Compare commits

..
217 changed files with 37649 additions and 4248 deletions

No files matched your search

+1
View File
@@ -24,6 +24,7 @@ install-sh
missing
.svn
*.layout
projects/Xcode4/Frameworks/
projects/Xcode/Frameworks/
#========
+10
View File
@@ -9,6 +9,16 @@ SUBDIRS = mongoose code
EXTRA_DIST = \
FS2OpenSCPReadMe.doc \
projects/MSVC_2005/Freespace2.sln \
projects/MSVC_2005/Freespace2.vcproj \
projects/MSVC_2005/code.vcproj \
projects/MSVC_6/Fred2.dsp \
projects/MSVC_6/Freespace2.dsp \
projects/MSVC_6/Freespace2.dsw \
projects/MSVC_6/code.dsp \
projects/MSVC_6/libjpeg.dsp \
projects/MSVC_6/liblua.dsp \
projects/MSVC_6/wxFRED2.dsp \
projects/Xcode/English.lproj/InfoPlist.strings \
projects/Xcode/FS2_Open.icns \
projects/Xcode/FS2_Open.xcodeproj/project.pbxproj \
+3 -3
View File
@@ -5,12 +5,12 @@ environment:
- VisualStudioVersion: 10.0
PlatformToolset: v100
ProjectPath: projects/MSVC_2010/Freespace2.vcxproj
- VisualStudioVersion: 11.0
PlatformToolset: v110
ProjectPath: projects/MSVC_2012/Freespace2.vcxproj
- VisualStudioVersion: 12.0
PlatformToolset: v120
ProjectPath: projects/MSVC_2013/Freespace2.vcxproj
- VisualStudioVersion: 14.0
PlatformToolset: v140
ProjectPath: projects/MSVC_2015/Freespace2.vcxproj
build_script:
- msbuild "%ProjectPath%" /p:Configuration="Debug SSE2" /m /p:PlatformToolset="%PlatformToolset%" /verbosity:minimal
test: off
-2
View File
@@ -1,7 +1,5 @@
#!/usr/bin/env sh
set -e
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
# Nothing to do here
:
+2 -4
View File
@@ -1,11 +1,9 @@
#!/usr/bin/env sh
set -e
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
# Due to a bug in gcc the array bounds check isn't working correctly
# This can be removed when gcc is updated
AUTOGEN_CONFIG="CXXFLAGS=-Wno-array-bounds --enable-fatal-warnings --enable-generic-architecture"
AUTOGEN_CONFIG="CXXFLAGS=-Wno-array-bounds --enable-fatal-warnings"
if [ "$CONFIGURATION" = "Debug" ]; then
AUTOGEN_CONFIG="$AUTOGEN_CONFIG --enable-debug"
@@ -13,6 +11,6 @@ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
./autogen.sh $AUTOGEN_CONFIG
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
cd projects/Xcode
cd projects/Xcode4
tar -xvzf Frameworks.tgz
fi
-2
View File
@@ -1,7 +1,5 @@
#!/usr/bin/env sh
set -e
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
# Nothing to do here
:
+2 -4
View File
@@ -1,10 +1,8 @@
#!/usr/bin/env sh
set -e
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
make -j 4
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
cd projects/Xcode
xcodebuild ARCHS=$MACOSX_ARCH ONLY_ACTIVE_ARCH=NO -configuration "$CONFIGURATION" | xcpretty -c && exit ${PIPESTATUS[0]}
cd projects/Xcode4
xcodebuild ARCHS=$MACOSX_ARCH ONLY_ACTIVE_ARCH=NO -configuration "$CONFIGURATION" | xcpretty -c
fi
+1 -1
View File
@@ -1239,7 +1239,7 @@ int ai_big_strafe_maybe_retreat(float dist, vec3d *target_pos)
float dist_to_target, dist_normal_to_target, time_to_target;
dist_to_target = vm_vec_mag_quick(&vec_to_target);
if (vm_vec_mag_quick(&aip->big_attack_surface_normal) > 0.9) {
dist_normal_to_target = -vm_vec_dot(&vec_to_target, &aip->big_attack_surface_normal);
dist_normal_to_target = -vm_vec_dotprod(&vec_to_target, &aip->big_attack_surface_normal);
} else {
dist_normal_to_target = 0.2f * vm_vec_mag_quick(&vec_to_target);
}
+67 -57
View File
@@ -980,7 +980,7 @@ int ai_is_stealth_visible(object *viewer_objp, object *stealth_objp)
if ( !ship_is_visible_by_team(stealth_objp, &Ships[viewer_objp->instance]) ) {
vm_vec_sub(&vec_to_stealth, &stealth_objp->pos, &viewer_objp->pos);
dist_to_stealth = vm_vec_mag_quick(&vec_to_stealth);
dot_to_stealth = vm_vec_dot(&viewer_objp->orient.vec.fvec, &vec_to_stealth) / dist_to_stealth;
dot_to_stealth = vm_vec_dotprod(&viewer_objp->orient.vec.fvec, &vec_to_stealth) / dist_to_stealth;
// get max dist at which stealth is visible
max_stealth_dist = get_skill_stealth_dist_scaler() * STEALTH_MAX_VIEW_DIST;
@@ -1539,8 +1539,8 @@ float turn_towards_tangent(object *objp, vec3d *point, float radius)
vec3d v2g;
vm_vec_normalized_dir(&vec_to_point, point, &objp->pos);
vm_vec_cross(&up_vec, &vec_to_point, &objp->orient.vec.fvec);
vm_vec_cross(&perp_vec, &vec_to_point, &up_vec);
vm_vec_crossprod(&up_vec, &vec_to_point, &objp->orient.vec.fvec);
vm_vec_crossprod(&perp_vec, &vec_to_point, &up_vec);
vm_vec_scale_add(&perp_point, point, &vec_to_point, -radius);
if (vm_vec_dot(&objp->orient.vec.fvec, &perp_vec) > 0.0f) {
@@ -1563,7 +1563,7 @@ float turn_toward_tangent_with_axis(object *objp, object *center_objp, float rad
// find closest z of center objp
vm_vec_sub(&sph_r_vec, &objp->pos, &center_objp->pos);
center_obj_z = vm_vec_dot(&sph_r_vec, &center_objp->orient.vec.fvec);
center_obj_z = vm_vec_dotprod(&sph_r_vec, &center_objp->orient.vec.fvec);
// find pt on axis with closest z
vm_vec_scale_add(&center_vec, &center_objp->pos, &center_objp->orient.vec.fvec, center_obj_z);
@@ -1571,10 +1571,10 @@ float turn_toward_tangent_with_axis(object *objp, object *center_objp, float rad
// get r_vec
vm_vec_sub(&r_vec, &objp->pos, &center_vec);
Assert( (vm_vec_dot(&r_vec, &center_objp->orient.vec.fvec) < 0.0001));
Assert( (vm_vec_dotprod(&r_vec, &center_objp->orient.vec.fvec) < 0.0001));
// get theta vec - perp to r_vec and z_vec
vm_vec_cross(&theta_vec, &center_objp->orient.vec.fvec, &r_vec);
vm_vec_crossprod(&theta_vec, &center_objp->orient.vec.fvec, &r_vec);
#ifndef NDEBUG
float mag;
@@ -1583,11 +1583,11 @@ float turn_toward_tangent_with_axis(object *objp, object *center_objp, float rad
#endif
vec3d temp;
vm_vec_cross(&temp, &r_vec, &theta_vec);
vm_vec_crossprod(&temp, &r_vec, &theta_vec);
#ifndef NDEBUG
float dot;
dot = vm_vec_dot(&temp, &center_objp->orient.vec.fvec);
dot = vm_vec_dotprod(&temp, &center_objp->orient.vec.fvec);
Assert( dot >0.9999 && dot < 1.0001);
#endif
@@ -1613,17 +1613,17 @@ void get_tangent_point(vec3d *goal_point, object *objp, vec3d *point, float radi
vec3d up_vec, perp_vec;
vm_vec_normalized_dir(&vec_to_point, point, &objp->pos);
vm_vec_cross(&up_vec, &vec_to_point, &objp->orient.vec.fvec);
vm_vec_crossprod(&up_vec, &vec_to_point, &objp->orient.vec.fvec);
while (IS_VEC_NULL(&up_vec)) {
vec3d rnd_vec;
vm_vec_rand_vec_quick(&rnd_vec);
vm_vec_add2(&rnd_vec, &objp->orient.vec.fvec);
vm_vec_cross(&up_vec, &vec_to_point, &rnd_vec);
vm_vec_crossprod(&up_vec, &vec_to_point, &rnd_vec);
}
vm_vec_cross(&perp_vec, &vec_to_point, &up_vec);
vm_vec_crossprod(&perp_vec, &vec_to_point, &up_vec);
vm_vec_normalize(&perp_vec);
vm_vec_scale_add(&perp_point, point, &vec_to_point, -radius);
@@ -2621,7 +2621,7 @@ void create_path_to_point(vec3d *curpos, vec3d *goalpos, object *curobjp, object
void copy_xlate_model_path_points(object *objp, model_path *mp, int dir, int count, int path_num, pnode *pnp, int randomize_pnt)
{
polymodel *pm;
int i, modelnum, model_instance_num;
int i, modelnum;
vec3d v1;
int pp_index; // index in Path_points at which to store point, if this is a modify-in-place (pnp ! NULL)
int start_index, finish_index;
@@ -2646,12 +2646,14 @@ void copy_xlate_model_path_points(object *objp, model_path *mp, int dir, int cou
// Goober5000 - check for rotating submodels
modelnum = Ship_info[Ships[objp->instance].ship_info_index].model_num;
model_instance_num = Ships[objp->instance].model_instance_num;
pm = model_get(modelnum);
if ((mp->parent_submodel >= 0) && (pm->submodel[mp->parent_submodel].movement_type >= 0))
{
rotating_submodel = true;
// start submodel calculation
ship_model_start(objp);
model_find_submodel_offset(&submodel_offset, modelnum, mp->parent_submodel);
}
else
@@ -2668,7 +2670,7 @@ void copy_xlate_model_path_points(object *objp, model_path *mp, int dir, int cou
{
// movement... find location of point like with docking code and spark generation
vm_vec_sub(&local_vert, &mp->verts[i].pos, &submodel_offset);
model_instance_find_world_point(&v1, &local_vert, model_instance_num, mp->parent_submodel, &objp->orient, &objp->pos);
model_find_world_point(&v1, &local_vert, modelnum, mp->parent_submodel, &objp->orient, &objp->pos);
}
else
{
@@ -2690,6 +2692,12 @@ void copy_xlate_model_path_points(object *objp, model_path *mp, int dir, int cou
add_path_point(&v1, path_num, i, pp_index);
offset++;
}
// stop submodel calculation
if (!rotating_submodel)
{
ship_model_stop(objp);
}
}
@@ -2958,8 +2966,8 @@ int maybe_avoid_player(object *objp, vec3d *goal_pos)
} else {
vec3d tvec1;
vm_vec_normalize(&avoid_vec);
vm_vec_cross(&tvec1, &n_vec_to_goal, &avoid_vec);
vm_vec_cross(&avoid_vec, &tvec1, &n_vec_to_player);
vm_vec_crossprod(&tvec1, &n_vec_to_goal, &avoid_vec);
vm_vec_crossprod(&avoid_vec, &tvec1, &n_vec_to_player);
}
// Now, avoid_vec is a vector perpendicular to the vector to the player and the direction *objp
@@ -6245,9 +6253,10 @@ void render_path_points(object *objp)
vec3d dock_point, global_dock_point;
vertex v;
ship_model_start(&Objects[aip->goal_objnum]);
if (pm->n_docks) {
dock_point = pm->docking_bays[0].pnt[0];
model_instance_find_world_point(&global_dock_point, &dock_point, shipp->model_instance_num, 0, &dobjp->orient, &dobjp->pos );
model_find_world_point(&global_dock_point, &dock_point, pm->id, 0, &dobjp->orient, &dobjp->pos );
g3_rotate_vertex(&v, &global_dock_point);
gr_set_color(255, 255, 255);
g3_draw_sphere( &v, 1.5f);
@@ -6280,6 +6289,8 @@ void render_path_points(object *objp)
pp++;
}
}
ship_model_stop(&Objects[aip->goal_objnum]);
}
/**
@@ -6485,7 +6496,7 @@ void set_predicted_enemy_pos(vec3d *predicted_enemy_pos, object *pobjp, vec3d *e
vec3d temp;
vm_vec_sub(&temp, enemy_pos, &pobjp->pos);
vm_vec_normalize_quick(&temp);
float dot = vm_vec_dot(&temp, &pobjp->orient.vec.fvec);
float dot = vm_vec_dotprod(&temp, &pobjp->orient.vec.fvec);
float st_err = 3.0f * (1.4f - dot) * (1.0f + dist / (get_skill_stealth_dist_scaler() * STEALTH_MAX_VIEW_DIST)) * (1 - aip->ai_accuracy);
scale += st_err;
}
@@ -7045,7 +7056,7 @@ void ai_stealth_find()
// if dist is near max and dot is close to 1, accel, afterburn
vm_vec_sub(&vec_to_enemy, &new_pos, &Pl_objp->pos);
dist_to_enemy = vm_vec_normalize_quick(&vec_to_enemy);
dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.vec.fvec);
dot_to_enemy = vm_vec_dotprod(&vec_to_enemy, &Pl_objp->orient.vec.fvec);
// if i think i should see him ahead and i don't, set goal pos and turn around, but only if I haven't seen him for a while
if ( (delta_time > 800) && (aip->submode_parm0 == SM_SF_AHEAD) && (dot_to_enemy > .94) && (dist_to_enemy < get_skill_stealth_dist_scaler()*STEALTH_MAX_VIEW_DIST + 50) ) {
@@ -7054,7 +7065,7 @@ void ai_stealth_find()
aip->submode_parm0 = SM_SF_BEHIND;
vm_vec_sub(&vec_to_enemy, &new_pos, &Pl_objp->pos);
dist_to_enemy = vm_vec_normalize_quick(&vec_to_enemy);
dot_to_enemy = vm_vec_dot(&vec_to_enemy, &Pl_objp->orient.vec.fvec);
dot_to_enemy = vm_vec_dotprod(&vec_to_enemy, &Pl_objp->orient.vec.fvec);
}
if ( (dist_to_enemy > get_skill_stealth_dist_scaler()*STEALTH_MAX_VIEW_DIST) && (dot_to_enemy > 0.94f) ) { // 20 degree half angle
@@ -7084,7 +7095,7 @@ void ai_stealth_find()
ai_turn_towards_vector(&new_pos, Pl_objp, flFrametime, sip->srotation_time, NULL, NULL, 0.0f, 0);
}
dot_from_enemy = -vm_vec_dot(&vec_to_enemy, &En_objp->orient.vec.fvec);
dot_from_enemy = -vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.vec.fvec);
attack_set_accel(aip, sip, dist_to_enemy, dot_to_enemy, dot_from_enemy);
}
@@ -7133,10 +7144,10 @@ void ai_stealth_sweep()
}
// get "right" vector for box
vm_vec_cross(&right, &aip->stealth_velocity, &vmd_y_vector);
vm_vec_crossprod(&right, &aip->stealth_velocity, &vmd_y_vector);
if ( vm_vec_mag_quick(&right) < 0.01 ) {
vm_vec_cross(&right, &aip->stealth_velocity, &vmd_z_vector);
vm_vec_crossprod(&right, &aip->stealth_velocity, &vmd_z_vector);
}
vm_vec_normalize_quick(&right);
@@ -7145,7 +7156,7 @@ void ai_stealth_sweep()
vm_vec_copy_normalize_quick(&forward, &aip->stealth_velocity);
// get "up" for box
vm_vec_cross(&up, &forward, &right);
vm_vec_crossprod(&up, &forward, &right);
// lost far away ahead (do box)
switch(aip->submode_parm0) {
@@ -7215,7 +7226,7 @@ void ai_stealth_sweep()
if (dist_to_goal < 100) {
vec3d vec_to_goal;
vm_vec_normalized_dir(&vec_to_goal, &goal_pt, &Pl_objp->pos);
dot = vm_vec_dot(&vec_to_goal, &Pl_objp->orient.vec.fvec);
dot = vm_vec_dotprod(&vec_to_goal, &Pl_objp->orient.vec.fvec);
}
accelerate_ship(aip, 0.8f*dot);
@@ -7861,7 +7872,7 @@ void ai_chase_big_get_separations(object *attack_objp, object *target_objp, vec3
vm_vec_sub(&vec_to_target, &attack_objp->pos, &target_objp->pos);
// find the distance between centers along forward direction of ships
perp_dist = vm_vec_dot(&vec_to_target, &target_objp->orient.vec.fvec);
perp_dist = vm_vec_dotprod(&vec_to_target, &target_objp->orient.vec.fvec);
// subtract off perp component to get "horizontal" separation vector between cylinders [ASSUMING parallel]
vm_vec_scale_add(horz_vec_to_target, &vec_to_target, &target_objp->orient.vec.fvec, -perp_dist);
@@ -7892,7 +7903,7 @@ void ai_chase_big_parallel_set_goal(vec3d *goal_pos, object *attack_objp, object
r_target = MAX(temp, r_target);
// are we opposing (only when other ship is not moving)
opposing = ( vm_vec_dot(&attack_objp->orient.vec.fvec, &target_objp->orient.vec.fvec) < 0 );
opposing = ( vm_vec_dotprod(&attack_objp->orient.vec.fvec, &target_objp->orient.vec.fvec) < 0 );
ai_chase_big_get_separations(attack_objp, target_objp, &horz_vec_to_target, &optimal_separation, &separation);
@@ -7910,7 +7921,7 @@ void ai_chase_big_parallel_set_goal(vec3d *goal_pos, object *attack_objp, object
// find the distance between centers along forward direction of ships
vec3d vec_to_target;
vm_vec_sub(&vec_to_target, &target_objp->pos, &attack_objp->pos);
float perp_dist = vm_vec_dot(&vec_to_target, &target_objp->orient.vec.fvec);
float perp_dist = vm_vec_dotprod(&vec_to_target, &target_objp->orient.vec.fvec);
float match_accel = 0.0f;
float length_scale = attack_objp->radius;
@@ -8060,7 +8071,7 @@ void ai_cruiser_chase()
// moving
if (moving) {
// if within 90 degrees of en forward, go into parallel, otherwise circle
if ( vm_vec_dot(&En_objp->orient.vec.fvec, &Pl_objp->orient.vec.fvec) > 0 ) {
if ( vm_vec_dotprod(&En_objp->orient.vec.fvec, &Pl_objp->orient.vec.fvec) > 0 ) {
aip->submode = SM_BIG_PARALLEL;
aip->submode_start_time = Missiontime;
}
@@ -8080,9 +8091,9 @@ void ai_cruiser_chase()
vec3d temp;
float desired_sep, cur_sep;
// we're behind the enemy ship
if (vm_vec_dot(&vec_to_enemy, &En_objp->orient.vec.fvec) > 0) {
if (vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.vec.fvec) > 0) {
// and we're turning toward the enemy
if (vm_vec_dot(&En_objp->orient.vec.fvec, &Pl_objp->orient.vec.fvec) > 0) {
if (vm_vec_dotprod(&En_objp->orient.vec.fvec, &Pl_objp->orient.vec.fvec) > 0) {
// get separation
ai_chase_big_get_separations(Pl_objp, En_objp, &temp, &desired_sep, &cur_sep);
// and the separation is > 0.9 desired
@@ -8097,9 +8108,9 @@ void ai_cruiser_chase()
vec3d temp;
float desired_sep, cur_sep;
// we're behind the enemy ship
if (vm_vec_dot(&vec_to_enemy, &En_objp->orient.vec.fvec) > 0) {
if (vm_vec_dotprod(&vec_to_enemy, &En_objp->orient.vec.fvec) > 0) {
// and we're turning toward the enemy
if (vm_vec_dot(&En_objp->orient.vec.fvec, &Pl_objp->orient.vec.fvec) > 0) {
if (vm_vec_dotprod(&En_objp->orient.vec.fvec, &Pl_objp->orient.vec.fvec) > 0) {
// get separation
ai_chase_big_get_separations(Pl_objp, En_objp, &temp, &desired_sep, &cur_sep);
// and the separation is > 0.9 desired
@@ -8112,7 +8123,7 @@ void ai_cruiser_chase()
// in front of ship
else {
// and we're turning toward the enemy
if (vm_vec_dot(&En_objp->orient.vec.fvec, &Pl_objp->orient.vec.fvec) < 0) {
if (vm_vec_dotprod(&En_objp->orient.vec.fvec, &Pl_objp->orient.vec.fvec) < 0) {
// get separation
ai_chase_big_get_separations(Pl_objp, En_objp, &temp, &desired_sep, &cur_sep);
// and the separation is > 0.9 desired
@@ -8127,7 +8138,7 @@ void ai_cruiser_chase()
case SM_BIG_PARALLEL:
// we're opposing
if ( vm_vec_dot(&Pl_objp->orient.vec.fvec, &En_objp->orient.vec.fvec) < 0 ) {
if ( vm_vec_dotprod(&Pl_objp->orient.vec.fvec, &En_objp->orient.vec.fvec) < 0 ) {
// and the other ship is moving
if (moving) {
// and we no longer overlap
@@ -8985,7 +8996,7 @@ void set_goal_dock_orient(matrix *dom, vec3d *docker_p0, vec3d *docker_p1, vec3d
// Pre-multiply the orientation of the source object (docker_orient) by the transpose
// of the docking bay's orientation, ie unrotate the source object's matrix.
vm_transpose(&m2);
vm_transpose_matrix(&m2);
vm_matrix_x_matrix(dom, &m3, &m2);
}
@@ -9029,9 +9040,8 @@ void find_adjusted_dockpoint_info(vec3d *global_p0, vec3d *global_p1, vec3d *glo
{
vec3d submodel_offset;
vec3d local_p0, local_p1;
ship *shipp;
shipp = &Ships[objp->instance];
ship_model_start(objp);
// calculate the dockpoint locations relative to the unrotated submodel
model_find_submodel_offset(&submodel_offset, modelnum, submodel);
@@ -9039,11 +9049,13 @@ void find_adjusted_dockpoint_info(vec3d *global_p0, vec3d *global_p1, vec3d *glo
vm_vec_sub(&local_p1, &pm->docking_bays[dock_index].pnt[1], &submodel_offset);
// find the dynamic positions of the dockpoints
model_instance_find_world_point(global_p0, &local_p0, shipp->model_instance_num, submodel, &objp->orient, &objp->pos);
model_instance_find_world_point(global_p1, &local_p1, shipp->model_instance_num, submodel, &objp->orient, &objp->pos);
model_find_world_point(global_p0, &local_p0, modelnum, submodel, &objp->orient, &objp->pos);
model_find_world_point(global_p1, &local_p1, modelnum, submodel, &objp->orient, &objp->pos);
// find the normal of the first dockpoint
model_instance_find_world_dir(global_p0_norm, &pm->docking_bays[dock_index].norm[0], shipp->model_instance_num, submodel, &objp->orient);
model_find_world_dir(global_p0_norm, &pm->docking_bays[dock_index].norm[0], modelnum, submodel, &objp->orient, &objp->pos);
ship_model_stop(objp);
}
// use the static dockpoints
else
@@ -9125,21 +9137,23 @@ float dock_orient_and_approach(object *docker_objp, int docker_index, object *do
vec3d submodel_offset;
vec3d dockpoint_temp;
ship_model_start(dockee_objp);
// get submodel center
model_find_submodel_offset(&submodel_offset, sip1->model_num, dockee_rotating_submodel);
vm_vec_add(&submodel_pos, &dockee_objp->pos, &submodel_offset);
polymodel_instance *pmi1 = model_get_instance(Ships[dockee_objp->instance].model_instance_num);
// get angular velocity of dockpoint
//WMC - hack(?) to fix bug where sii might not exist
if ( pmi1->submodel[dockee_rotating_submodel].sii != NULL ) {
submodel_omega = pmi1->submodel[dockee_rotating_submodel].sii->cur_turn_rate;
if(pm1->submodel[dockee_rotating_submodel].sii != NULL) {
submodel_omega = pm1->submodel[dockee_rotating_submodel].sii->cur_turn_rate;
}
// get radius to dockpoint
vm_vec_avg(&dockpoint_temp, &dockee_p0, &dockee_p1);
submodel_radius = vm_vec_dist(&submodel_pos, &dockpoint_temp);
ship_model_stop(dockee_objp);
}
// Goober5000
@@ -9247,7 +9261,7 @@ float dock_orient_and_approach(object *docker_objp, int docker_index, object *do
vec3d origin_docker_point, adjusted_docker_point, v_offset;
// find out the rotation matrix that will get us from the old to the new rotation
vm_copy_transpose(&temp, &docker_objp->orient);
vm_copy_transpose_matrix(&temp, &docker_objp->orient);
vm_matrix_x_matrix(&m_offset, &temp, &dom);
// now find out the new docker point after being adjusted for the new orientation
@@ -9787,7 +9801,7 @@ float get_cylinder_points(object *other_objp, object *cyl_objp, vec3d *axis_pt,
// get point on axis and on cylinder
// extended_cylinder_z is along extended cylinder
// cylinder_z is capped within cylinder
float extended_cylinder_z = vm_vec_dot(&r_sph, &cyl_objp->orient.vec.fvec);
float extended_cylinder_z = vm_vec_dotprod(&r_sph, &cyl_objp->orient.vec.fvec);
// get pt on axis of extended cylinder
vm_vec_scale_add(axis_pt, &cyl_objp->pos, &cyl_objp->orient.vec.fvec, extended_cylinder_z);
@@ -9823,7 +9837,7 @@ void ai_big_guard()
// get position relative to cylinder of guard_objp
extended_z = get_cylinder_points(Pl_objp, guard_objp, &axis_pt, &r_vec, &radius);
vm_vec_cross(&theta_vec, &guard_objp->orient.vec.fvec, &r_vec);
vm_vec_crossprod(&theta_vec, &guard_objp->orient.vec.fvec, &r_vec);
// half ships circle each way
if (objval > 0.5f) {
@@ -13648,7 +13662,7 @@ int aas_1(object *objp, ai_info *aip, vec3d *safe_pos)
vec3d vec_from_exp;
float dir = 1.0f;
vm_vec_sub(&vec_from_exp, &objp->pos, &expected_pos);
float dot = vm_vec_dot(&vec_from_exp, &weapon_objp->orient.vec.fvec);
float dot = vm_vec_dotprod(&vec_from_exp, &weapon_objp->orient.vec.fvec);
if (dot > -30) {
// if we're already on the other side of the explosion, don't try to fly behind it
dir = -1.0f;
@@ -13812,22 +13826,18 @@ int ai_await_repair_frame(object *objp, ai_info *aip)
// Maybe should only do this if they are preventing their wing from re-entering.
void ai_maybe_self_destruct(object *objp, ai_info *aip)
{
Assertion(objp->type == OBJ_SHIP, "ai_maybe_self_destruct() can only be called with objects that are ships!");
ship *shipp = &Ships[objp->instance];
// Some IFFs can be repaired, so no self-destruct.
// In multiplayer, just don't self-destruct. I figured there would be a problem. -- MK, 3/19/98.
if ((Iff_info[shipp->team].flags & IFFF_SUPPORT_ALLOWED) || (Game_mode & GM_MULTIPLAYER))
if ((Iff_info[Ships[objp->instance].team].flags & IFFF_SUPPORT_ALLOWED) || (Game_mode & GM_MULTIPLAYER))
return;
// Small ships in a wing blow themselves up after awhile if engine or weapons system has been destroyed.
// Reason: Don't want them to prevent a re-emergence of the wing.
// Note: Don't blow up if not in a wing for two reasons: One, won't affect re-emergence of waves and (1) disable the Dragon
// mission would be broken.
// Also, don't blow up the ship if it has a ship flag preventing this - Goober5000
if ((Ship_info[shipp->ship_info_index].flags & SIF_SMALL_SHIP) && (shipp->wingnum >= 0) && !(shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT)) {
if ((ship_get_subsystem_strength(shipp, SUBSYSTEM_ENGINE) <= 0.0f) ||
(ship_get_subsystem_strength(shipp, SUBSYSTEM_WEAPONS) <= 0.0f)) {
if ((Ship_info[Ships[objp->instance].ship_info_index].flags & SIF_SMALL_SHIP) && (Ships[objp->instance].wingnum != -1)) {
if ((ship_get_subsystem_strength(&Ships[objp->instance], SUBSYSTEM_ENGINE) <= 0.0f) ||
(ship_get_subsystem_strength(&Ships[objp->instance], SUBSYSTEM_WEAPONS) <= 0.0f)) {
if (aip->self_destruct_timestamp < 0)
aip->self_destruct_timestamp = timestamp(90 * 1000); // seconds until self-destruct
} else {
+5 -55
View File
@@ -1308,8 +1308,6 @@ void ship_get_global_turret_info(object *objp, model_subsystem *tp, vec3d *gpos,
vm_vec_unrotate(gvec, &tp->turret_norm, &objp->orient);
}
void turret_ai_update_aim(ai_info *aip, object *En_Objp, ship_subsys *ss);
/**
* Given an object and a turret on that object, return the actual firing point of the gun and its normal.
*
@@ -1334,59 +1332,11 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
gun_pos = &tp->turret_firing_point[ssp->turret_next_fire_pos % tp->turret_num_firing_points];
//model_find_world_point(gpos, gun_pos, tp->model_num, tp->turret_gun_sobj, &objp->orient, &objp->pos );
model_instance_find_world_point(gpos, gun_pos, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
model_instance_find_world_point(gpos, gun_pos, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
if (use_angles) {
model_instance_find_world_dir(gvec, &tp->turret_norm, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient);
} else if (tp->flags2 & MSS_FLAG2_SHARE_FIRE_DIRECTION) {
vec3d avg, tmp_pos, tmp_target, enemy_point, turret_norm;
vm_vec_avg_n(&avg, tp->turret_num_firing_points, tp->turret_firing_point);
model_instance_find_world_point(&tmp_pos, &avg, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
if (targetp == nullptr) {
Assertion(ssp->turret_enemy_objnum >= 0, "The turret enemy object number %d for %s on ship number %d is invalid.", ssp->turret_enemy_objnum, ssp->sub_name, ssp->parent_objnum);
object *lep = &Objects[ssp->turret_enemy_objnum];
int best_weapon_tidx = turret_select_best_weapon(ssp, lep);
//This turret doesn't have any good weapons
if (best_weapon_tidx < 0)
return;
weapon_info *wip = get_turret_weapon_wip(&ssp->weapons, best_weapon_tidx);
float weapon_system_strength = ship_get_subsystem_strength(&Ships[ssp->parent_objnum], SUBSYSTEM_WEAPONS);
turret_ai_update_aim(&Ai_info[Ships[ssp->parent_objnum].ai_index], &Objects[ssp->turret_enemy_objnum], ssp);
if ((ssp->targeted_subsys != nullptr) && !(ssp->flags & SSF_NO_SS_TARGETING)) {
vm_vec_unrotate(&enemy_point, &ssp->targeted_subsys->system_info->pnt, &Objects[ssp->turret_enemy_objnum].orient);
vm_vec_add2(&enemy_point, &ssp->last_aim_enemy_pos);
} else {
if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
vm_vec_unrotate(&turret_norm, &tp->turret_norm, &objp->orient);
ai_big_pick_attack_point_turret(lep, ssp, &tmp_pos, &turret_norm, &enemy_point, MIN(wip->max_speed * wip->lifetime, wip->weapon_range), tp->turret_fov);
}
else {
enemy_point = ssp->last_aim_enemy_pos;
}
}
vec3d target_moving_direction = ssp->last_aim_enemy_vel;
//Try to guess where the enemy will be, and store that spot in predicted_enemy_pos
if (The_mission.ai_profile->flags & AIPF_USE_ADDITIVE_WEAPON_VELOCITY) {
vm_vec_scale_sub2(&target_moving_direction, &objp->phys_info.vel, wip->vel_inherit_amount);
}
set_predicted_enemy_pos_turret(&tmp_target, &tmp_pos, objp, &enemy_point, &target_moving_direction, wip->max_speed, ssp->turret_time_enemy_in_range * (weapon_system_strength + 1.0f) / 2.0f);
} else {
tmp_target = *targetp;
}
vm_vec_normalized_dir(gvec, &tmp_target, &tmp_pos);
} else {
if (use_angles)
model_instance_find_world_dir(gvec, &tp->turret_norm, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos );
else {
//vector gun_pos2;
//vm_vec_add(&gun_pos2, gpos, gun_pos);
vm_vec_normalized_dir(gvec, targetp, gpos);
@@ -2629,7 +2579,7 @@ void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum)
ss->turret_next_fire_pos = ffp_pos;
}
ship_get_global_turret_gun_info(&Objects[parent_objnum], ss, &gpos, &gvec, use_angles, &predicted_enemy_pos);
ship_get_global_turret_gun_info(&Objects[parent_objnum], ss, &gpos, &gvec, use_angles, &predicted_enemy_pos);
// Fire in the direction the turret is facing, not right at the target regardless of turret dir.
vm_vec_sub(&v2e, &predicted_enemy_pos, &gpos);
+11 -16
View File
@@ -329,11 +329,6 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
}
asp->objnum = objnum;
asp->model_instance_num = -1;
if (model_get(asip->model_num[asteroid_subtype])->flags & PM_FLAG_HAS_INTRINSIC_ROTATE) {
asp->model_instance_num = model_create_instance(false, asip->model_num[asteroid_subtype]);
}
// Add to Asteroid_used_list
asteroid_obj_list_add(objnum);
@@ -833,12 +828,10 @@ void asteroid_delete( object * obj )
asp = &Asteroids[num];
if (asp->model_instance_num >= 0)
model_delete_instance(asp->model_instance_num);
Assert( Num_asteroids >= 0 );
asp->flags = 0;
Num_asteroids--;
Assert(Num_asteroids >= 0);
asteroid_obj_list_remove( obj );
}
@@ -937,7 +930,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
if ( asteroid_hit_info == NULL ) {
// asteroid weapon collision
Assert( other_obj->type == OBJ_WEAPON );
mc.model_instance_num = Asteroids[num].model_instance_num;
mc.model_instance_num = -1;
mc.model_num = Asteroid_info[Asteroids[num].asteroid_type].model_num[asteroid_subtype]; // Fill in the model to check
model_clear_instance( mc.model_num );
mc.orient = &pasteroid->orient; // The object's orient
@@ -1012,6 +1005,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
mc.flags = MC_ONLY_SPHERE | MC_CHECK_SPHERELINE;
SCP_vector<int> submodel_vector;
polymodel *pm;
polymodel_instance *pmi;
if (model_collide(&mc)) {
@@ -1025,7 +1019,8 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
model_get_rotating_submodel_list(&submodel_vector, heavy_obj);
// Get polymodel and turn off all rotating submodels, collide against only 1 at a time.
pmi = model_get_instance(Ships[heavy_obj->instance].model_instance_num);
pm = model_get(Ship_info[Ships[heavy_obj->instance].ship_info_index].model_num);
pmi = model_get_instance(Ships[pship_obj->instance].model_instance_num);
// turn off all rotating submodels and test for collision
for (size_t j=0; j<submodel_vector.size(); j++) {
@@ -1046,10 +1041,10 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// find the start and end positions of the sphere in submodel RF
pmi->submodel[submodel_vector[i]].angs = pmi->submodel[submodel_vector[i]].prev_angs;
world_find_model_instance_point(&p0, &light_obj->last_pos, pmi, submodel_vector[i], &heavy_obj->last_orient, &heavy_obj->last_pos);
world_find_model_instance_point(&p0, &light_obj->last_pos, pm, pmi, submodel_vector[i], &heavy_obj->last_orient, &heavy_obj->last_pos);
pmi->submodel[submodel_vector[i]].angs = copy_angles;
world_find_model_instance_point(&p1, &light_obj->pos, pmi, submodel_vector[i], &heavy_obj->orient, &heavy_obj->pos);
world_find_model_instance_point(&p1, &light_obj->pos, pm, pmi, submodel_vector[i], &heavy_obj->orient, &heavy_obj->pos);
mc.p0 = &p0;
mc.p1 = &p1;
@@ -1066,14 +1061,14 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// set up asteroid_hit_info for rotating submodel
if (asteroid_hit_info->edge_hit == 0) {
model_instance_find_obj_dir(&asteroid_hit_info->collision_normal, &mc.hit_normal, Ships[heavy_obj->instance].model_instance_num, mc.hit_submodel, &heavy_obj->orient);
model_instance_find_obj_dir(&asteroid_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
}
// find position in submodel RF of light object at collison
vec3d int_light_pos, diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&int_light_pos, mc.p0, &diff, mc.hit_dist);
model_instance_find_world_point(&asteroid_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
model_instance_find_world_point(&asteroid_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
}
}
// Don't look at this submodel again
@@ -1098,7 +1093,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// get collision normal if not edge hit
if (asteroid_hit_info->edge_hit == 0) {
model_instance_find_obj_dir(&asteroid_hit_info->collision_normal, &mc.hit_normal, Ships[heavy_obj->instance].model_instance_num, mc.hit_submodel, &heavy_obj->orient);
model_instance_find_obj_dir(&asteroid_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
}
// find position in submodel RF of light object at collison
@@ -1112,7 +1107,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
} else {
// Asteroid is heavier obj
mc.model_instance_num = Asteroids[num].model_instance_num;
mc.model_instance_num = -1;
mc.model_num = Asteroid_info[Asteroids[num].asteroid_type].model_num[asteroid_subtype]; // Fill in the model to check
model_clear_instance( mc.model_num );
mc.orient = &pasteroid->orient; // The object's orient
-1
View File
@@ -98,7 +98,6 @@ public:
typedef struct asteroid {
int flags;
int objnum;
int model_instance_num;
int asteroid_type; // 0..MAX_DEBRIS_TYPES
int asteroid_subtype; // Index in asteroid_info for modelnum and modelp
int check_for_wrap; // timestamp to check for asteroid wrapping around field
+9 -323
View File
@@ -38,7 +38,6 @@
#include <ctype.h>
#include <limits.h>
#include <iomanip>
// --------------------------------------------------------------------------------------------------------------------
// Private macros.
@@ -124,7 +123,7 @@ bitmap_lookup::bitmap_lookup(int bitmap_num):
Width = be->bm.w;
Height = be->bm.h;
Bitmap_data = (ubyte*)vm_malloc(Width * Height * Num_channels * sizeof(ubyte));
Bitmap_data = (float*)vm_malloc(Width * Height * Num_channels * sizeof(float));
gr_get_bitmap_from_texture((void*)Bitmap_data, bitmap_num);
}
@@ -157,7 +156,7 @@ float bitmap_lookup::get_channel_red(float u, float v)
int x = fl2i(map_texture_address(u) * (Width-1));
int y = fl2i(map_texture_address(v) * (Height-1));
return i2fl(Bitmap_data[(y*Width + x)*Num_channels]) / 255.0f;
return Bitmap_data[(y*Width + x)*Num_channels];
}
float bitmap_lookup::get_channel_green(float u, float v)
@@ -170,7 +169,7 @@ float bitmap_lookup::get_channel_green(float u, float v)
int x = fl2i(map_texture_address(u) * (Width-1));
int y = fl2i(map_texture_address(v) * (Height-1));
return i2fl(Bitmap_data[(y*Width + x)*Num_channels + 1]) / 255.0f;
return Bitmap_data[(y*Width + x)*Num_channels + 1];
}
float bitmap_lookup::get_channel_blue(float u, float v)
@@ -180,7 +179,7 @@ float bitmap_lookup::get_channel_blue(float u, float v)
int x = fl2i(map_texture_address(u) * (Width-1));
int y = fl2i(map_texture_address(v) * (Height-1));
return i2fl(Bitmap_data[(y*Width + x)*Num_channels + 2]) / 255.0f;
return Bitmap_data[(y*Width + x)*Num_channels + 2];
}
float bitmap_lookup::get_channel_alpha(float u, float v)
@@ -190,7 +189,7 @@ float bitmap_lookup::get_channel_alpha(float u, float v)
int x = fl2i(map_texture_address(u) * (Width-1));
int y = fl2i(map_texture_address(v) * (Height-1));
return i2fl(Bitmap_data[(y*Width + x)*Num_channels + 3]) / 255.0f;
return Bitmap_data[(y*Width + x)*Num_channels + 3];
}
/**
@@ -293,104 +292,6 @@ DCF(bm_frag, "Shows BmpMan fragmentation") {
key_getch();
}
DCF(bm_used, "Shows BmpMan Slot Usage") {
if (dc_optional_string_either("help", "--help")) {
dc_printf("Displays used bmpman slots usage with a breakdown per filetype\n\n");
return;
}
int none = 0, pcx = 0, user = 0, tga = 0, png = 0; int jpg = 0, dds = 0, ani = 0;
int eff = 0, eff_dds = 0, eff_tga = 0, eff_png = 0, eff_jpg = 0, eff_pcx = 0;
int render_target_dynamic = 0, render_target_static = 0;
for (int i = 0; i<MAX_BITMAPS; i++) {
switch (bm_bitmaps[i].type) {
case BM_TYPE_NONE:
none++;
break;
case BM_TYPE_PCX:
pcx++;
break;
case BM_TYPE_USER:
user++;
break;
case BM_TYPE_TGA:
tga++;
break;
case BM_TYPE_PNG:
// TODO distinguish png(static) from apng
png++;
break;
case BM_TYPE_JPG:
jpg++;
break;
case BM_TYPE_DDS:
dds++;
break;
case BM_TYPE_ANI:
ani++;
break;
case BM_TYPE_EFF:
eff++;
switch (bm_bitmaps[i].info.ani.eff.type) {
case BM_TYPE_DDS:
eff_dds++;
break;
case BM_TYPE_TGA:
eff_tga++;
break;
case BM_TYPE_PNG:
eff_png++;
break;
case BM_TYPE_JPG:
eff_jpg++;
break;
case BM_TYPE_PCX:
eff_pcx++;
break;
default:
Warning(LOCATION, "Unhandled EFF image type (%i), get a coder!", bm_bitmaps[i].info.ani.eff.type);
break;
}
break;
case BM_TYPE_RENDER_TARGET_STATIC:
render_target_static++;
break;
case BM_TYPE_RENDER_TARGET_DYNAMIC:
render_target_dynamic++;
break;
default:
Warning(LOCATION, "Unhandled image type (%i), get a coder!", bm_bitmaps[i].type);
break;
}
}
SCP_stringstream text;
text << "BmpMan Used Slots\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << pcx << ", PCX\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << user << ", User\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << tga << ", TGA\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << png << ", PNG\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << jpg << ", JPG\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << dds << ", DDS\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << ani << ", ANI\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << eff << ", EFF\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << eff_dds << ", EFF/DDS\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << eff_tga << ", EFF/TGA\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << eff_png << ", EFF/PNG\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << eff_jpg << ", EFF/JPG\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << eff_pcx << ", EFF/PCX\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << render_target_static << ", Render/Static\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << render_target_dynamic << ", Render/Dynamic\n";
text << " " << std::dec << std::setw(4) << std::setfill('0') << MAX_BITMAPS-none << "/" << MAX_BITMAPS << ", Total\n";
text << "\n";
// TODO consider converting 1's to monospace to make debug console output prettier
mprintf(("%s", text.str().c_str())); // log for ease for copying data
dc_printf("%s", text.str().c_str()); // instant gratification
}
DCF(bmpman, "Shows/changes bitmap caching parameters and usage") {
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: BmpMan [arg]\nWhere arg can be any of the following:\n");
@@ -1012,110 +913,6 @@ int bm_is_valid(int handle) {
return (bm_bitmaps[handle % MAX_BITMAPS].handle == handle);
}
// Load an image and validate it while retrieving information for later use
// Input: type = current BM_TYPE_*
// n = location in bm_bitmaps[]
// filename = name of the current file
// img_cfp = already open CFILE handle, if available
//
// Output: w = bmp width
// h = bmp height
// bpp = bmp bits per pixel
// c_type = output for an updated BM_TYPE_*
// mm_lvl = number of mipmap levels for the image
// size = size of the data contained in the image
static int bm_load_info(BM_TYPE type, int n, const char *filename, CFILE *img_cfp, int *w, int *h, int *bpp, BM_TYPE *c_type, int *mm_lvl, int *size)
{
int dds_ct;
if (type == BM_TYPE_DDS) {
int dds_error = dds_read_header(filename, img_cfp, w, h, bpp, &dds_ct, mm_lvl, size);
if (dds_error != DDS_ERROR_NONE) {
mprintf(("DDS ERROR: Couldn't open '%s' -- %s\n", filename, dds_error_string(dds_error)));
return -1;
}
switch (dds_ct) {
case DDS_DXT1:
*c_type = BM_TYPE_DXT1;
break;
case DDS_DXT3:
*c_type = BM_TYPE_DXT3;
break;
case DDS_DXT5:
*c_type = BM_TYPE_DXT5;
break;
case DDS_UNCOMPRESSED:
*c_type = BM_TYPE_DDS;
break;
case DDS_CUBEMAP_DXT1:
*c_type = BM_TYPE_CUBEMAP_DXT1;
break;
case DDS_CUBEMAP_DXT3:
*c_type = BM_TYPE_CUBEMAP_DXT3;
break;
case DDS_CUBEMAP_DXT5:
*c_type = BM_TYPE_CUBEMAP_DXT5;
break;
case DDS_CUBEMAP_UNCOMPRESSED:
*c_type = BM_TYPE_CUBEMAP_DDS;
break;
default:
Error(LOCATION, "Bad DDS file compression! Not using DXT1,3,5: %s", filename);
return -1;
}
}
// if its a tga file
else if (type == BM_TYPE_TGA) {
int tga_error = targa_read_header(filename, img_cfp, w, h, bpp, NULL);
if (tga_error != TARGA_ERROR_NONE) {
mprintf(("tga: Couldn't open '%s'\n", filename));
return -1;
}
}
// if its a png file
else if (type == BM_TYPE_PNG) {
int png_error = png_read_header(filename, img_cfp, w, h, bpp, NULL);
if (png_error != PNG_ERROR_NONE) {
mprintf(("png: Couldn't open '%s'\n", filename));
return -1;
}
}
// if its a jpg file
else if (type == BM_TYPE_JPG) {
int jpg_error = jpeg_read_header(filename, img_cfp, w, h, bpp, NULL);
if (jpg_error != JPEG_ERROR_NONE) {
mprintf(("jpg: Couldn't open '%s'\n", filename));
return -1;
}
}
// if its a pcx file
else if (type == BM_TYPE_PCX) {
int pcx_error = pcx_read_header(filename, img_cfp, w, h, bpp, NULL);
if (pcx_error != PCX_ERROR_NONE) {
mprintf(("pcx: Couldn't open '%s'\n", filename));
return -1;
}
}
else {
Assertion(false, "Unknown file type specified! This is probably a coding error.");
return -1;
}
return 0;
}
int bm_load(const char *real_filename) {
int i, free_slot = -1;
int w, h, bpp = 8;
@@ -1188,7 +985,7 @@ int bm_load(const char *real_filename) {
goto Done;
}
rc = bm_load_info(type, free_slot, filename, img_cfp, &w, &h, &bpp, &c_type, &mm_lvl, &bm_size);
rc = gr_bm_load(type, free_slot, filename, img_cfp, &w, &h, &bpp, &c_type, &mm_lvl, &bm_size);
if (rc != 0)
goto Done;
@@ -1314,109 +1111,6 @@ bool bm_load_and_parse_eff(const char *filename, int dir_type, int *nframes, int
return true;
}
/**
* Lock an image files data into memory
*/
static int bm_load_image_data(const char *filename, int handle, int bitmapnum, ubyte bpp, ubyte flags, bool nodebug)
{
BM_TYPE c_type = BM_TYPE_NONE;
ubyte true_bpp;
bitmap_entry *be = &bm_bitmaps[bitmapnum];
bitmap *bmp = &be->bm;
Assert(!Is_standalone);
if (bmp->true_bpp > bpp)
true_bpp = bmp->true_bpp;
else
true_bpp = bpp;
// don't do a bpp check here since it could be different in OGL - taylor
if (bmp->data == 0) {
Assert(be->ref_count == 1);
if (be->type != BM_TYPE_USER && !nodebug) {
if (bmp->data == 0)
nprintf(("BmpMan", "Loading %s for the first time.\n", be->filename));
}
if (!Bm_paging) {
if (be->type != BM_TYPE_USER && !nodebug)
nprintf(("Paging", "Loading %s (%dx%dx%d)\n", be->filename, bmp->w, bmp->h, true_bpp));
}
// select proper format
if (flags & BMP_AABITMAP)
BM_SELECT_ALPHA_TEX_FORMAT();
else if (flags & BMP_TEX_ANY)
BM_SELECT_TEX_FORMAT();
else
BM_SELECT_SCREEN_FORMAT();
// make sure we use the real graphic type for EFFs
if (be->type == BM_TYPE_EFF) {
c_type = be->info.ani.eff.type;
}
else {
c_type = be->type;
}
switch (c_type)
{
case BM_TYPE_PCX:
bm_lock_pcx(handle, bitmapnum, be, bmp, true_bpp, flags);
break;
case BM_TYPE_ANI:
bm_lock_ani(handle, bitmapnum, be, bmp, true_bpp, flags);
break;
case BM_TYPE_TGA:
bm_lock_tga(handle, bitmapnum, be, bmp, true_bpp, flags);
break;
case BM_TYPE_PNG:
//libpng handles compression with zlib
bm_lock_png(handle, bitmapnum, be, bmp, true_bpp, flags);
break;
case BM_TYPE_JPG:
bm_lock_jpg(handle, bitmapnum, be, bmp, true_bpp, flags);
break;
case BM_TYPE_DDS:
case BM_TYPE_DXT1:
case BM_TYPE_DXT3:
case BM_TYPE_DXT5:
case BM_TYPE_CUBEMAP_DDS:
case BM_TYPE_CUBEMAP_DXT1:
case BM_TYPE_CUBEMAP_DXT3:
case BM_TYPE_CUBEMAP_DXT5:
bm_lock_dds(handle, bitmapnum, be, bmp, true_bpp, flags);
break;
case BM_TYPE_USER:
bm_lock_user(handle, bitmapnum, be, bmp, true_bpp, flags);
break;
default:
Warning(LOCATION, "Unsupported type in bm_lock -- %d\n", c_type);
return -1;
}
// always go back to screen format
BM_SELECT_SCREEN_FORMAT();
// make sure we actually did something
if (!(bmp->data))
return -1;
}
return 0;
}
int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *keyframe, int can_drop_frames, int dir_type) {
int i, n;
anim the_anim;
@@ -1584,8 +1278,8 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke
bm_bitmaps[n + i].info.ani.eff.type = eff_type;
sprintf(bm_bitmaps[n + i].info.ani.eff.filename, "%s_%.4d", clean_name, i);
// bm_load_info() returns non-0 on failure
if (bm_load_info(eff_type, n + i, bm_bitmaps[n + i].info.ani.eff.filename, NULL, &anim_width, &anim_height, &bpp, &c_type, &mm_lvl, &img_size)) {
// gr_bm_load() returns non-0 on failure
if (gr_bm_load(eff_type, n + i, bm_bitmaps[n + i].info.ani.eff.filename, NULL, &anim_width, &anim_height, &bpp, &c_type, &mm_lvl, &img_size)) {
// if we didn't get anything then bail out now
if (i == 0) {
Warning(LOCATION, "EFF: No frame images were found. EFF, %s, is invalid.\n", filename);
@@ -1810,21 +1504,13 @@ bitmap * bm_lock(int handle, ubyte bpp, ubyte flags, bool nodebug) {
#endif
// read the file data
if (bm_load_image_data(be->filename, handle, bitmapnum, bpp, flags, nodebug) == -1) {
if (gr_bm_lock(be->filename, handle, bitmapnum, bpp, flags, nodebug) == -1) {
// oops, this isn't good - reset and return NULL
bm_unlock( handle );
bm_unload( handle );
return NULL;
}
if (!gr_bm_data(bitmapnum, bmp)) {
// graphics subsystem failed, reset and return NULL
bm_unlock( handle );
bm_unload( handle );
return NULL;
}
MONITOR_INC(NumBitmapPage, 1);
MONITOR_INC(SizeBitmapPage, bmp->w*bmp->h);
+1 -1
View File
@@ -175,7 +175,7 @@ void *bm_malloc(int handle, int size);
void bm_update_memory_used(int n, int size);
class bitmap_lookup {
ubyte *Bitmap_data;
float *Bitmap_data;
int Width;
int Height;
+1 -3
View File
@@ -330,10 +330,8 @@ void camera::get_info(vec3d *position, matrix *orientation)
eyep = get_submodel_eye(pm, object_host_submodel);
if(eyep)
{
Assertion(objp->type == OBJ_SHIP, "This part of the code expects the object to be a ship");
vec3d c_pos_in;
find_submodel_instance_point_normal(&c_pos_in, &host_normal, Ships[objp->instance].model_instance_num, eyep->parent, &eyep->pnt, &eyep->norm);
find_submodel_instance_point_normal( &c_pos_in, &host_normal, objp, eyep->parent, &eyep->pnt, &eyep->norm);
vm_vec_unrotate(&c_pos, &c_pos_in, &objp->orient);
vm_vec_add2(&c_pos, &objp->pos);
}
+190 -218
View File
@@ -92,87 +92,77 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
#define CFILE_STACK_MAX 8
int cfile_inited = 0;
static int Cfile_stack_pos = 0;
int Cfile_stack_pos = 0;
static char Cfile_stack[CFILE_STACK_MAX][CFILE_ROOT_DIRECTORY_LEN];
char Cfile_stack[CFILE_STACK_MAX][CFILE_ROOT_DIRECTORY_LEN];
Cfile_block Cfile_block_list[MAX_CFILE_BLOCKS];
static CFILE Cfile_list[MAX_CFILE_BLOCKS];
CFILE Cfile_list[MAX_CFILE_BLOCKS];
static const char *Cfile_cdrom_dir = NULL;
const char *Cfile_cdrom_dir = NULL;
//
// Function prototypes for internally-called functions
//
static int cfget_cfile_block();
static CFILE *cf_open_fill_cfblock(const char* source, int line, FILE * fp, int type);
static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int type, int offset, int size);
int cfget_cfile_block();
CFILE *cf_open_fill_cfblock(FILE * fp, int type);
CFILE *cf_open_packed_cfblock(FILE *fp, int type, int offset, int size);
#if defined _WIN32
static CFILE *cf_open_mapped_fill_cfblock(const char* source, int line, HANDLE hFile, int type);
CFILE *cf_open_mapped_fill_cfblock(HANDLE hFile, int type);
#elif defined SCP_UNIX
static CFILE *cf_open_mapped_fill_cfblock(const char* source, int line, FILE *fp, int type);
CFILE *cf_open_mapped_fill_cfblock(FILE *fp, int type);
#endif
static void cf_chksum_long_init();
void cf_chksum_long_init();
static void dump_opened_files()
void cfile_close()
{
for (int i = 0; i < MAX_CFILE_BLOCKS; i++) {
auto cb = &Cfile_block_list[i];
if (cb->type != CFILE_BLOCK_UNUSED) {
mprintf((" %s:%d\n", cb->source_file, cb->line_num));
}
}
}
static void cfile_close()
{
mprintf(("Still opened files:\n"));
dump_opened_files();
cf_free_secondary_filelist();
}
#ifdef SCP_UNIX
#define MIN_NUM_PATH_COMPONENTS 2 /* Directory + file */
#else
#define MIN_NUM_PATH_COMPONENTS 3 /* Drive + directory + file */
#endif
/**
* @brief Determine if the given path is in the root directory
*
* @param exe_path Path to executable
*
* @return true if root directory, false if not
*/
static bool cfile_in_root_dir(const char *exe_path)
// determine if the given path is in a root directory (c:\ or c:\freespace2.exe or c:\fred2.exe etc)
int cfile_in_root_dir(const char *exe_path)
{
int new_token;
int token_count = 0;
const char *p = exe_path;
char path_copy[CFILE_ROOT_DIRECTORY_LEN] = "";
char *tok;
Assert(exe_path != NULL);
// bogus
if(exe_path == NULL){
return 1;
}
// copy the path
memset(path_copy, 0, CFILE_ROOT_DIRECTORY_LEN);
strncpy(path_copy, exe_path, CFILE_ROOT_DIRECTORY_LEN - 1);
// count how many slashes there are in the path
tok = strtok(path_copy, DIR_SEPARATOR_STR);
if(tok == NULL){
return 1;
}
do {
new_token = 0;
while (*p == DIR_SEPARATOR_CHAR) {
p++;
}
token_count++;
tok = strtok(NULL, DIR_SEPARATOR_STR);
} while(tok != NULL);
#ifdef SCP_UNIX
// /freespace works, / does not
if(token_count <= 1) {
#else
// C:/freespace works, C:/ does not
if(token_count <= 2){
#endif
return 1;
}
while ((*p != '\0') && (*p != DIR_SEPARATOR_CHAR)) {
new_token = 1;
p++;
}
token_count += new_token;
} while (*p != '\0');
return (token_count < MIN_NUM_PATH_COMPONENTS);
// not-root directory
return 0;
}
/**
* @brief Initialize the cfile system. Called once at application start.
* Initializes the cfile system. Called once at application start.
*
* @param exe_dir Path to a file (not a directory)
* @param cdrom_dir Path to a CD drive mount point (may be NULL)
@@ -184,61 +174,57 @@ int cfile_init(const char *exe_dir, const char *cdrom_dir)
{
int i;
encrypt_init(); /* initialize encryption */
// initialize encryption
encrypt_init();
if (cfile_inited) {
return 0;
}
if ( !cfile_inited ) {
char buf[CFILE_ROOT_DIRECTORY_LEN];
char buf[CFILE_ROOT_DIRECTORY_LEN];
cfile_inited = 1;
strncpy(buf, exe_dir, CFILE_ROOT_DIRECTORY_LEN - 1);
buf[CFILE_ROOT_DIRECTORY_LEN - 1] = '\0';
i = strlen(buf);
memset(buf, 0, CFILE_ROOT_DIRECTORY_LEN);
strncpy(buf, exe_dir, CFILE_ROOT_DIRECTORY_LEN - 1);
i = strlen(buf);
/* Determine if we in a root directory? */
if (cfile_in_root_dir(buf)) {
MessageBox((HWND)NULL,
"FreeSpace2/Fred2 cannot be run from a drive root directory!",
"Error", MB_OK);
return 1;
}
// are we in a root directory?
if(cfile_in_root_dir(buf)){
MessageBox((HWND)NULL, "FreeSpace2/Fred2 cannot be run from a drive root directory!", "Error", MB_OK);
return 1;
}
// This needs to be set here because cf_build_secondary_filelist assumes it to be true
cfile_inited = 1;
while (i--) {
if (buf[i] == DIR_SEPARATOR_CHAR){
break;
}
}
/*
* Determine the executable's directory. Note that DIR_SEPARATOR_CHAR
* is guaranteed to be found in the string else cfile_in_root_dir()
* would have failed.
*/
if (i >= 2) {
buf[i] = 0;
cfile_chdir(buf);
} else {
MessageBox((HWND)NULL, "Error trying to determine executable root directory!", "Error", MB_OK);
return 1;
}
char *p;
p = strrchr(buf, DIR_SEPARATOR_CHAR);
*p = '\0';
cfile_chdir(buf);
// set root directory
strncpy(Cfile_root_dir, buf, CFILE_ROOT_DIRECTORY_LEN - 1);
// set root directory
strncpy(Cfile_root_dir, buf, CFILE_ROOT_DIRECTORY_LEN-1);
#ifdef SCP_UNIX
snprintf(Cfile_user_dir, CFILE_ROOT_DIRECTORY_LEN - 1, "%s/%s/",
detect_home(), Osreg_user_dir);
snprintf(Cfile_user_dir, CFILE_ROOT_DIRECTORY_LEN-1, "%s/%s/", detect_home(), Osreg_user_dir);
#endif
for (i = 0; i < MAX_CFILE_BLOCKS; i++) {
Cfile_block_list[i].type = CFILE_BLOCK_UNUSED;
for ( i = 0; i < MAX_CFILE_BLOCKS; i++ ) {
Cfile_block_list[i].type = CFILE_BLOCK_UNUSED;
}
// 32 bit CRC table init
cf_chksum_long_init();
Cfile_cdrom_dir = cdrom_dir;
cf_build_secondary_filelist(Cfile_cdrom_dir);
atexit( cfile_close );
}
// 32 bit CRC table init
cf_chksum_long_init();
Cfile_cdrom_dir = cdrom_dir;
cf_build_secondary_filelist(Cfile_cdrom_dir);
atexit(cfile_close);
return 0;
}
@@ -252,13 +238,13 @@ void cfile_refresh()
#ifdef _WIN32
// Changes to a drive if valid.. 1=A, 2=B, etc
// If flag, then changes to it.
// Returns 0 if not-valid, 1 if valid.
int cfile_chdrive( int DriveNum, int flag )
{
int Valid = 0;
#ifdef _WIN32
int n, org;
org = -1;
@@ -274,108 +260,99 @@ int cfile_chdrive( int DriveNum, int flag )
if ( (!flag) && (n != org) )
_chdrive( org );
#endif // _WIN32
return Valid;
}
#endif // _WIN32
/**
* @brief Common code for changing directory
*
* @param new_dir Directory to which to change
* @param cur_dir Current directory (only used on Windows)
*
* @retval 0 Success
* @retval 1 Failed to change to new directory's drive (Windows only)
* @retval 2 Failed to change to new directory
*/
static int _cfile_chdir(const char *new_dir, const char *cur_dir __UNUSED)
// push current directory on a 'stack' (so we can restore it) and change the directory
int cfile_push_chdir(int type)
{
int status;
const char *path = NULL;
const char no_dir[] = "\\.";
int e;
char dir[CFILE_ROOT_DIRECTORY_LEN];
char OriginalDirectory[CFILE_ROOT_DIRECTORY_LEN];
char *Path = NULL;
char NoDir[] = "\\.";
_getcwd(OriginalDirectory, CFILE_ROOT_DIRECTORY_LEN-1);
Assert(Cfile_stack_pos < CFILE_STACK_MAX);
if ( Cfile_stack_pos >= CFILE_STACK_MAX )
return -1;
strncpy(Cfile_stack[Cfile_stack_pos++], OriginalDirectory, CFILE_ROOT_DIRECTORY_LEN-1);
cf_create_default_path_string( dir, sizeof(dir)-1, type, NULL );
#ifdef _WIN32
const char *colon = strchr(new_dir, ':');
char *colon_pos = strchr(dir, ':');
if (colon) {
if (!cfile_chdrive(tolower(*(colon - 1)) - 'a' + 1, 1))
if (colon_pos) {
if (!cfile_chdrive( tolower(*(colon_pos - 1)) - 'a' + 1, 1))
return 1;
path = colon + 1;
Path = colon_pos+1;
} else
#endif /* _WIN32 */
#endif // _WIN32
{
path = new_dir;
Path = dir;
}
if (*path == '\0') {
path = no_dir;
if (!(*Path)) {
Path = NoDir;
}
/* This chdir might get a critical error! */
status = _chdir(path);
if (status != 0) {
// This chdir might get a critical error!
e = _chdir( Path );
if (e) {
#ifdef _WIN32
cfile_chdrive(tolower(cur_dir[0]) - 'a' + 1, 1);
#endif /* _WIN32 */
cfile_chdrive( tolower(OriginalDirectory[0]) - 'a' + 1, 1 );
#endif // _WIN32
return 2;
}
return 0;
}
/**
* @brief Push current directory onto a 'stack' and change to a new directory
*
* The current directory is pushed onto a 'stack' so that it can be easily
* restored at a later time. The new directory is derived from @a type.
*
* @param type path type (CF_TYPE_xxx)
*
* @retval -1 'Stack' is full
* @retval 0 Success
* @retval 1 Failed to change to new directory's drive (Windows only)
* @retval 2 Failed to change to new directory
*/
int cfile_push_chdir(int type)
{
char dir[CFILE_ROOT_DIRECTORY_LEN];
char OriginalDirectory[CFILE_ROOT_DIRECTORY_LEN];
_getcwd(OriginalDirectory, CFILE_ROOT_DIRECTORY_LEN - 1);
Assert(Cfile_stack_pos < CFILE_STACK_MAX);
if (Cfile_stack_pos >= CFILE_STACK_MAX) {
return -1;
}
strncpy(Cfile_stack[Cfile_stack_pos++], OriginalDirectory,
CFILE_ROOT_DIRECTORY_LEN - 1);
cf_create_default_path_string(dir, sizeof(dir) - 1, type, NULL);
return _cfile_chdir(dir, OriginalDirectory);
}
/**
* @brief Change to the specified directory
*
* @param dir Directory
*
* @retval 0 Success
* @retval 1 Failed to change to new directory's drive (Windows only)
* @retval 2 Failed to change to new directory
*/
int cfile_chdir(const char *dir)
{
int e;
char OriginalDirectory[CFILE_ROOT_DIRECTORY_LEN];
const char *Path = NULL;
char NoDir[] = "\\.";
_getcwd(OriginalDirectory, CFILE_ROOT_DIRECTORY_LEN - 1);
_getcwd(OriginalDirectory, CFILE_ROOT_DIRECTORY_LEN-1);
return _cfile_chdir(dir, OriginalDirectory);
#ifdef _WIN32
const char *colon_pos = strchr(dir, ':');
if (colon_pos) {
if (!cfile_chdrive( tolower(*(colon_pos - 1)) - 'a' + 1, 1))
return 1;
Path = colon_pos+1;
} else
#endif // _WIN32
{
Path = dir;
}
if (!(*Path)) {
Path = NoDir;
}
// This chdir might get a critical error!
e = _chdir( Path );
if (e) {
#ifdef _WIN32
cfile_chdrive( tolower(OriginalDirectory[0]) - 'a' + 1, 1 );
#endif // _WIN32
return 2;
}
return 0;
}
int cfile_pop_dir()
@@ -428,7 +405,7 @@ int cfile_flush_dir(int dir_type)
for (unsigned int i = 0; i < globinfo.gl_pathc; i++) {
// Determine if this is a regular file
struct stat statbuf;
memset(&statbuf, 0, sizeof(statbuf));
stat(globinfo.gl_pathv[i], &statbuf);
if (S_ISREG(statbuf.st_mode)) {
// delete the file
@@ -472,24 +449,34 @@ char *cf_add_ext(const char *filename, const char *ext)
return path;
}
/**
* @brief Delete the specified file
*
* @param filename Name of file to delete
* @param path_type Path type (CF_TYPE_xxx)
*
* @return 0 on failure, 1 on success
*/
int cf_delete(const char *filename, int path_type)
// Deletes a file. Returns 0 if an error occurs, 1 on success
int cf_delete(const char *filename, int dir_type)
{
char longname[MAX_PATH_LEN];
Assert(CF_TYPE_SPECIFIED(path_type));
Assert( CF_TYPE_SPECIFIED(dir_type) );
cf_create_default_path_string(longname, sizeof(longname) - 1,
path_type, filename);
cf_create_default_path_string( longname, sizeof(longname)-1, dir_type, filename );
return (_unlink(longname) != -1);
FILE *fp = fopen(longname, "rb");
if (fp) {
// delete the file
fclose(fp);
if(_unlink(longname) == -1)
{
//ERROR - file is probably read only
return 0;
}
else
{
return 1;
}
}
else
{
//ERROR - file doesn't exist
return 0;
}
}
@@ -644,7 +631,7 @@ extern int game_cd_changed();
// error ==> NULL
//
CFILE *_cfopen(const char* source, int line, const char *file_path, const char *mode, int type, int dir_type, bool localize)
CFILE *cfopen(const char *file_path, const char *mode, int type, int dir_type, bool localize)
{
/* Bobboau, what is this doing here? 31 is way too short... - Goober5000
if( strlen(file_path) > 31 )
@@ -729,7 +716,7 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
FILE *fp = fopen(longname, happy_mode);
if (fp) {
return cf_open_fill_cfblock(source, line, fp, dir_type);
return cf_open_fill_cfblock(fp, dir_type);
}
return NULL;
}
@@ -758,12 +745,12 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
hFile = CreateFile(longname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
return cf_open_mapped_fill_cfblock(source, line, hFile, dir_type);
return cf_open_mapped_fill_cfblock(hFile, dir_type);
}
#elif defined SCP_UNIX
FILE *fp = fopen( longname, "rb" );
if (fp) {
return cf_open_mapped_fill_cfblock(source, line, fp, dir_type);
return cf_open_mapped_fill_cfblock(fp, dir_type);
}
#endif
}
@@ -775,10 +762,10 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
if ( fp ) {
if ( offset ) {
// Found it in a pack file
return cf_open_packed_cfblock(source, line, fp, dir_type, offset, size );
return cf_open_packed_cfblock(fp, dir_type, offset, size );
} else {
// Found it in a normal file
return cf_open_fill_cfblock(source, line, fp, dir_type);
return cf_open_fill_cfblock(fp, dir_type);
}
}
}
@@ -799,7 +786,7 @@ CFILE *_cfopen(const char* source, int line, const char *file_path, const char *
// returns: success ==> address of CFILE structure
// error ==> NULL
//
CFILE *_cfopen_special(const char* source, int line, const char *file_path, const char *mode, const int size, const int offset, int dir_type)
CFILE *cfopen_special(const char *file_path, const char *mode, const int size, const int offset, int dir_type)
{
if ( !cfile_inited) {
Int3();
@@ -824,10 +811,10 @@ CFILE *_cfopen_special(const char* source, int line, const char *file_path, cons
if ( offset ) {
// it's in a pack file
return cf_open_packed_cfblock(source, line, fp, dir_type, offset, size);
return cf_open_packed_cfblock(fp, dir_type, offset, size);
} else {
// it's a normal file
return cf_open_fill_cfblock(source, line, fp, dir_type);
return cf_open_fill_cfblock(fp, dir_type);
}
}
@@ -846,7 +833,7 @@ CFILE *ctmpfile()
FILE *fp;
fp = tmpfile();
if ( fp )
return cf_open_fill_cfblock(LOCATION, fp, 0);
return cf_open_fill_cfblock(fp, 0);
else
return NULL;
}
@@ -859,7 +846,7 @@ CFILE *ctmpfile()
// returns: success ==> index in Cfile_block_list[] array
// failure ==> -1
//
static int cfget_cfile_block()
int cfget_cfile_block()
{
int i;
Cfile_block *cb;
@@ -876,13 +863,7 @@ static int cfget_cfile_block()
// If we've reached this point, a free Cfile_block could not be found
nprintf(("Warning","A free Cfile_block could not be found.\n"));
// Dump a list of all opened files
mprintf(("Out of cfile blocks! Currently opened files:\n"));
dump_opened_files();
Assertion(false, "There are no more free cfile blocks. This means that there are too many files opened by FSO.\n"
"This is probably caused by a programming or scripting error where a file does not get closed."); // out of free cfile blocks
Assert(0); // out of free cfile blocks
return -1;
}
@@ -960,7 +941,7 @@ int cf_is_valid(CFILE *cfile)
// returns: success ==> ptr to CFILE structure.
// error ==> NULL
//
static CFILE *cf_open_fill_cfblock(const char* source, int line, FILE *fp, int type)
CFILE *cf_open_fill_cfblock(FILE *fp, int type)
{
int cfile_block_index;
@@ -979,9 +960,6 @@ static CFILE *cf_open_fill_cfblock(const char* source, int line, FILE *fp, int t
cfbp->fp = fp;
cfbp->dir_type = type;
cfbp->max_read_len = 0;
cfbp->source_file = source;
cfbp->line_num = line;
int pos = ftell(fp);
if(pos == -1L)
@@ -999,7 +977,7 @@ static CFILE *cf_open_fill_cfblock(const char* source, int line, FILE *fp, int t
// returns: success ==> ptr to CFILE structure.
// error ==> NULL
//
static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int type, int offset, int size)
CFILE *cf_open_packed_cfblock(FILE *fp, int type, int offset, int size)
{
// Found it in a pack file
int cfile_block_index;
@@ -1021,9 +999,6 @@ static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int
cfbp->dir_type = type;
cfbp->max_read_len = 0;
cfbp->source_file = source;
cfbp->line_num = line;
cf_init_lowlevel_read_code(cfp,offset, size, 0 );
return cfp;
@@ -1039,9 +1014,9 @@ static CFILE *cf_open_packed_cfblock(const char* source, int line, FILE *fp, int
// returns: ptr CFILE structure.
//
#if defined _WIN32
static CFILE *cf_open_mapped_fill_cfblock(const char* source, int line, HANDLE hFile, int type)
CFILE *cf_open_mapped_fill_cfblock(HANDLE hFile, int type)
#elif defined SCP_UNIX
static CFILE *cf_open_mapped_fill_cfblock(const char* source, int line, FILE *fp, int type)
CFILE *cf_open_mapped_fill_cfblock(FILE *fp, int type)
#endif
{
int cfile_block_index;
@@ -1068,9 +1043,6 @@ static CFILE *cf_open_mapped_fill_cfblock(const char* source, int line, FILE *fp
#endif
cfbp->dir_type = type;
cfbp->source_file = source;
cfbp->line_num = line;
cf_init_lowlevel_read_code(cfp, 0, 0, 0 );
#if defined _WIN32
cfbp->hMapFile = CreateFileMapping(cfbp->hInFile, NULL, PAGE_READONLY, 0, 0, NULL);
@@ -1606,7 +1578,7 @@ char *cfgets(char *buf, int n, CFILE *cfile)
// CRC code for mission validation. given to us by Kevin Bentley on 7/20/98. Some sort of
// checksumming code that he wrote a while ago.
#define CRC32_POLYNOMIAL 0xEDB88320
static uint CRCTable[256];
uint CRCTable[256];
#define CF_CHKSUM_SAMPLE_SIZE 512
@@ -1643,7 +1615,7 @@ uint cf_add_chksum_long(uint seed, ubyte *buffer, int size)
return crc;
}
static void cf_chksum_long_init()
void cf_chksum_long_init()
{
int i, j;
uint crc;
@@ -1664,7 +1636,7 @@ static void cf_chksum_long_init()
// single function convenient to use for both short and long checksums
// NOTE : only one of chk_short or chk_long must be non-NULL (indicating which checksum to perform)
static int cf_chksum_do(CFILE *cfile, ushort *chk_short, uint *chk_long, int max_size)
int cf_chksum_do(CFILE *cfile, ushort *chk_short, uint *chk_long, int max_size)
{
ubyte cf_buffer[CF_CHKSUM_SAMPLE_SIZE];
int is_long;
+2 -6
View File
@@ -129,15 +129,11 @@ int cf_get_dir_type(CFILE *cfile);
// Opens the file. If no path is given, use the extension to look into the
// default path. If mode is NULL, delete the file.
CFILE *_cfopen(const char* source_file, int line, const char *filename, const char *mode,
int type = CFILE_NORMAL, int dir_type = CF_TYPE_ANY, bool localize = false);
#define cfopen(...) _cfopen(LOCATION, __VA_ARGS__) // Pass source location to the function
CFILE *cfopen(const char *filename, const char *mode, int type = CFILE_NORMAL, int dir_type = CF_TYPE_ANY, bool localize = false);
// like cfopen(), but it accepts a fully qualified path only (ie, the result of a cf_find_file_location() call)
// NOTE: only supports reading files!!
CFILE *_cfopen_special(const char* source_file, int line, const char *file_path, const char *mode,
const int size, const int offset, int dir_type = CF_TYPE_ANY);
#define cfopen_special(...) _cfopen_special(LOCATION, __VA_ARGS__) // Pass source location to the function
CFILE *cfopen_special(const char *file_path, const char *mode, const int size, const int offset, int dir_type = CF_TYPE_ANY);
// Flush the open file buffer
int cflush(CFILE *cfile);
+1 -3
View File
@@ -39,13 +39,11 @@ typedef struct Cfile_block {
int size; // for packed files
size_t max_read_len; // max read offset, for special error handling
const char* source_file;
int line_num;
} Cfile_block;
#define MAX_CFILE_BLOCKS 64
extern Cfile_block Cfile_block_list[MAX_CFILE_BLOCKS];
extern CFILE Cfile_list[MAX_CFILE_BLOCKS];
// Called once to setup the low-level reading code.
void cf_init_lowlevel_read_code( CFILE * cfile, int lib_offset, int size, int pos );
+14 -24
View File
@@ -146,7 +146,9 @@ Flag exe_params[] =
{ "-fb_explosions", "Enable Framebuffer Shockwaves", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_explosions", },
{ "-no_deferred", "Disable Deferred Lighting", true, EASY_DEFAULT_MEM, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_deferred"},
{ "-enable_shadows", "Enable Shadows", true, EASY_MEM_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_shadows"},
{ "-img2dds", "Compress non-compressed images", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-img2dds", },
{ "-no_vsync", "Disable vertical sync", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_vsync", },
{ "-no_fps_capping", "Don't limit frames-per-second", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_fps_capping", },
{ "-cache_bitmaps", "Cache bitmaps between missions", true, 0, EASY_DEFAULT_MEM, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-cache_bitmaps", },
{ "-dualscanlines", "Add another pair of scanning lines", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dualscanlines", },
@@ -187,6 +189,7 @@ Flag exe_params[] =
{ "-no_glsl", "Disable GLSL (shader) support", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_glsl", },
{ "-ati_swap", "Fix colour issues on some ATI cards", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ati_swap", },
{ "-no_3d_sound", "Use only 2D/stereo for sound effects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_3d_sound", },
{ "-disable_glsl_model","Don't use shaders for model rendering", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_glsl_model", },
{ "-mipmap", "Enable mipmapping", true, 0, EASY_DEFAULT_MEM, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mipmap", },
#ifndef SCP_UNIX
{ "-disable_di_mouse", "Don't use DirectInput for mouse control", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_di_mouse", },
@@ -197,9 +200,6 @@ Flag exe_params[] =
{ "-no_batching", "Disable batched model rendering", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-no_geo_effects", "Disable geometry shader for effects", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-set_cpu_affinity", "Sets processor affinity to config value", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
#ifdef WIN32
{ "-fix_registry", "Use a different registry path", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
#endif
{ "-ingame_join", "Allow in-game joining", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-voicer", "Enable voice recognition", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-voicer", },
@@ -231,7 +231,6 @@ Flag exe_params[] =
{ "-profile_frame_time", "Profile engine subsystems", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_frame_timings", },
{ "-profile_write_file", "Write profiling information to file", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-profile_write_file", },
{ "-no_unfocused_pause","Don't pause if the window isn't focused", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_unfocused_pause", },
{ "-benchmark_mode", "Puts the game into benchmark mode", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-benchmark_mode", },
};
// forward declaration
@@ -346,10 +345,12 @@ int Cmdline_no_deferred_lighting = 0;
// Game Speed related
cmdline_parm cache_bitmaps_arg("-cache_bitmaps", NULL, AT_NONE); // Cmdline_cache_bitmaps
cmdline_parm img2dds_arg("-img2dds", NULL, AT_NONE); // Cmdline_img2dds
cmdline_parm no_fpscap("-no_fps_capping", "Don't limit frames-per-second", AT_NONE); // Cmdline_NoFPSCap
cmdline_parm no_vsync_arg("-no_vsync", NULL, AT_NONE); // Cmdline_no_vsync
int Cmdline_cache_bitmaps = 0; // caching of bitmaps between missions (faster loads, can hit swap on reload with <512 Meg RAM though) - taylor
int Cmdline_img2dds = 0;
int Cmdline_NoFPSCap = 0; // Disable FPS capping - kazan
int Cmdline_no_vsync = 0;
@@ -423,6 +424,7 @@ cmdline_parm noglsl_arg("-no_glsl", NULL, AT_NONE); // Cmdline_noglsl -- disa
cmdline_parm mipmap_arg("-mipmap", NULL, AT_NONE); // Cmdline_mipmap
cmdline_parm atiswap_arg("-ati_swap", NULL, AT_NONE); // Cmdline_atiswap - Fix ATI color swap issue for screenshots.
cmdline_parm no3dsound_arg("-no_3d_sound", NULL, AT_NONE); // Cmdline_no_3d_sound - Disable use of full 3D sounds
cmdline_parm no_glsl_models_arg("-disable_glsl_model", NULL, AT_NONE); // Cmdline_no_glsl_model_rendering -- switches model rendering to fixed pipeline
cmdline_parm no_di_mouse_arg("-disable_di_mouse", "Disable DirectInput mouse code (Windows only)", AT_NONE); // Cmdline_no_di_mouse -- Disables directinput use for mouse control
cmdline_parm no_drawrangeelements("-use_gldrawelements", NULL, AT_NONE); // Cmdline_drawelements -- Uses glDrawElements instead of glDrawRangeElements
cmdline_parm keyboard_layout("-keyboard_layout", "Specify keyboard layout (qwertz or azerty)", AT_STRING);
@@ -430,9 +432,6 @@ cmdline_parm old_collision_system("-old_collision", NULL, AT_NONE); // Cmdline_o
cmdline_parm gl_finish ("-gl_finish", NULL, AT_NONE);
cmdline_parm no_geo_sdr_effects("-no_geo_effects", NULL, AT_NONE);
cmdline_parm set_cpu_affinity("-set_cpu_affinity", NULL, AT_NONE);
#ifdef WIN32
cmdline_parm fix_registry("-fix_registry", NULL, AT_NONE);
#endif
int Cmdline_load_all_weapons = 0;
int Cmdline_nohtl = 0;
@@ -444,15 +443,13 @@ int Cmdline_no_pbo = 0;
int Cmdline_noglsl = 0;
int Cmdline_ati_color_swap = 0;
int Cmdline_no_3d_sound = 0;
int Cmdline_no_glsl_model_rendering = 0;
int Cmdline_no_di_mouse = 0;
int Cmdline_drawelements = 0;
char* Cmdline_keyboard_layout = NULL;
bool Cmdline_gl_finish = false;
bool Cmdline_no_geo_sdr_effects = false;
bool Cmdline_set_cpu_affinity = false;
#ifdef WIN32
bool Cmdline_alternate_registry_path = false;
#endif
// Developer/Testing related
cmdline_parm start_mission_arg("-start_mission", "Skip mainhall and run this mission", AT_STRING); // Cmdline_start_mission
@@ -482,8 +479,6 @@ cmdline_parm reparse_mainhall_arg("-reparse_mainhall", NULL, AT_NONE); //Cmdline
cmdline_parm frame_profile_arg("-profile_frame_time", NULL, AT_NONE); //Cmdline_frame_profile
cmdline_parm frame_profile_write_file("-profile_write_file", NULL, AT_NONE); // Cmdline_profile_write_file
cmdline_parm no_unfocused_pause_arg("-no_unfocused_pause", NULL, AT_NONE); //Cmdline_no_unfocus_pause
cmdline_parm benchmark_mode_arg("-benchmark_mode", NULL, AT_NONE); //Cmdline_benchmark_mode
char *Cmdline_start_mission = NULL;
int Cmdline_old_collision_sys = 0;
@@ -511,7 +506,6 @@ int Cmdline_reparse_mainhall = 0;
bool Cmdline_frame_profile = false;
bool Cmdline_profile_write_file = false;
bool Cmdline_no_unfocus_pause = false;
bool Cmdline_benchmark_mode = false;
// Other
cmdline_parm get_flags_arg("-get_flags", "Output the launcher flags file", AT_NONE);
@@ -1545,6 +1539,10 @@ bool SetCmdlineParams()
Cmdline_noglsl = 1;
}
if (no_glsl_models_arg.found() ) {
Cmdline_no_glsl_model_rendering = 1;
}
if (fxaa_arg.found() ) {
Cmdline_fxaa = true;
@@ -1559,6 +1557,9 @@ bool SetCmdlineParams()
Cmdline_no_di_mouse = 1;
}
if ( img2dds_arg.found() )
Cmdline_img2dds = 1;
if ( glow_arg.found() )
Cmdline_glow = 0;
@@ -1626,12 +1627,6 @@ bool SetCmdlineParams()
Cmdline_set_cpu_affinity = true;
}
#ifdef WIN32
if (fix_registry.found()) {
Cmdline_alternate_registry_path = true;
}
#endif
if ( snd_preload_arg.found() )
{
Cmdline_snd_preload = 1;
@@ -1769,11 +1764,6 @@ bool SetCmdlineParams()
{
Cmdline_no_unfocus_pause = true;
}
if (benchmark_mode_arg.found())
{
Cmdline_benchmark_mode = true;
}
//Deprecated flags - CommanderDJ
if( deprecated_spec_arg.found() )
+2 -4
View File
@@ -83,6 +83,7 @@ extern int Cmdline_no_deferred_lighting;
// Game Speed related
extern int Cmdline_cache_bitmaps;
extern int Cmdline_img2dds;
extern int Cmdline_NoFPSCap;
extern int Cmdline_no_vsync;
@@ -129,15 +130,13 @@ extern int Cmdline_noglsl;
extern int Cmdline_mipmap;
extern int Cmdline_ati_color_swap;
extern int Cmdline_no_3d_sound;
extern int Cmdline_no_glsl_model_rendering;
extern int Cmdline_no_di_mouse;
extern int Cmdline_drawelements;
extern char* Cmdline_keyboard_layout;
extern bool Cmdline_gl_finish;
extern bool Cmdline_no_geo_sdr_effects;
extern bool Cmdline_set_cpu_affinity;
#ifdef WIN32
extern bool Cmdline_alternate_registry_path;
#endif
// Developer/Testing related
extern char *Cmdline_start_mission;
@@ -162,6 +161,5 @@ extern int Cmdline_reparse_mainhall;
extern bool Cmdline_frame_profile;
extern bool Cmdline_profile_write_file;
extern bool Cmdline_no_unfocus_pause;
extern bool Cmdline_benchmark_mode;
#endif
+1 -2
View File
@@ -2257,8 +2257,7 @@ int check_control_used(int id, int key)
return 0;
}
if ((Control_config[id].key_id == key) || joy_down_count(Control_config[id].joy_id, 1) ||
((Control_config[id].joy_id >= 0) && (Control_config[id].joy_id < MOUSE_NUM_BUTTONS) && mouse_down_count(1 << Control_config[id].joy_id))) {
if ((Control_config[id].key_id == key) || joy_down_count(Control_config[id].joy_id, 1) || mouse_down_count(1 << Control_config[id].joy_id)) {
//mprintf(("Key used %d", key));
control_used(id);
return 1;
+1 -1
View File
@@ -617,7 +617,7 @@ void control_config_common_close()
{
// only need to worry control presets for now
for (auto ii = Control_config_presets.cbegin(); ii != Control_config_presets.cend(); ++ii) {
delete[] * ii;
delete * ii;
}
}
+1 -1
View File
@@ -345,7 +345,7 @@ static void OGG_video_init(theora_info *tinfo)
opengl_set_texture_target(GL_TEXTURE_2D);
opengl_tcache_get_adjusted_texture_size(g_screenWidth, g_screenHeight, &wp2, &hp2);
if(!is_minimum_GLSL_version())
if(!Use_GLSL)
use_shaders = false;
if(use_shaders) {
+11 -8
View File
@@ -563,7 +563,6 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
db->is_hull = hull_flag;
db->source_objnum = parent_objnum;
db->source_sig = source_obj->signature;
db->damage_type_idx = shipp->debris_damage_type_idx;
db->ship_info_index = shipp->ship_info_index;
db->team = shipp->team;
db->fire_timeout = 0; // if not changed, timestamp_elapsed() will return false
@@ -704,7 +703,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
// displacement fromt the center of the parent object to the center of the debris piece
vec3d world_rotvel, vel_from_rotvel;
vm_vec_unrotate ( &world_rotvel, &source_obj->phys_info.rotvel, &source_obj->orient );
vm_vec_cross ( &vel_from_rotvel, &world_rotvel, &to_center );
vm_vec_crossprod ( &vel_from_rotvel, &world_rotvel, &to_center );
vm_vec_scale ( &vel_from_rotvel, DEBRIS_ROTVEL_SCALE);
vm_vec_add (&obj->phys_info.vel, &radial_vel, &source_obj->phys_info.vel);
@@ -898,8 +897,11 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
mc.flags = MC_ONLY_SPHERE | MC_CHECK_SPHERELINE;
SCP_vector<int> submodel_vector;
polymodel *pm;
polymodel_instance *pmi;
ship_model_start(pship_obj);
if (model_collide(&mc)) {
// Set earliest hit time
@@ -913,6 +915,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
model_get_rotating_submodel_list(&submodel_vector, heavy_obj);
// Get polymodel and turn off all rotating submodels, collide against only 1 at a time.
pm = model_get(Ship_info[Ships[heavy_obj->instance].ship_info_index].model_num);
pmi = model_get_instance(Ships[heavy_obj->instance].model_instance_num);
// turn off all rotating submodels and test for collision
@@ -937,10 +940,10 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
// find the start and end positions of the sphere in submodel RF
pmi->submodel[*smv].angs = pmi->submodel[*smv].prev_angs;
world_find_model_instance_point(&p0, &light_obj->last_pos, pmi, *smv, &heavy_obj->last_orient, &heavy_obj->last_pos);
world_find_model_instance_point(&p0, &light_obj->last_pos, pm, pmi, *smv, &heavy_obj->last_orient, &heavy_obj->last_pos);
pmi->submodel[*smv].angs = copy_angles;
world_find_model_instance_point(&p1, &light_obj->pos, pmi, *smv, &heavy_obj->orient, &heavy_obj->pos);
world_find_model_instance_point(&p1, &light_obj->pos, pm, pmi, *smv, &heavy_obj->orient, &heavy_obj->pos);
mc.p0 = &p0;
mc.p1 = &p1;
@@ -954,18 +957,18 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
// set up debris_hit_info common
set_hit_struct_info(debris_hit_info, &mc, SUBMODEL_ROT_HIT);
model_instance_find_world_point(&debris_hit_info->hit_pos, &mc.hit_point, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
model_instance_find_world_point(&debris_hit_info->hit_pos, &mc.hit_point, mc.model_num, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
// set up debris_hit_info for rotating submodel
if (debris_hit_info->edge_hit == 0) {
model_instance_find_obj_dir(&debris_hit_info->collision_normal, &mc.hit_normal, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient);
model_instance_find_obj_dir(&debris_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
}
// find position in submodel RF of light object at collison
vec3d int_light_pos, diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&int_light_pos, mc.p0, &diff, mc.hit_dist);
model_instance_find_world_point(&debris_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
model_instance_find_world_point(&debris_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.model_instance_num, mc.hit_submodel, &heavy_obj->orient, &zero);
}
}
// Don't look at this submodel again
@@ -989,7 +992,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
// get collision normal if not edge hit
if (debris_hit_info->edge_hit == 0) {
model_instance_find_obj_dir(&debris_hit_info->collision_normal, &mc.hit_normal, Ships[heavy_obj->instance].model_instance_num, mc.hit_submodel, &heavy_obj->orient);
model_instance_find_obj_dir(&debris_hit_info->collision_normal, &mc.hit_normal, heavy_obj, mc.hit_submodel);
}
// find position in submodel RF of light object at collison
-1
View File
@@ -25,7 +25,6 @@ typedef struct debris {
int flags; // See DEBRIS_??? defines
int source_objnum; // What object this came from
int source_sig; // Signature of the source object
int damage_type_idx; // Damage type of this debris
int ship_info_index; // Ship info index of the ship type debris came from
int team; // Team of the ship where the debris came from
int objnum; // What object this is linked to
-11
View File
@@ -672,10 +672,6 @@ void event_editor::OnButtonNewEvent()
return;
}
// before we do anything, we must check and save off any data from the current event (e.g
// the repeat count and interval count)
save();
reset_event(m_num_events++, TVI_LAST);
}
@@ -689,11 +685,6 @@ void event_editor::OnInsert()
return;
}
// before we do anything, we must check and save off any data from the current event (e.g
// the repeat count and interval count)
save();
if(cur_event < 0 || m_num_events == 0)
{
//There are no events yet, so just create one
@@ -759,8 +750,6 @@ void event_editor::reset_event(int num, HTREEITEM after)
m_event_tree.item_index = index;
m_event_tree.add_operator("do-nothing");
update_cur_event();
m_event_tree.SelectItem(h);
// GetDlgItem(IDC_CHAIN_DELAY) -> EnableWindow(FALSE);
if (num >= MAX_MISSION_EVENTS){
+96 -94
View File
@@ -18,11 +18,13 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@@ -114,7 +116,7 @@ IDB_DATA_95 BITMAP "res\\data95.bmp"
// Toolbar
//
IDR_MAINFRAME TOOLBAR 23, 23
IDR_MAINFRAME TOOLBAR 23, 23
BEGIN
BUTTON ID_SELECT
BUTTON ID_SELECT_AND_MOVE
@@ -150,7 +152,7 @@ END
// Menu
//
IDR_MAINMENU MENU
IDR_MAINMENU MENU
BEGIN
POPUP "&File"
BEGIN
@@ -332,7 +334,7 @@ BEGIN
END
END
IDR_MENU_SHIP_POPUP MENU
IDR_MENU_SHIP_POPUP MENU
BEGIN
POPUP "Properties"
BEGIN
@@ -342,7 +344,7 @@ BEGIN
END
END
IDR_MENU_EDIT_POPUP MENU
IDR_MENU_EDIT_POPUP MENU
BEGIN
POPUP "EDIT"
BEGIN
@@ -367,7 +369,7 @@ BEGIN
END
END
IDR_MENU_CAMPAIGN MENU
IDR_MENU_CAMPAIGN MENU
BEGIN
POPUP "&File"
BEGIN
@@ -389,7 +391,7 @@ BEGIN
END
END
IDR_MENU_EDIT_SEXP_TREE MENU
IDR_MENU_EDIT_SEXP_TREE MENU
BEGIN
POPUP "Edit sexp tree"
BEGIN
@@ -439,7 +441,7 @@ BEGIN
END
END
IDR_WING_EDIT_MENU MENU
IDR_WING_EDIT_MENU MENU
BEGIN
POPUP "&Select Wing"
BEGIN
@@ -447,7 +449,7 @@ BEGIN
END
END
IDR_SHIP_EDIT_MENU MENU
IDR_SHIP_EDIT_MENU MENU
BEGIN
POPUP "&Select Ship"
BEGIN
@@ -455,7 +457,7 @@ BEGIN
END
END
IDR_PLAYER_EDIT_MENU MENU
IDR_PLAYER_EDIT_MENU MENU
BEGIN
POPUP "Select Team"
BEGIN
@@ -468,7 +470,7 @@ BEGIN
END
END
IDR_WAYPOINT_PATH_EDIT_MENU MENU
IDR_WAYPOINT_PATH_EDIT_MENU MENU
BEGIN
POPUP "&Select Waypoint Path"
BEGIN
@@ -476,7 +478,7 @@ BEGIN
END
END
IDR_ASTEROID_FIELD_MENU MENU
IDR_ASTEROID_FIELD_MENU MENU
BEGIN
POPUP "Select Field"
BEGIN
@@ -484,7 +486,7 @@ BEGIN
END
END
IDR_CPGN_VIEW_OFF MENU
IDR_CPGN_VIEW_OFF MENU
BEGIN
POPUP "Blah"
BEGIN
@@ -493,7 +495,7 @@ BEGIN
END
END
IDR_CPGN_VIEW_ON MENU
IDR_CPGN_VIEW_ON MENU
BEGIN
POPUP "Blah"
BEGIN
@@ -509,7 +511,7 @@ END
// Accelerator
//
IDR_MAINFRAME ACCELERATORS
IDR_MAINFRAME ACCELERATORS
BEGIN
"1", ID_SPEED1, VIRTKEY, NOINVERT
"1", ID_GROUP1, VIRTKEY, CONTROL, NOINVERT
@@ -600,7 +602,7 @@ BEGIN
"Z", ID_ZOOM_EXTENTS, VIRTKEY, SHIFT, NOINVERT
END
IDR_ACC_CAMPAIGN ACCELERATORS
IDR_ACC_CAMPAIGN ACCELERATORS
BEGIN
"H", ID_ERROR_CHECKER, VIRTKEY, ALT, NOINVERT
"N", ID_CPGN_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
@@ -615,13 +617,13 @@ END
// Dialog
//
IDD_ABOUTBOX DIALOG 0, 0, 284, 89
IDD_ABOUTBOX DIALOG 0, 0, 284, 89
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About FRED2"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,10,17,20,20,SS_REALSIZEIMAGE
LTEXT "FRED2_OPEN - FreeSpace Editor, Version 3.7.5 OpenGL",IDC_STATIC,39,8,184,10,SS_NOPREFIX
LTEXT "FRED2_OPEN - FreeSpace Editor, Version 3.7.3 OpenGL",IDC_STATIC,39,8,184,10,SS_NOPREFIX
LTEXT "Copyright © 1999 Volition, Inc. All Rights Reserved",IDC_STATIC,39,17,164,8
DEFPUSHBUTTON "OK",IDOK,229,7,48,14,WS_GROUP
LTEXT """Fred2 is the omega of all giant unwieldy pieces of code. Its big, its horrifying, and it just doesn't care. View it at your own risk."" - Dave Baranec",IDC_STATIC,39,62,238,20
@@ -696,7 +698,7 @@ BEGIN
GROUPBOX "Message Properties",IDC_STATIC,7,184,184,60
END
IDD_SHIP_GOALS_EDITOR DIALOG 0, 0, 412, 221
IDD_SHIP_GOALS_EDITOR DIALOG 0, 0, 412, 221
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Initial Orders"
FONT 8, "MS Sans Serif"
@@ -880,7 +882,7 @@ BEGIN
CONTROL "Mission End to Mainhall",IDC_END_TO_MAINHALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,326,190,142,10
END
IDD_PREFERENCES DIALOG 0, 0, 333, 81
IDD_PREFERENCES DIALOG 0, 0, 333, 81
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Preferences"
FONT 8, "MS Sans Serif"
@@ -1015,7 +1017,7 @@ BEGIN
LTEXT "Missile bank 4",IDC_STATIC,232,64,46,8
END
IDD_SHIP_MARKINGS DIALOG 0, 0, 252, 140
IDD_SHIP_MARKINGS DIALOG 0, 0, 252, 140
STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION
CAPTION "Ship Markings"
FONT 8, "MS Sans Serif"
@@ -1148,7 +1150,7 @@ BEGIN
PUSHBUTTON "Restrict Departure Paths",IDC_RESTRICT_DEPARTURE,160,223,121,14,0,WS_EX_STATICEDGE
END
IDD_OPERATOR_ARGUMENT_TYPES DIALOG 0, 0, 235, 50
IDD_OPERATOR_ARGUMENT_TYPES DIALOG 0, 0, 235, 50
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Argument Types"
FONT 8, "MS Sans Serif"
@@ -1197,7 +1199,7 @@ BEGIN
LTEXT "Set Amount From Variable",IDC_STATIC,179,234,93,10
END
IDD_ORIENT_EDITOR DIALOG 0, 0, 229, 119
IDD_ORIENT_EDITOR DIALOG 0, 0, 229, 119
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Object Orientation Editor"
FONT 8, "MS Sans Serif"
@@ -1419,7 +1421,7 @@ BEGIN
LTEXT "Delay After Arrival",IDC_STATIC,7,99,57,8
END
IDD_REINFORCEMENT_SELECT DIALOG 0, 0, 156, 132
IDD_REINFORCEMENT_SELECT DIALOG 0, 0, 156, 132
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Reinforcement Unit"
FONT 8, "MS Sans Serif"
@@ -1429,7 +1431,7 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,99,111,50,14
END
IDD_WAYPOINT_PATH_EDITOR DIALOG 0, 0, 145, 29
IDD_WAYPOINT_PATH_EDITOR DIALOG 0, 0, 145, 29
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Waypoint Path/Jump Node Editor"
MENU IDR_WAYPOINT_PATH_EDIT_MENU
@@ -1439,7 +1441,7 @@ BEGIN
EDITTEXT IDC_NAME,32,7,106,14,ES_AUTOHSCROLL
END
IDD_WING_CREATE DIALOG 0, 0, 119, 68
IDD_WING_CREATE DIALOG 0, 0, 119, 68
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Create Wing"
FONT 8, "MS Sans Serif"
@@ -1490,7 +1492,7 @@ BEGIN
LTEXT "Team Color Setting:",IDC_STATIC,16,308,66,8
END
IDD_ASTEROID_EDITOR DIALOG 0, 0, 376, 210
IDD_ASTEROID_EDITOR DIALOG 0, 0, 376, 210
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Debris Field Editor"
FONT 8, "MS Sans Serif"
@@ -1588,7 +1590,7 @@ BEGIN
LTEXT "Debriefing persona index",IDC_STATIC,148,176,79,8
END
IDD_TEXT_VIEW DIALOG 0, 0, 324, 285
IDD_TEXT_VIEW DIALOG 0, 0, 324, 285
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Ship TBL Data"
FONT 8, "MS Sans Serif"
@@ -1653,7 +1655,7 @@ BEGIN
CONTROL "Use Cargo Icon",IDC_USE_CARGO_ICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,233,394,65,10
END
IDD_IGNORE_ORDERS DIALOG 0, 0, 120, 217
IDD_IGNORE_ORDERS DIALOG 0, 0, 120, 217
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Ignore Orders"
FONT 8, "MS Sans Serif"
@@ -1703,7 +1705,7 @@ BEGIN
COMBOBOX IDC_FAILED_MISSION_TRACK,445,294,80,180,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
IDD_ADJUST_GRID DIALOG 0, 0, 153, 94
IDD_ADJUST_GRID DIALOG 0, 0, 153, 94
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Adjust Grid"
FONT 8, "MS Sans Serif"
@@ -1725,7 +1727,7 @@ BEGIN
LTEXT "X Level",IDC_STATIC,69,50,25,8
END
IDD_SHIELD_SYS DIALOG 0, 0, 192, 106
IDD_SHIELD_SYS DIALOG 0, 0, 192, 106
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Shield System Editor"
FONT 8, "MS Sans Serif"
@@ -1742,7 +1744,7 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,134,86,50,14
END
IDD_INITIAL_SHIPS DIALOG 0, 0, 127, 210
IDD_INITIAL_SHIPS DIALOG 0, 0, 127, 210
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Initial Ships Allowed"
FONT 8, "MS Sans Serif"
@@ -1832,15 +1834,13 @@ BEGIN
CONTROL "Laser Protect Ship",IDC_LASER_PROTECT_SHIP,"Button",BS_3STATE | WS_TABSTOP,12,110,80,8
CONTROL "Missile Protect Ship",IDC_MISSILE_PROTECT_SHIP,"Button",BS_3STATE | WS_TABSTOP,12,118,80,8
GROUPBOX "Turret Threats",IDC_STATIC,7,83,102,48
CONTROL "Does Not Move",IDC_IMMOBILE,"Button",BS_3STATE | WS_TABSTOP,7,274,66,10
CONTROL "Cloaked",IDC_CLOAKED,"Button",BS_3STATE | WS_TABSTOP,165,167,42,10
CONTROL "Scramble Messages",IDC_SCRAMBLE_MESSAGES,"Button",BS_3STATE | WS_TABSTOP,165,177,79,10
CONTROL "No Collisions",IDC_NO_COLLIDE,"Button",BS_3STATE | WS_TABSTOP,165,188,66,10
CONTROL "No Disabled Self-Destruct",IDC_NO_DISABLED_SELF_DESTRUCT,
"Button",BS_3STATE | WS_TABSTOP,165,199,114,10
END
IDD_ADD_VARIABLE DIALOG 0, 0, 422, 102
CONTROL "Does Not Move",IDC_IMMOBILE,"Button",BS_3STATE | WS_TABSTOP,7,274,66,10
CONTROL "Cloaked",IDC_CLOAKED,"Button",BS_3STATE | WS_TABSTOP,165,167,42,10
CONTROL "Scramble Messages",IDC_SCRAMBLE_MESSAGES,"Button",BS_3STATE | WS_TABSTOP,165,177,79,10
CONTROL "No Collisions",IDC_NO_COLLIDE,"Button",BS_3STATE | WS_TABSTOP,165,188,66,10
END
IDD_ADD_VARIABLE DIALOG 0, 0, 422, 102
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Add Variable"
FONT 8, "MS Sans Serif"
@@ -1860,7 +1860,7 @@ BEGIN
CONTROL "Network-Variable",IDC_TYPE_NETWORK_VARIABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,137,71,84,11
END
IDD_MODIFY_VARIABLE DIALOG 0, 0, 422, 102
IDD_MODIFY_VARIABLE DIALOG 0, 0, 422, 102
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Modify Variable"
FONT 8, "MS Sans Serif"
@@ -1882,7 +1882,7 @@ BEGIN
CONTROL "Network-Variable",IDC_TYPE_NETWORK_VARIABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,138,72,84,11
END
IDD_SPECIAL_DAMAGE DIALOG 0, 0, 234, 129
IDD_SPECIAL_DAMAGE DIALOG 0, 0, 234, 129
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Special Explosion"
FONT 8, "MS Sans Serif"
@@ -1908,7 +1908,7 @@ BEGIN
LTEXT "Duration (msecs):",IDC_STATIC,30,111,56,8
END
IDD_DUMP_STATS DIALOG 0, 0, 577, 375
IDD_DUMP_STATS DIALOG 0, 0, 577, 375
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Mission Stats"
FONT 8, "MS Sans Serif"
@@ -1918,7 +1918,7 @@ BEGIN
EDITTEXT IDC_STATS_TEXT,7,7,563,333,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | ES_NUMBER | WS_VSCROLL
END
IDD_SHIP_TEXTURES DIALOG 0, 0, 296, 56
IDD_SHIP_TEXTURES DIALOG 0, 0, 296, 56
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Ship Texture Replace"
FONT 8, "MS Sans Serif"
@@ -1928,10 +1928,10 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,239,35,50,14
LTEXT "Old texture:",IDC_LABEL1,7,7,44,9
LTEXT "New texture:",IDC_LABEL2,152,7,44,9
COMBOBOX IDC_OLD_TEXTURE_LIST,7,16,137,85,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_OLD_TEXTURE_LIST,7,16,137,85,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
IDD_SPECIAL_HITPOINTS DIALOG 0, 0, 234, 85
IDD_SPECIAL_HITPOINTS DIALOG 0, 0, 234, 85
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Special Hitpoints"
FONT 8, "MS Sans Serif"
@@ -1948,7 +1948,7 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,106,10
END
IDD_SET_GLOBAL_SHIP_FLAGS DIALOG 0, 0, 114, 79
IDD_SET_GLOBAL_SHIP_FLAGS DIALOG 0, 0, 114, 79
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Set Global Ship Flags"
FONT 8, "MS Sans Serif"
@@ -1959,7 +1959,7 @@ BEGIN
PUSHBUTTON "Global Affected-By-Gravity",IDC_AFFECTED_BY_GRAVITY,7,58,100,14
END
IDD_VOICE_MANAGER DIALOG 0, 0, 407, 218
IDD_VOICE_MANAGER DIALOG 0, 0, 407, 218
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Voice Acting Manager"
FONT 8, "MS Sans Serif"
@@ -2004,7 +2004,7 @@ BEGIN
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,166,159,100,19
END
IDD_BRIEFING_PERSONAS DIALOG 0, 0, 320, 201
IDD_BRIEFING_PERSONAS DIALOG 0, 0, 320, 201
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
@@ -2013,7 +2013,7 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,263,24,50,14
END
IDD_CUSTOM_WING_NAMES DIALOG 0, 0, 390, 54
IDD_CUSTOM_WING_NAMES DIALOG 0, 0, 390, 54
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Custom Wing Names"
FONT 8, "MS Sans Serif"
@@ -2035,7 +2035,7 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,333,24,50,14
END
IDD_RESTRICT_PATHS DIALOG 0, 0, 241, 87
IDD_RESTRICT_PATHS DIALOG 0, 0, 241, 87
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Restrict Paths"
FONT 8, "MS Sans Serif"
@@ -2046,7 +2046,7 @@ BEGIN
LTEXT "Restrict departure paths to the following:",IDC_RESTRICT_PATHS_LABEL,7,7,127,11
END
IDD_BACKGROUND_CHOOSER DIALOG 0, 0, 152, 45
IDD_BACKGROUND_CHOOSER DIALOG 0, 0, 152, 45
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Choose a background"
FONT 8, "MS Sans Serif"
@@ -2103,8 +2103,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,7,1,0
PRODUCTVERSION 3,7,1,0
FILEVERSION 3,7,1,000000
PRODUCTVERSION 3,7,1,000000
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -2121,12 +2121,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Volition Inc."
VALUE "FileDescription", "Fred 2 Open"
VALUE "FileVersion", "3.7.5.000000"
VALUE "FileVersion", "3.7.3.000000"
VALUE "InternalName", "Fred 2 Open"
VALUE "LegalCopyright", "Copyright © 1998"
VALUE "OriginalFilename", "fred2.exe"
VALUE "ProductName", "Fred 2 Open"
VALUE "ProductVersion", "3.7.5"
VALUE "ProductVersion", "3.7.3"
END
END
BLOCK "VarFileInfo"
@@ -2142,7 +2142,7 @@ END
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
GUIDELINES DESIGNINFO
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
@@ -2696,19 +2696,19 @@ IDC_CURSOR2 CURSOR "res\\cursor2.cur"
// String Table
//
STRINGTABLE
STRINGTABLE
BEGIN
IDR_MAINFRAME "FRED2_OPEN 3.7.5 - FreeSpace2 Mission Editor\nUntitled\nFRED2\nFreeSpace2 Missions (*.fs2)\n.fs2\nFreeSpace2Mission\nFreeSpace2 Mission"
IDR_MAINFRAME "FRED2_OPEN 3.7.3 - FreeSpace2 Mission Editor\nUntitled\nFRED2\nFreeSpace2 Missions (*.fs2)\n.fs2\nFreeSpace2Mission\nFreeSpace2 Mission"
END
STRINGTABLE
STRINGTABLE
BEGIN
AFX_IDS_APP_TITLE "FRED2"
AFX_IDS_IDLEMESSAGE "For Help, press F1"
AFX_IDS_HELPMODEMESSAGE "Select an object on which to get Help"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_FILE_NEW "Create a new campaign\nNew"
ID_FILE_OPEN "Open an existing campaign\nOpen"
@@ -2721,7 +2721,7 @@ BEGIN
ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
ID_APP_EXIT "Exit the campaign editor\nExit"
@@ -2732,7 +2732,7 @@ BEGIN
ID_HELP "Display help for current task or command\nHelp"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_FILE_MRU_FILE1 "Open this document"
ID_FILE_MRU_FILE2 "Open this document"
@@ -2752,18 +2752,18 @@ BEGIN
ID_FILE_MRU_FILE16 "Open this document"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_EDIT_CLEAR "Erase the selection\nErase"
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
@@ -2778,13 +2778,13 @@ BEGIN
ID_EDIT_REDO "Redo the previously undone action\nRedo"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
END
STRINGTABLE
STRINGTABLE
BEGIN
AFX_IDS_SCSIZE "Change the window size"
AFX_IDS_SCMOVE "Change the window position"
@@ -2795,24 +2795,24 @@ BEGIN
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
END
STRINGTABLE
STRINGTABLE
BEGIN
AFX_IDS_SCRESTORE "Restore the window to normal size"
AFX_IDS_SCTASKLIST "Activate Task List"
END
STRINGTABLE
STRINGTABLE
BEGIN
AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_FILE_MISSIONNOTES "Displays designer notes and mission properties\nMission Specs"
ID_SELECT "Select objects mode\nSelect (S)"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_VIEW_FIGHTERS "Show/Hide Fighter objects"
ID_VIEW_CAPITALSHIPS "Show/Hide Capital Ship objects"
@@ -2830,7 +2830,7 @@ BEGIN
ID_EDITORS_SHIPS "Open ship editor dialog window to edit ship"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_EDITORS_GOALS "Activates Mission Goal Editor\nMission Goal Editor"
ID_EDITORS_WAYPOINTS "Activates Waypoint Editor\nWaypoint Editor"
@@ -2841,7 +2841,7 @@ BEGIN
ID_PROPERTIES_ONE "This is Mike's prompt!"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_INDICATOR_EXT "EXT"
ID_INDICATOR_CAPS "CAP"
@@ -2855,7 +2855,7 @@ BEGIN
ID_INDICATOR_MODIFIED "MODIFIED"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_MISCSTUFF_SHOWSHIPSASICONS "This is the (help?) prompt!"
ID_EDIT_POPUP_SHOW_SHIP_MODELS
@@ -2864,7 +2864,7 @@ BEGIN
"Display ship names and ship types for visible ships"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_ADD_MISSION_TIME "Evaluates to elapsed time into mission in seconds"
ID_ADD_EQUALS "Evaluates to true if numbers or objects are the same"
@@ -2879,7 +2879,7 @@ BEGIN
ID_ADD_FALSE "Evaluates to a boolean value of false"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_EDIT_POPUP_SHOW_COMPASS
"Display a 3 dimentional compass in the upper right corner of window"
@@ -2893,7 +2893,7 @@ BEGIN
ID_ADD_MINUS "Evaluates to difference between first subexpression and remaining subexpressions"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_SHOW_GRID_POSITIONS "Show position on grid for all visible objects"
ID_SHOW_COORDINATES "Display the coordinates of objects/waypoints."
@@ -2908,7 +2908,7 @@ BEGIN
ID_DISSOLVE_WING "Remove selected ships from Wing(s)\nRemove from Wing"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_SELECT_AND_MOVE "Select and Move objects\nSelect and Move (M)"
ID_SELECT_AND_ROTATE "Select and Rotate objects\nSelect and Rotate (R)"
@@ -2923,7 +2923,7 @@ BEGIN
ID_FIND_DISTANCE "Find Distance between two objects\nFind Distance"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_BUTTON32944 "Constrain to YZ axis\nYZ Constraint"
ID_BUTTON32945 "Constrain to XY axis\nXY Constraint"
@@ -2938,27 +2938,27 @@ BEGIN
ID_SHOW_HORIZON "Show the horizon line"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_EDITORS_PLAYER "Edit loadout information for all teams"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_REVERT "Revert changes by reloading mission from last save\nRevert"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_ERROR_CHECKER "Checks campaign for errors"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_LOOKAT_OBJ "Rotate camera around selected object\nRotate around object (Ctrl+V)"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_EDITORS_ADJUST_GRID "Adjust the orientation and level of the grid."
ID_EDITORS_SHIELD_SYS "Editor for availability of shield system for ships."
@@ -2966,7 +2966,7 @@ BEGIN
ID_MARK_WING "Mark entire wing selected object is a member of."
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_CONTROL_OBJ "Movement keys control marked objects instead of camera."
ID_CHECKOUT "Checks out the mission from Source Safe"
@@ -2974,35 +2974,37 @@ BEGIN
ID_AA_GRIDLINES "Toggle Gridlines being drawn anti-aliased or not."
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_FORMAT_FS2_OPEN "Save missions with SCP features"
ID_FORMAT_FS2_RETAIL "Save missions compatible with FS2 retail"
ID_FORMAT_FS1 "Save missions compatible with FS1 retail"
END
STRINGTABLE
STRINGTABLE
BEGIN
ID_FORMAT_FS1_RETAIL "Save missions compatible with FS1 retail"
END
#endif // English (United States) resources
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United Kingdom) resources
// English (U.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ALT_SHIP_CLASS DIALOG 0, 0, 312, 212
IDD_ALT_SHIP_CLASS DIALOG 0, 0, 312, 212
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Alternate Ship Class Editor"
FONT 8, "MS Sans Serif"
@@ -3029,7 +3031,7 @@ END
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
GUIDELINES DESIGNINFO
BEGIN
IDD_ALT_SHIP_CLASS, DIALOG
BEGIN
@@ -3041,7 +3043,7 @@ BEGIN
END
#endif // APSTUDIO_INVOKED
#endif // English (United Kingdom) resources
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
+22 -22
View File
@@ -885,8 +885,12 @@ void render_one_model_htl(object *objp)
// build flags
if ((Show_ship_models || Show_outlines) && ((objp->type == OBJ_SHIP) || (objp->type == OBJ_START))){
g3_start_instance_matrix(&Eye_position, &Eye_matrix, 0);
j = MR_NORMAL;
if (Show_ship_models){
j = MR_NORMAL;
} else {
j = MR_NO_POLYS;
}
if(Show_dock_points){
debug_flags |= MR_DEBUG_BAY_PATHS;
@@ -911,21 +915,17 @@ void render_one_model_htl(object *objp)
model_render_params render_info;
if (Fred_outline) {
render_info.set_color(Fred_outline >> 16, (Fred_outline >> 8) & 0xff, Fred_outline & 0xff);
j |= MR_SHOW_OUTLINE_HTL | MR_NO_LIGHTING | MR_NO_POLYS | MR_NO_TEXTURING;
}
render_info.set_flags(j);
render_info.set_debug_flags(debug_flags);
render_info.set_replacement_textures(Ships[z].ship_replacement_textures);
if (Fred_outline) {
render_info.set_color(Fred_outline >> 16, (Fred_outline >> 8) & 0xff, Fred_outline & 0xff);
render_info.set_flags(j | MR_SHOW_OUTLINE_HTL | MR_NO_LIGHTING | MR_NO_POLYS | MR_NO_TEXTURING);
model_render_immediate(&render_info, Ship_info[Ships[z].ship_info_index].model_num, &objp->orient, &objp->pos);
}
g3_done_instance(0);
if ( Show_ship_models ) {
render_info.set_flags(j);
model_render_immediate(&render_info, Ship_info[Ships[z].ship_info_index].model_num, &objp->orient, &objp->pos);
}
model_render_immediate(&render_info, Ship_info[Ships[z].ship_info_index].model_num, &objp->orient, &objp->pos);
} else {
int r = 0, g = 0, b = 0;
@@ -1140,7 +1140,7 @@ void draw_orient_sphere(object *obj, int r, int g, int b)
if ((obj->type != OBJ_WAYPOINT) && (obj->type != OBJ_POINT))
{
flag = (vm_vec_dot(&eye_orient.vec.fvec, &obj->orient.vec.fvec) < 0.0f);
flag = (vm_vec_dotprod(&eye_orient.vec.fvec, &obj->orient.vec.fvec) < 0.0f);
v1 = v2 = obj->pos;
vm_vec_scale_add2(&v1, &obj->orient.vec.fvec, size);
vm_vec_scale_add2(&v2, &obj->orient.vec.fvec, size * 1.5f);
@@ -1176,7 +1176,7 @@ void draw_orient_sphere2(int col, object *obj, int r, int g, int b)
if ((obj->type != OBJ_WAYPOINT) && (obj->type != OBJ_POINT))
{
flag = (vm_vec_dot(&eye_orient.vec.fvec, &obj->orient.vec.fvec) < 0.0f);
flag = (vm_vec_dotprod(&eye_orient.vec.fvec, &obj->orient.vec.fvec) < 0.0f);
v1 = v2 = obj->pos;
vm_vec_scale_add2(&v1, &obj->orient.vec.fvec, size);
@@ -1373,11 +1373,11 @@ void process_controls(vec3d *pos, matrix *orient, float frametime, int key, int
vm_angles_2_matrix(&rotmat, &rotangs);
if (rotangs.h && Universal_heading)
vm_transpose(orient);
vm_transpose_matrix(orient);
vm_matrix_x_matrix(&newmat, orient, &rotmat);
*orient = newmat;
if (rotangs.h && Universal_heading)
vm_transpose(orient);
vm_transpose_matrix(orient);
}
}
@@ -1659,7 +1659,7 @@ void game_do_frame()
leader = &Objects[cur_object_index];
leader_old_pos = leader->pos; // save original position
leader_orient = leader->orient; // save original orientation
vm_copy_transpose(&leader_transpose, &leader_orient);
vm_copy_transpose_matrix(&leader_transpose, &leader_orient);
process_controls(&leader->pos, &leader->orient, f2fl(Frametime), key);
vm_vec_sub(&delta_pos, &leader->pos, &leader_old_pos); // get position change
@@ -1676,7 +1676,7 @@ void game_do_frame()
// change rotation matrix to rotate in opposite direction. This rotation
// matrix is what the leader ship has rotated by.
vm_copy_transpose(&rot_trans, &view_physics.last_rotmat);
vm_copy_transpose_matrix(&rot_trans, &view_physics.last_rotmat);
// get point relative to our point of rotation (make POR the origin). Since
// only the leader has been moved yet, and not the objects, we have to use
@@ -2027,7 +2027,7 @@ void render_compass(void)
v.xyz.x = 1.0f;
v.xyz.y = v.xyz.z = 0.0f;
if (vm_vec_dot(&eye, &v) < 0.0f)
if (vm_vec_dotprod(&eye, &v) < 0.0f)
gr_set_color(159, 20, 20);
else
gr_set_color(255, 32, 32);
@@ -2035,7 +2035,7 @@ void render_compass(void)
v.xyz.y = 1.0f;
v.xyz.x = v.xyz.z = 0.0f;
if (vm_vec_dot(&eye, &v) < 0.0f)
if (vm_vec_dotprod(&eye, &v) < 0.0f)
gr_set_color(20, 159, 20);
else
gr_set_color(32, 255, 32);
@@ -2043,7 +2043,7 @@ void render_compass(void)
v.xyz.z = 1.0f;
v.xyz.x = v.xyz.y = 0.0f;
if (vm_vec_dot(&eye, &v) < 0.0f)
if (vm_vec_dotprod(&eye, &v) < 0.0f)
gr_set_color(20, 20, 159);
else
gr_set_color(32, 32, 255);
+1 -1
View File
@@ -230,7 +230,7 @@ void set_time_compression(float multiplier, float change_time){}
fix game_get_overall_frametime() { return 0; }
//WMC
void game_level_init(){}
void game_level_init(int seed){}
void game_post_level_init(){}
camid game_render_frame_setup(){return camid();}
void game_render_frame(camid cid){}
+2 -2
View File
@@ -773,7 +773,7 @@ int drag_rotate_objects()
leader = &Objects[cur_object_index];
leader_orient = leader->orient; // save original orientation
vm_copy_transpose(&leader_transpose, &leader_orient);
vm_copy_transpose_matrix(&leader_transpose, &leader_orient);
vm_angles_2_matrix(&rotmat, &a);
vm_matrix_x_matrix(&newmat, &leader->orient, &rotmat);
@@ -789,7 +789,7 @@ int drag_rotate_objects()
// change rotation matrix to rotate in opposite direction. This rotation
// matrix is what the leader ship has rotated by.
vm_copy_transpose(&rot_trans, &rotmat);
vm_copy_transpose_matrix(&rot_trans, &rotmat);
// get point relative to our point of rotation (make POR the origin).
vm_vec_sub(&tmpv1, &objp->pos, &leader->pos);
-2
View File
@@ -135,7 +135,6 @@ int query_ship_name_duplicate(int ship);
char *reg_read_string( char *section, char *name, char *default_value );
extern int Nmodel_num;
extern int Nmodel_instance_num;
extern matrix Nmodel_orient;
extern int Nmodel_bitmap;
@@ -956,7 +955,6 @@ void clear_mission()
Nmodel_flags = DEFAULT_NMODEL_FLAGS;
Nmodel_num = -1;
Nmodel_instance_num = -1;
vm_set_identity(&Nmodel_orient);
Nmodel_bitmap = -1;
-2
View File
@@ -1724,8 +1724,6 @@ int CFred_mission_save::save_objects()
fout(" \"scramble-messages\"");
if (!(objp->flags & OF_COLLIDES))
fout(" \"no-collide\"");
if (shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT)
fout(" \"no-disabled-self-destruct\"");
fout(" )");
}
// -----------------------------------------------------------
-1
View File
@@ -1180,7 +1180,6 @@
#define IDC_MISSION_LOG_1ST_TRIGGER 1641
#define IDC_MISSION_LOG_LAST_TRIGGER 1642
#define IDC_NO_COLLIDE 1643
#define IDC_NO_DISABLED_SELF_DESTRUCT 1644
#define ID_FILE_MISSIONNOTES 32771
#define ID_DUPLICATE 32774
#define ID_VIEW_ROTATE 32775
+18 -48
View File
@@ -74,10 +74,9 @@ void ship_flags_dlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_HIDE_SHIP_NAME, m_hide_ship_name);
DDX_Control(pDX, IDC_DISABLE_ETS, m_disable_ets);
DDX_Control(pDX, IDC_CLOAKED, m_cloaked);
DDX_Control(pDX, IDC_NO_COLLIDE, m_no_collide);
DDX_Control(pDX, IDC_SET_CLASS_DYNAMICALLY, m_set_class_dynamically);
DDX_Control(pDX, IDC_SCRAMBLE_MESSAGES, m_scramble_messages);
DDX_Control(pDX, IDC_NO_COLLIDE, m_no_collide);
DDX_Control(pDX, IDC_NO_DISABLED_SELF_DESTRUCT, m_no_disabled_self_destruct);
//}}AFX_DATA_MAP
if (pDX->m_bSaveAndValidate) { // get dialog control values
@@ -143,7 +142,6 @@ BEGIN_MESSAGE_MAP(ship_flags_dlg, CDialog)
ON_BN_CLICKED(IDC_CLOAKED, OnCloaked)
ON_BN_CLICKED(IDC_SCRAMBLE_MESSAGES, OnScrambleMessages)
ON_BN_CLICKED(IDC_NO_COLLIDE, OnNoCollide)
ON_BN_CLICKED(IDC_NO_DISABLED_SELF_DESTRUCT, OnNoDisabledSelfDestruct)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -164,7 +162,7 @@ BOOL ship_flags_dlg::OnInitDialog()
int hidden_from_sensors = 0, primitive_sensors = 0, no_subspace_drive = 0, affected_by_gravity = 0;
int toggle_subsystem_scanning = 0, scannable = 0, kamikaze = 0, no_dynamic = 0, red_alert_carry = 0;
int special_warpin = 0, disable_messages = 0, guardian = 0, vaporize = 0, stealth = 0, friendly_stealth_invisible = 0;
int no_death_scream = 0, always_death_scream = 0, scramble_messages = 0, no_disabled_self_destruct = 0;
int no_death_scream = 0, always_death_scream = 0, scramble_messages = 0;
int nav_carry = 0, nav_needslink = 0, hide_ship_name = 0, set_class_dynamically = 0, no_ets = 0, cloaked = 0, no_collide = 0;
object *objp;
@@ -215,7 +213,6 @@ BOOL ship_flags_dlg::OnInitDialog()
cloaked = (shipp->flags2 & SF2_CLOAKED) ? 1 : 0;
scramble_messages = (shipp->flags2 & SF2_SCRAMBLE_MESSAGES) ? 1 : 0;
no_collide = (objp->flags & OF_COLLIDES) ? 0 : 1;
no_disabled_self_destruct = (shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT) ? 1 : 0;
destroy_before_mission = (shipp->flags & SF_KILL_BEFORE_MISSION) ? 1 : 0;
m_destroy_value.init(shipp->final_death_time);
@@ -277,7 +274,6 @@ BOOL ship_flags_dlg::OnInitDialog()
cloaked = tristate_set(shipp->flags2 & SF2_CLOAKED, cloaked);
scramble_messages = tristate_set(shipp->flags2 & SF2_SCRAMBLE_MESSAGES, scramble_messages);
no_collide = tristate_set(!(objp->flags & OF_COLLIDES), no_collide);
no_disabled_self_destruct = tristate_set(shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT, no_disabled_self_destruct);
// check the final death time and set the internal variable according to whether or not
// the final_death_time is set. Also, the value in the edit box must be set if all the
@@ -353,7 +349,6 @@ BOOL ship_flags_dlg::OnInitDialog()
m_cloaked.SetCheck(cloaked);
m_scramble_messages.SetCheck(scramble_messages);
m_no_collide.SetCheck(no_collide);
m_no_disabled_self_destruct.SetCheck(no_disabled_self_destruct);
m_kdamage.setup(IDC_KDAMAGE, this);
m_destroy_value.setup(IDC_DESTROY_VALUE, this);
@@ -971,6 +966,22 @@ void ship_flags_dlg::update_ship(int shipnum)
break;
}
switch (m_no_collide.GetCheck()) {
case 1:
if ( objp->flags & OF_COLLIDES )
set_modified();
objp->flags &= ~OF_COLLIDES;
break;
case 0:
if (!(objp->flags & OF_COLLIDES))
set_modified();
objp->flags |= OF_COLLIDES;
break;
}
switch (m_guardian.GetCheck()) {
case 1:
if ( !(shipp->ship_guardian_threshold) )
@@ -1051,38 +1062,6 @@ void ship_flags_dlg::update_ship(int shipnum)
break;
}
switch (m_no_collide.GetCheck()) {
case 1:
if (objp->flags & OF_COLLIDES)
set_modified();
objp->flags &= ~OF_COLLIDES;
break;
case 0:
if (!(objp->flags & OF_COLLIDES))
set_modified();
objp->flags |= OF_COLLIDES;
break;
}
switch (m_no_disabled_self_destruct.GetCheck()) {
case 1:
if (!(shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT))
set_modified();
shipp->flags2 |= SF2_NO_DISABLED_SELF_DESTRUCT;
break;
case 0:
if (shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT)
set_modified();
shipp->flags2 &= ~SF2_NO_DISABLED_SELF_DESTRUCT;
break;
}
shipp->respawn_priority = 0;
if(The_mission.game_type & MISSION_TYPE_MULTI) {
@@ -1461,12 +1440,3 @@ void ship_flags_dlg::OnNoCollide()
m_no_collide.SetCheck(1);
}
}
void ship_flags_dlg::OnNoDisabledSelfDestruct()
{
if (m_no_disabled_self_destruct.GetCheck() == 1) {
m_no_disabled_self_destruct.SetCheck(0);
} else {
m_no_disabled_self_destruct.SetCheck(1);
}
}
+1 -3
View File
@@ -65,10 +65,9 @@ public:
CButton m_hide_ship_name;
CButton m_disable_ets;
CButton m_cloaked;
CButton m_no_collide;
CButton m_set_class_dynamically;
CButton m_scramble_messages;
CButton m_no_collide;
CButton m_no_disabled_self_destruct;
CSpinButtonCtrl m_destroy_spin;
numeric_edit_control m_kdamage;
@@ -129,7 +128,6 @@ protected:
afx_msg void OnCloaked();
afx_msg void OnScrambleMessages();
afx_msg void OnNoCollide();
afx_msg void OnNoDisabledSelfDestruct();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
+11 -10
View File
@@ -405,7 +405,7 @@ void wing_editor::initialize_data_safe(int full_update)
for (i=0; i<Wings[cur_wing].wave_count; i++)
ptr->AddString(Ships[Wings[cur_wing].ship_index[i]].ship_name);
m_threshold_spin.SetRange(0, static_cast<short>(calc_max_wave_treshold()));
m_threshold_spin.SetRange(0, (short) Wings[cur_wing].wave_count - 1);
for (i=0; i<Num_reinforcements; i++)
if (!stricmp(Reinforcements[i].name, Wings[cur_wing].name))
break;
@@ -754,8 +754,16 @@ void wing_editor::update_data_safe()
if (cur_wing < 0)
return;
if (m_threshold > calc_max_wave_treshold()) {
m_threshold = calc_max_wave_treshold();
if (m_threshold >= Wings[cur_wing].wave_count) {
m_threshold = Wings[cur_wing].wave_count - 1;
if (!bypass_errors) {
sprintf(buf, "Wave threshold is set too high. Value has been lowered to %d", (int) m_threshold);
MessageBox(buf);
}
}
if (m_threshold + Wings[cur_wing].wave_count > MAX_SHIPS_PER_WING) {
m_threshold = MAX_SHIPS_PER_WING - Wings[cur_wing].wave_count;
if (!bypass_errors) {
sprintf(buf, "Wave threshold is set too high. Value has been lowered to %d", (int) m_threshold);
MessageBox(buf);
@@ -1351,11 +1359,4 @@ void wing_editor::OnRestrictDeparture()
dlg.m_path_mask = &Wings[cur_wing].departure_path_mask;
dlg.DoModal();
}
int wing_editor::calc_max_wave_treshold()
{
const int treshold1 = Wings[cur_wing].wave_count - 1; // At least 1 ship must have died before allowing respawn
const int treshold2 = MAX_SHIPS_PER_WING - Wings[cur_wing].wave_count; // Maximum MAX_SHIPS_PER_WING ships can be alive at any given time
return min(treshold1, treshold2);
}
-3
View File
@@ -106,7 +106,4 @@ protected:
afx_msg void OnRestrictDeparture();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Aux functions
int calc_max_wave_treshold();
};
+125 -18
View File
@@ -311,6 +311,8 @@ int last_single_step=0;
int game_zbuffer = 1;
static int Game_paused;
int Game_level_seed;
#define EXPIRE_BAD_CHECKSUM 1
#define EXPIRE_BAD_TIME 2
@@ -947,18 +949,28 @@ uint load_post_level_init;
*
* @return 0 on failure, 1 on success
*/
void game_level_init()
void game_level_init(int seed)
{
game_busy( NOX("** starting game_level_init() **") );
load_gl_init = (uint) time(NULL);
// seed the random number generator
if ( seed == -1 ) {
// if no seed was passed, seed the generator either from the time value, or from the
// netgame security flags -- ensures that all players in multiplayer game will have the
// same randon number sequence (with static rand functions)
if ( Game_mode & GM_NORMAL ) {
Game_level_seed = (int) time(NULL);
} else {
Game_level_seed = Netgame.security;
}
} else {
Assert( !(Game_mode & GM_MULTIPLAYER) );
Game_level_seed = seed;
}
srand( Game_level_seed );
// seed the random number generator in multiplayer
if ( Game_mode & GM_MULTIPLAYER ) {
// seed the generator from the netgame security flags -- ensures that all players in
// multiplayer will have the same random number sequence (with static rand functions)
srand( Netgame.security );
// semirand function needs to get re-initted every time in multiplayer
// semirand function needs to get re-initted every time in multiplayer
if ( Game_mode & GM_MULTIPLAYER ){
init_semirand();
}
@@ -1604,6 +1616,8 @@ DCF(show_cpu,"Toggles showing cpu usage")
#endif
int Game_init_seed;
DCF(use_joy_mouse,"Makes joystick move mouse cursor")
{
bool process = true;
@@ -1740,8 +1754,8 @@ void game_init()
// Moved from rand32, if we're gonna break, break immediately.
Assert(RAND_MAX == 0x7fff || RAND_MAX >= 0x7ffffffd);
// seed the random number generator
int game_init_seed = (int) time(NULL);
srand( game_init_seed );
Game_init_seed = (int) time(NULL);
srand( Game_init_seed );
Framerate_delay = 0;
@@ -3883,6 +3897,97 @@ void john_debug_stuff(vec3d *eye_pos, matrix *eye_orient)
}
#endif
// following function for dumping frames for purposes of building trailers.
#ifndef NDEBUG
// function to toggle state of dumping every frame into PCX when playing the game
DCF(dump_frames, "Toggles On/off frame dumping at 15 hz")
{
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 15;
Debug_dump_trigger = 0;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 15 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
}
DCF(dump_frames_trigger, "Starts/stop frame dumping at 15 hz")
{
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 15;
Debug_dump_trigger = 1;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 15 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
}
DCF(dump_frames30, "Starts/stop frame dumping at 30 hz")
{
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 30;
Debug_dump_trigger = 0;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 30 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
}
DCF(dump_frames30_trigger, "Starts/stop frame dumping at 30 hz")
{
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 30;
Debug_dump_trigger = 1;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Triggered frame dumping at 30 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Triggered frame dumping is now OFF\n" );
}
}
void game_maybe_dump_frame()
{
if ( !Debug_dump_frames ){
return;
}
if( Debug_dump_trigger && !keyd_pressed[KEY_Q] ){
return;
}
game_stop_time();
gr_dump_frame();
Debug_dump_frame_num++;
game_start_time();
}
#endif
extern int Player_dead_state;
// Flip the page and time how long it took.
@@ -4343,6 +4448,7 @@ void game_frame(bool paused)
}
#endif
// start timing frame
timing_frame_start();
profile_begin("Main Frame");
DEBUG_GET_TIME( total_time1 )
@@ -4507,7 +4613,11 @@ void game_frame(bool paused)
// maybe render and process the dead popup
game_maybe_do_dead_popup(flFrametime);
// start timing frame
timing_frame_stop();
// timing_display(30, 10);
// If a regular popup is active, don't flip (popup code flips)
if( !popup_running_state() ){
DEBUG_GET_TIME( flip_time1 )
@@ -4515,6 +4625,9 @@ void game_frame(bool paused)
DEBUG_GET_TIME( flip_time2 )
}
#ifndef NDEBUG
game_maybe_dump_frame(); // used to dump pcx files for building trailers
#endif
} else {
game_show_standalone_framerate();
}
@@ -4758,9 +4871,7 @@ void game_set_frametime(int state)
Last_frame_timestamp = timestamp();
flFrametime = f2fl(Frametime);
auto frametime_ms = f2i(fixmul(Frametime, F1_0 * TIMESTAMP_FREQUENCY));
timestamp_inc(frametime_ms);
timestamp_inc(flFrametime);
// wrap overall frametime if needed
if ( FrametimeOverall > (INT_MAX - F1_0) )
@@ -5653,10 +5764,6 @@ void game_leave_state( int old_state, int new_state )
snd_aav_init();
freespace_stop_mission();
if (Cmdline_benchmark_mode) {
gameseq_post_event( GS_EVENT_QUIT_GAME );
}
}
break;
+1 -1
View File
@@ -219,7 +219,7 @@ void game_unpause();
//WMC - Stuff for scripting, these make the game go
extern camid Main_camera;
extern void game_level_init();
extern void game_level_init(int seed = -1);
extern void game_post_level_init();
extern camid game_render_frame_setup();
extern void game_render_frame(camid cid);
+4 -4
View File
@@ -336,8 +336,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,7,5,000000
PRODUCTVERSION 3,7,5,000000
FILEVERSION 3,7,3,000000
PRODUCTVERSION 3,7,3,000000
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -354,12 +354,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Volition Inc."
VALUE "FileDescription", "FreeSpace 2 Open"
VALUE "FileVersion", "3.7.5.000000"
VALUE "FileVersion", "3.7.3.000000"
VALUE "InternalName", "FreeSpace 2 Open"
VALUE "LegalCopyright", "Copyright © 1998"
VALUE "OriginalFilename", "fs2.exe"
VALUE "ProductName", "FreeSpace 2 Open"
VALUE "ProductVersion", "3.7.5"
VALUE "ProductVersion", "3.7.3"
END
END
BLOCK "VarFileInfo"
+20 -20
View File
@@ -14,8 +14,8 @@
//Struct used to hold data about file defaults
typedef struct def_file
{
const char* filename;
const char *contents;
char* filename;
char *contents;
} def_file;
//:PART 1:
@@ -100,7 +100,7 @@ def_file Default_files[] =
static int Num_default_files = sizeof(Default_files) / sizeof(def_file);
//**********
const char *defaults_get_file(const char *filename)
char *defaults_get_file(char *filename)
{
for(int i = 0; i < Num_default_files; i++)
{
@@ -1448,7 +1448,7 @@ char* Default_main_vertex_shader =
" #endif\n"
" #ifdef FLAG_ENV_MAP\n"
" // Environment mapping reflection vector.\n"
" envReflect = reflect(normalize(position.xyz), normal);\n"
" envReflect = reflect(position.xyz, normal);\n"
" envReflect = vec3(envMatrix * vec4(envReflect, 0.0));\n"
" envReflect = normalize(envReflect);\n"
" #endif\n"
@@ -1467,7 +1467,7 @@ char* Default_main_vertex_shader =
" gl_ClipVertex = (gl_ModelViewMatrix * orient * vertex);\n"
"}";
char *Default_main_fragment_shader =
char *Default_main_fragment_shader =
"#extension GL_EXT_texture_array : enable\n"
"#ifdef FLAG_LIGHT\n"
"uniform int n_lights;\n"
@@ -1510,7 +1510,6 @@ char *Default_main_fragment_shader =
"#ifdef FLAG_TEAMCOLOR\n"
"uniform vec3 base_color;\n"
"uniform vec3 stripe_color;\n"
"uniform bool team_glow_enabled;\n"
"vec2 teamMask = vec2(0.0, 0.0);\n"
"#endif\n"
"#ifdef FLAG_MISC_MAP\n"
@@ -1536,7 +1535,7 @@ char *Default_main_fragment_shader =
"varying vec4 position;\n"
"varying vec3 lNormal;\n"
"\n"
"#if __VERSION__ == 120\n"
"#if SHADER_MODEL == 2\n"
" #define MAX_LIGHTS 2\n"
"#else\n"
" #define MAX_LIGHTS 8\n"
@@ -1708,8 +1707,8 @@ char *Default_main_fragment_shader =
"\n"
"#ifdef FLAG_MISC_MAP\n"
" #ifdef FLAG_TEAMCOLOR\n"
" vec4 teamMask = vec4(0.0, 0.0, 0.0, 0.0);\n"
" teamMask = texture2D(sMiscmap, texCoord);\n"
" vec2 teamMask = vec2(0.0, 0.0);\n"
" teamMask = texture2D(sMiscmap, texCoord).rg;\n"
" vec3 base = base_color - vec3(0.5);\n"
" vec3 stripe = stripe_color - vec3(0.5);\n"
" baseColor.rgb += (base * teamMask.x) + (stripe * teamMask.y);\n"
@@ -1727,7 +1726,7 @@ char *Default_main_fragment_shader =
" float dist;\n"
" #pragma optionNV unroll all\n"
" for (int i = 0; i < MAX_LIGHTS; ++i) {\n"
" #if __VERSION__ > 120\n"
" #if SHADER_MODEL > 2\n"
" if (i > n_lights)\n"
" break;\n"
" #endif\n"
@@ -1737,7 +1736,7 @@ char *Default_main_fragment_shader =
" lightDir = normalize(gl_LightSource[i].position.xyz);\n"
" float attenuation = 1.0;\n"
" #ifndef FLAG_DEFERRED\n"
" #if __VERSION__ > 120\n"
" #if SHADER_MODEL > 2\n"
" if (gl_LightSource[i].position.w == 1.0) {\n"
" #else\n"
" if (gl_LightSource[i].position.w == 1.0 && i != 0) {\n"
@@ -1745,7 +1744,7 @@ char *Default_main_fragment_shader =
" // Positional light source\n"
" dist = distance(gl_LightSource[i].position.xyz, position.xyz);\n"
" lightDir = (gl_LightSource[i].position.xyz - position.xyz);\n"
" #if __VERSION__ > 120\n"
" #if SHADER_MODEL > 2\n"
" if (gl_LightSource[i].spotCutoff < 91.0) { // Tube light\n"
" float beamlength = length(gl_LightSource[i].spotDirection);\n"
" vec3 beamDir = normalize(gl_LightSource[i].spotDirection);\n"
@@ -1790,14 +1789,7 @@ char *Default_main_fragment_shader =
"#endif\n"
"\n"
"#ifdef FLAG_GLOW_MAP\n"
" vec3 glowColor = texture2D(sGlowmap, texCoord).rgb;\n"
" #ifdef FLAG_MISC_MAP\n"
" #ifdef FLAG_TEAMCOLOR\n"
" float glowColorLuminance = dot(glowColor, vec3(0.299, 0.587, 0.114));\n"
" glowColor = team_glow_enabled ? mix((base * teamMask.b) + (stripe * teamMask.a), glowColor, clamp(glowColorLuminance - teamMask.b - teamMask.a, 0.0, 1.0)) : glowColor;\n"
" #endif\n"
" #endif\n"
" baseColor.rgb += glowColor * GLOW_MAP_INTENSITY;\n"
" baseColor.rgb += texture2D(sGlowmap, texCoord).rgb * GLOW_MAP_INTENSITY;\n"
"#endif\n"
"\n"
"#ifdef FLAG_FOG\n"
@@ -1904,6 +1896,14 @@ char* Default_fxaa_fragment_shader =
"#extension GL_EXT_gpu_shader4 : enable\n"
"#define FXAA_EARLY_EXIT 1\n"
"#define FXAA_DISCARD 1\n"
"#if SHADER_MODEL == 2\n"
" #define FXAA_GLSL_120 1\n"
" #define FXAA_GLSL_130 0\n"
"#endif\n"
"#if SHADER_MODEL > 2\n"
" #define FXAA_GLSL_120 0\n"
" #define FXAA_GLSL_130 1\n"
"#endif\n"
"#ifndef FXAA_FAST_PIXEL_OFFSET\n"
" #ifdef GL_EXT_gpu_shader4\n"
" #define FXAA_FAST_PIXEL_OFFSET 1\n"
+1 -1
View File
@@ -12,7 +12,7 @@
#define __DEF_FILES_H_
//Used to retrieve pointer to file data from def_files.cpp
const char *defaults_get_file(const char *filename);
char *defaults_get_file(char *filename);
//WMC -
//There are three parts to adding a file
+2
View File
@@ -10,6 +10,8 @@
#include "globalincs/pstypes.h"
#include "globalincs/version.h"
#include <sstream>
namespace version
{
bool check_at_least(int major, int minor, int build, int revision)
+1 -1
View File
@@ -36,7 +36,7 @@
#define FS_VERSION_MAJOR 3 // major version
#define FS_VERSION_MINOR 7 // increase by 1 for minor revs
#define FS_VERSION_BUILD 5 // bugfix release
#define FS_VERSION_BUILD 3 // bugfix release
#define FS_VERSION_REVIS 000000 // SVN revision
//#define FS_VERSION_IDENT NOX("custom") // special build release identifier, must be a string (don't define unless it's supposed to be used!!)
-1
View File
@@ -7,7 +7,6 @@
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <queue>
#include <deque>
#include <unordered_map>
+8 -7
View File
@@ -849,6 +849,7 @@ static bool gr_init_sub(int mode, int width, int height, int depth, float center
gr_screen.bits_per_pixel = depth;
gr_screen.bytes_per_pixel= depth / 8;
gr_screen.rendering_to_texture = -1;
gr_screen.recording_state_block = false;
gr_screen.envmap_render_target = -1;
gr_screen.mode = mode;
gr_screen.res = res;
@@ -1739,7 +1740,7 @@ void poly_list::allocate(int _verts)
tsb = (tsb_t*)vm_malloc(sizeof(tsb_t) * _verts);
}
if ( GLSL_version >= 130 ) {
if ( Use_GLSL >= 3 ) {
submodels = (int*)vm_malloc(sizeof(int) * _verts);
}
@@ -1851,15 +1852,15 @@ void poly_list::calculate_tangent()
vm_vec_normalize_safe(t2);
// compute handedness (for all 3 verts)
vm_vec_cross(&cross, &norm[i], &tangent);
vm_vec_crossprod(&cross, &norm[i], &tangent);
scale = vm_vec_dot(&cross, &binormal);
tsb[i].scaler = (scale < 0.0f) ? -1.0f : 1.0f;
vm_vec_cross(&cross, &norm[i+1], &tangent);
vm_vec_crossprod(&cross, &norm[i+1], &tangent);
scale = vm_vec_dot(&cross, &binormal);
tsb[i+1].scaler = (scale < 0.0f) ? -1.0f : 1.0f;
vm_vec_cross(&cross, &norm[i+2], &tangent);
vm_vec_crossprod(&cross, &norm[i+2], &tangent);
scale = vm_vec_dot(&cross, &binormal);
tsb[i+2].scaler = (scale < 0.0f) ? -1.0f : 1.0f;
}
@@ -1921,7 +1922,7 @@ void poly_list::make_index_buffer(SCP_vector<int> &vertex_list)
buffer_list_internal.tsb[z] = tsb[j];
}
if ( GLSL_version >= 130 ) {
if ( Use_GLSL >= 3 ) {
buffer_list_internal.submodels[z] = submodels[j];
}
@@ -1951,7 +1952,7 @@ poly_list& poly_list::operator = (poly_list &other_list)
memcpy(tsb, other_list.tsb, sizeof(tsb_t) * other_list.n_verts);
}
if ( GLSL_version >= 130 ) {
if ( Use_GLSL >= 3 ) {
memcpy(submodels, other_list.submodels, sizeof(int) * other_list.n_verts);
}
@@ -2146,7 +2147,7 @@ uint gr_determine_model_shader_flags(
) {
uint shader_flags = 0;
if ( GLSL_version >= 120 ) {
if ( Use_GLSL > 1 ) {
shader_flags |= SDR_FLAG_MODEL_CLIP;
}
+50 -4
View File
@@ -405,12 +405,23 @@ typedef struct screen {
int envmap_render_target;
bool recording_state_block;
int current_state_block;
void (*gf_start_state_block)();
int (*gf_end_state_block)();
void (*gf_set_state_block)(int);
//switch onscreen, offscreen
void (*gf_flip)();
// Sets the current palette
void (*gf_set_palette)(const ubyte *new_pal, int restrict_alphacolor);
// Fade the screen in/out
void (*gf_fade_in)(int instantaneous);
void (*gf_fade_out)(int instantaneous);
// Flash the screen
void (*gf_flash)( int r, int g, int b );
void (*gf_flash_alpha)(int r, int g, int b, int a);
@@ -500,7 +511,17 @@ typedef struct screen {
// Frees up a saved screen.
void (*gf_free_screen)(int id);
// CODE FOR DUMPING FRAMES TO A FILE
// Begin frame dumping
void (*gf_dump_frame_start)( int first_frame_number, int nframes_between_dumps );
// Dump the current frame to file
void (*gf_dump_frame)();
// Dump the current frame to file
void (*gf_dump_frame_stop)();
// Sets the gamma
void (*gf_set_gamma)(float gamma);
@@ -536,9 +557,10 @@ typedef struct screen {
// Here be the bitmap functions
void (*gf_bm_free_data)(int n, bool release);
void (*gf_bm_create)(int n);
int(*gf_bm_load)(BM_TYPE type, int n, const char *filename, CFILE *img_cfp, int *w, int *h, int *bpp, BM_TYPE *c_type, int *mm_lvl, int *size);
void (*gf_bm_init)(int n);
void (*gf_bm_page_in_start)();
bool (*gf_bm_data)(int n, bitmap* bm);
int (*gf_bm_lock)(const char *filename, int handle, int bitmapnum, ubyte bpp, ubyte flags, bool nodebug);
int (*gf_bm_make_render_target)(int n, int *width, int *height, ubyte *bpp, int *mm_lvl, int flags );
int (*gf_bm_set_render_target)(int n, int face);
@@ -562,7 +584,11 @@ typedef struct screen {
int (*gf_create_stream_buffer)();
void (*gf_render_stream_buffer)(int buffer_handle, int offset, int n_verts, int flags);
int (*gf_make_flat_buffer)(poly_list*);
int (*gf_make_line_buffer)(line_list*);
//the projection matrix; fov, aspect ratio, near, far
void (*gf_set_proj_matrix)(float, float, float, float);
void (*gf_end_proj_matrix)();
@@ -609,6 +635,7 @@ typedef struct screen {
void (*gf_end_clip_plane)();
void (*gf_zbias)(int zbias);
void (*gf_setup_background_fog)(bool);
void (*gf_set_fill_mode)(int);
void (*gf_set_texture_panning)(float u, float v, bool enable);
@@ -810,6 +837,8 @@ __inline void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode = GR_R
(*gr_screen.gf_gradient)(x1, y1, x2, y2, resize_mode);
}
#define gr_fade_in GR_CALL(gr_screen.gf_fade_in)
#define gr_fade_out GR_CALL(gr_screen.gf_fade_out)
#define gr_flash GR_CALL(gr_screen.gf_flash)
#define gr_flash_alpha GR_CALL(gr_screen.gf_flash_alpha)
@@ -826,6 +855,10 @@ __inline void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode = GR_R
#define gr_restore_screen GR_CALL(gr_screen.gf_restore_screen)
#define gr_free_screen GR_CALL(gr_screen.gf_free_screen)
#define gr_dump_frame_start GR_CALL(gr_screen.gf_dump_frame_start)
#define gr_dump_frame_stop GR_CALL(gr_screen.gf_dump_frame_stop)
#define gr_dump_frame GR_CALL(gr_screen.gf_dump_frame)
#define gr_set_gamma GR_CALL(gr_screen.gf_set_gamma)
#define gr_get_region GR_CALL(gr_screen.gf_get_region)
@@ -858,8 +891,12 @@ __inline int gr_tcache_set(int bitmap_id, int bitmap_type, float *u_scale, float
#define gr_bm_free_data GR_CALL(*gr_screen.gf_bm_free_data)
#define gr_bm_create GR_CALL(*gr_screen.gf_bm_create)
#define gr_bm_init GR_CALL(*gr_screen.gf_bm_init)
__inline int gr_bm_load(BM_TYPE type, int n, const char *filename, CFILE *img_cfp = NULL, int *w = 0, int *h = 0, int *bpp = 0, BM_TYPE *c_type = 0, int *mm_lvl = 0, int *size = 0)
{
return (*gr_screen.gf_bm_load)(type, n, filename, img_cfp, w, h, bpp, c_type, mm_lvl, size);
}
#define gr_bm_page_in_start GR_CALL(*gr_screen.gf_bm_page_in_start)
#define gr_bm_data GR_CALL(*gr_screen.gf_bm_data)
#define gr_bm_lock GR_CALL(*gr_screen.gf_bm_lock)
#define gr_bm_make_render_target GR_CALL(*gr_screen.gf_bm_make_render_target)
@@ -889,6 +926,9 @@ __inline void gr_render_buffer(int start, const vertex_buffer *bufferp, int texi
#define gr_render_stream_buffer_end GR_CALL(*gr_screen.gf_render_stream_buffer_end)
#define gr_set_buffer GR_CALL(*gr_screen.gf_set_buffer)
#define gr_make_flat_buffer GR_CALL(*gr_screen.gf_make_flat_buffer)
#define gr_make_line_buffer GR_CALL(*gr_screen.gf_make_line_buffer)
#define gr_set_proj_matrix GR_CALL(*gr_screen.gf_set_proj_matrix)
#define gr_end_proj_matrix GR_CALL(*gr_screen.gf_end_proj_matrix)
@@ -933,6 +973,12 @@ __inline void gr_render_buffer(int start, const vertex_buffer *bufferp, int texi
#define gr_set_fill_mode GR_CALL(*gr_screen.gf_set_fill_mode)
#define gr_set_texture_panning GR_CALL(*gr_screen.gf_set_texture_panning)
#define gr_start_state_block GR_CAL(*gr_screen.gf_start_state_block)
#define gr_end_state_block GR_CALL(*gr_screen.gf_end_state_block)
#define gr_set_state_block GR_CALL(*gr_screen.gf_set_state_block)
#define gr_setup_background_fog GR_CALL(*gr_screen.gf_setup_background_fog)
#define gr_draw_line_list GR_CALL(*gr_screen.gf_draw_line_list)
#define gr_set_line_width GR_CALL(*gr_screen.gf_set_line_width)
+14 -14
View File
@@ -173,11 +173,11 @@ void geometry_batcher::draw_bitmap(vertex *pnt, int orient, float rad, float dep
uvec = View_matrix.vec.uvec;
// make a right vector from the f and up vector, this r vec is exactly what we want, so...
vm_vec_cross(&rvec, &View_matrix.vec.fvec, &uvec);
vm_vec_crossprod(&rvec, &View_matrix.vec.fvec, &uvec);
vm_vec_normalize_safe(&rvec);
// fix the u vec with it
vm_vec_cross(&uvec, &View_matrix.vec.fvec, &rvec);
vm_vec_crossprod(&uvec, &View_matrix.vec.fvec, &rvec);
// move the center of the sprite based on the depth parameter
if ( depth != 0.0f )
@@ -284,9 +284,9 @@ void geometry_batcher::draw_bitmap(vertex *pnt, float rad, float angle, float de
vm_rot_point_around_line(&uvec, &View_matrix.vec.uvec, angle, &vmd_zero_vector, &View_matrix.vec.fvec);
vm_vec_cross(&rvec, &View_matrix.vec.fvec, &uvec);
vm_vec_crossprod(&rvec, &View_matrix.vec.fvec, &uvec);
vm_vec_normalize_safe(&rvec);
vm_vec_cross(&uvec, &View_matrix.vec.fvec, &rvec);
vm_vec_crossprod(&uvec, &View_matrix.vec.fvec, &rvec);
vm_vec_scale_add(&PNT, &PNT, &fvec, depth);
vm_vec_scale_add(&p[0], &PNT, &rvec, rad);
@@ -373,13 +373,13 @@ void geometry_batcher::draw_beam(vec3d *start, vec3d *end, float width, float in
vm_vec_sub(&evec, &View_position, start);
vm_vec_normalize_safe(&evec);
vm_vec_cross(&uvecs, &fvec, &evec);
vm_vec_crossprod(&uvecs, &fvec, &evec);
vm_vec_normalize_safe(&uvecs);
vm_vec_sub(&evec, &View_position, end);
vm_vec_normalize_safe(&evec);
vm_vec_cross(&uvece, &fvec, &evec);
vm_vec_crossprod(&uvece, &fvec, &evec);
vm_vec_normalize_safe(&uvece);
@@ -441,13 +441,13 @@ float geometry_batcher::draw_laser(vec3d *p0, float width1, vec3d *p1, float wid
vm_vec_normalize(&reye);
// compute the up vector
vm_vec_cross(&uvec, &fvec, &reye);
vm_vec_crossprod(&uvec, &fvec, &reye);
vm_vec_normalize_safe(&uvec);
// ... the forward vector
vm_vec_cross(&fvec, &uvec, &reye);
vm_vec_crossprod(&fvec, &uvec, &reye);
vm_vec_normalize_safe(&fvec);
// now recompute right vector, in case it wasn't entirely perpendiclar
vm_vec_cross(&rvec, &uvec, &fvec);
vm_vec_crossprod(&rvec, &uvec, &fvec);
// Now have uvec, which is up vector and rvec which is the normal
// of the face.
@@ -728,12 +728,12 @@ int batch_add_bitmap(int texture, int tmap_flags, vertex *pnt, int orient, float
return 1;
}
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || GLSL_version <= 120 ) ) {
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || Use_GLSL <= 2 ) ) {
// don't render this as a soft particle if we don't support soft particles
tmap_flags &= ~(TMAP_FLAG_SOFT_QUAD);
}
if ( GLSL_version > 120 && Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && Is_Extension_Enabled(OGL_EXT_GEOMETRY_SHADER4) && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
if ( Use_GLSL > 2 && Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && Is_Extension_Enabled(OGL_EXT_GEOMETRY_SHADER4) && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
geometry_batch_add_bitmap(texture, tmap_flags, pnt, orient, rad, alpha, depth);
return 0;
} else if ( tmap_flags & TMAP_FLAG_VERTEX_GEN ) {
@@ -797,7 +797,7 @@ int batch_add_bitmap_rotated(int texture, int tmap_flags, vertex *pnt, float ang
return 1;
}
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || GLSL_version <= 120 ) ) {
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || Use_GLSL <= 2 ) ) {
// don't render this as a soft particle if we don't support soft particles
tmap_flags &= ~(TMAP_FLAG_SOFT_QUAD);
}
@@ -1179,7 +1179,7 @@ int distortion_add_bitmap_rotated(int texture, int tmap_flags, vertex *pnt, floa
return 1;
}
if ( GLSL_version < 120 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
if ( Use_GLSL < 2 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
// don't render distortions if we can't support them.
return 0;
}
@@ -1214,7 +1214,7 @@ int distortion_add_beam(int texture, int tmap_flags, vec3d *start, vec3d *end, f
return 1;
}
if ( GLSL_version < 120 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
if ( Use_GLSL < 2 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
// don't render distortions if we can't support them.
return 0;
}
+121 -19
View File
@@ -51,11 +51,7 @@ typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);
// minimum GL version we can reliably support is 1.2
static const int MIN_REQUIRED_GL_VERSION = 12;
// minimum GLSL version we can reliably support is 110
static const int MIN_REQUIRED_GLSL_VERSION = 110;
int GL_version = 0;
int GLSL_version = 0;
bool GL_initted = 0;
@@ -75,6 +71,14 @@ static ushort *GL_original_gamma_ramp = NULL;
int Use_VBOs = 0;
int Use_PBOs = 0;
int Use_GLSL = 0;
static int GL_dump_frames = 0;
static ubyte *GL_dump_buffer = NULL;
static int GL_dump_frame_number = 0;
static int GL_dump_frame_count = 0;
static int GL_dump_frame_count_max = 0;
static int GL_dump_frame_size = 0;
static ubyte *GL_saved_screen = NULL;
static ubyte *GL_saved_mouse_data = NULL;
@@ -1146,6 +1150,96 @@ void gr_opengl_free_screen(int bmp_id)
GL_saved_screen_id = -1;
}
static void opengl_flush_frame_dump()
{
char filename[MAX_FILENAME_LEN];
Assert( GL_dump_buffer != NULL);
for (int i = 0; i < GL_dump_frame_count; i++) {
sprintf(filename, NOX("frm%04d.tga"), GL_dump_frame_number );
GL_dump_frame_number++;
CFILE *f = cfopen(filename, "wb", CFILE_NORMAL, CF_TYPE_DATA);
// Write the TGA header
cfwrite_ubyte( 0, f ); // IDLength;
cfwrite_ubyte( 0, f ); // ColorMapType;
cfwrite_ubyte( 2, f ); // ImageType; // 2 = 24bpp, uncompressed, 10=24bpp rle compressed
cfwrite_ushort( 0, f ); // CMapStart;
cfwrite_ushort( 0, f ); // CMapLength;
cfwrite_ubyte( 0, f ); // CMapDepth;
cfwrite_ushort( 0, f ); // XOffset;
cfwrite_ushort( 0, f ); // YOffset;
cfwrite_ushort( (ushort)gr_screen.max_w, f ); // Width;
cfwrite_ushort( (ushort)gr_screen.max_h, f ); // Height;
cfwrite_ubyte( 24, f ); //PixelDepth;
cfwrite_ubyte( 0, f ); //ImageDesc;
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, gr_screen.max_w, gr_screen.max_h, GL_BGR_EXT, GL_UNSIGNED_BYTE, GL_dump_buffer);
// save the data out
cfwrite( GL_dump_buffer, GL_dump_frame_size, 1, f );
cfclose(f);
}
GL_dump_frame_count = 0;
}
void gr_opengl_dump_frame_start(int first_frame, int frames_between_dumps)
{
if ( GL_dump_frames ) {
Int3(); // We're already dumping frames. See John.
return;
}
GL_dump_frames = 1;
GL_dump_frame_number = first_frame;
GL_dump_frame_count = 0;
GL_dump_frame_count_max = frames_between_dumps; // only works if it's 1
GL_dump_frame_size = gr_screen.max_w * gr_screen.max_h * 3;
if ( !GL_dump_buffer ) {
int size = GL_dump_frame_count_max * GL_dump_frame_size;
GL_dump_buffer = (ubyte *)vm_malloc(size);
if ( !GL_dump_buffer ) {
Error(LOCATION, "Unable to malloc %d bytes for dump buffer", size );
}
}
}
void gr_opengl_dump_frame_stop()
{
if ( !GL_dump_frames ) {
Int3(); // We're not dumping frames. See John.
return;
}
// dump any remaining frames
opengl_flush_frame_dump();
GL_dump_frames = 0;
if ( GL_dump_buffer ) {
vm_free(GL_dump_buffer);
GL_dump_buffer = NULL;
}
}
void gr_opengl_dump_frame()
{
GL_dump_frame_count++;
if ( GL_dump_frame_count == GL_dump_frame_count_max ) {
opengl_flush_frame_dump();
}
}
//fill mode, solid/wire frame
void gr_opengl_set_fill_mode(int mode)
{
@@ -1230,6 +1324,13 @@ void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
// tex_shift=vmd_zero_vector;
}
void gr_opengl_setup_background_fog(bool set)
{
if (Cmdline_nohtl) {
return;
}
}
void gr_opengl_set_line_width(float width)
{
glLineWidth(width);
@@ -1694,6 +1795,8 @@ void opengl_setup_function_pointers()
gr_screen.gf_set_palette = gr_opengl_set_palette;
gr_screen.gf_print_screen = gr_opengl_print_screen;
gr_screen.gf_fade_in = gr_opengl_fade_in;
gr_screen.gf_fade_out = gr_opengl_fade_out;
gr_screen.gf_flash = gr_opengl_flash;
gr_screen.gf_flash_alpha = gr_opengl_flash_alpha;
@@ -1710,6 +1813,10 @@ void opengl_setup_function_pointers()
gr_screen.gf_restore_screen = gr_opengl_restore_screen;
gr_screen.gf_free_screen = gr_opengl_free_screen;
gr_screen.gf_dump_frame_start = gr_opengl_dump_frame_start;
gr_screen.gf_dump_frame_stop = gr_opengl_dump_frame_stop;
gr_screen.gf_dump_frame = gr_opengl_dump_frame;
gr_screen.gf_set_gamma = gr_opengl_set_gamma;
gr_screen.gf_fog_set = gr_opengl_fog_set;
@@ -1721,8 +1828,9 @@ void opengl_setup_function_pointers()
gr_screen.gf_bm_free_data = gr_opengl_bm_free_data;
gr_screen.gf_bm_create = gr_opengl_bm_create;
gr_screen.gf_bm_init = gr_opengl_bm_init;
gr_screen.gf_bm_load = gr_opengl_bm_load;
gr_screen.gf_bm_page_in_start = gr_opengl_bm_page_in_start;
gr_screen.gf_bm_data = gr_opengl_bm_data;
gr_screen.gf_bm_lock = gr_opengl_bm_lock;
gr_screen.gf_bm_make_render_target = gr_opengl_bm_make_render_target;
gr_screen.gf_bm_set_render_target = gr_opengl_bm_set_render_target;
@@ -1803,6 +1911,12 @@ void opengl_setup_function_pointers()
gr_screen.gf_center_alpha = gr_opengl_center_alpha;
gr_screen.gf_set_thrust_scale = gr_opengl_set_thrust_scale;
gr_screen.gf_setup_background_fog = gr_opengl_setup_background_fog;
gr_screen.gf_start_state_block = gr_opengl_start_state_block;
gr_screen.gf_end_state_block = gr_opengl_end_state_block;
gr_screen.gf_set_state_block = gr_opengl_set_state_block;
gr_screen.gf_draw_line_list = gr_opengl_draw_line_list;
gr_screen.gf_set_line_width = gr_opengl_set_line_width;
@@ -1897,7 +2011,7 @@ bool gr_opengl_init()
GLint max_texture_units = GL_supported_texture_units;
GLint max_texture_coords = GL_supported_texture_units;
if (is_minimum_GLSL_version()) {
if (Use_GLSL) {
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units);
}
@@ -1977,7 +2091,7 @@ bool gr_opengl_init()
mprintf(( " Post-processing enabled: %s\n", (Cmdline_postprocess) ? "YES" : "NO"));
mprintf(( " Using %s texture filter.\n", (GL_mipmap_filter) ? NOX("trilinear") : NOX("bilinear") ));
if (is_minimum_GLSL_version()) {
if (Use_GLSL) {
mprintf(( " OpenGL Shader Version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION) ));
}
@@ -2052,15 +2166,3 @@ DCF(ogl_anisotropy, "toggles anisotropic filtering")
// opengl_set_anisotropy( (float)Dc_arg_float );
}
}
/**
* Helper function to enquire whether minimum GLSL version present.
*
* Compares global variable set by glGetString(GL_SHADING_LANGUAGE_VERSION)
* against compile time MIN_REQUIRED_GLSL_VERSION.
*
* @return true if GLSL support present is above the minimum version.
*/
bool is_minimum_GLSL_version() {
return GLSL_version >= MIN_REQUIRED_GLSL_VERSION ? true : false;
}
+1 -2
View File
@@ -655,7 +655,6 @@ const ubyte GL_zero_3ub[3] = { 0, 0, 0 };
bool gr_opengl_init();
void gr_opengl_cleanup(int minimize=1);
int opengl_check_for_errors(char *err_at = NULL);
bool is_minimum_GLSL_version();
#ifndef NDEBUG
#define GL_CHECK_FOR_ERRORS(s) opengl_check_for_errors((s))
@@ -664,9 +663,9 @@ bool is_minimum_GLSL_version();
#endif
extern int GL_version;
extern int GLSL_version;
extern int Use_VBOs;
extern int Use_PBOs;
extern int Use_GLSL;
#endif
+445 -6
View File
@@ -78,6 +78,108 @@ void gr_opengl_bm_create(int n)
Assert( (n >= 0) && (n < MAX_BITMAPS) );
}
// Load an image and validate it while retrieving information for later use
// Input: type = current BM_TYPE_*
// n = location in bm_bitmaps[]
// filename = name of the current file
// img_cfp = already open CFILE handle, if available
//
// Output: w = bmp width
// h = bmp height
// bpp = bmp bits per pixel
// c_type = output for an updated BM_TYPE_*
// mm_lvl = number of mipmap levels for the image
// size = size of the data contained in the image
int gr_opengl_bm_load(BM_TYPE type, int n, const char *filename, CFILE *img_cfp, int *w, int *h, int *bpp, BM_TYPE *c_type, int *mm_lvl, int *size)
{
int dds_ct;
if (type == BM_TYPE_DDS) {
int dds_error = dds_read_header( filename, img_cfp, w, h, bpp, &dds_ct, mm_lvl, size );
if (dds_error != DDS_ERROR_NONE) {
mprintf(("DDS ERROR: Couldn't open '%s' -- %s\n", filename, dds_error_string(dds_error)));
return -1;
}
switch (dds_ct) {
case DDS_DXT1:
*c_type = BM_TYPE_DXT1;
break;
case DDS_DXT3:
*c_type = BM_TYPE_DXT3;
break;
case DDS_DXT5:
*c_type = BM_TYPE_DXT5;
break;
case DDS_UNCOMPRESSED:
*c_type = BM_TYPE_DDS;
break;
case DDS_CUBEMAP_DXT1:
*c_type = BM_TYPE_CUBEMAP_DXT1;
break;
case DDS_CUBEMAP_DXT3:
*c_type = BM_TYPE_CUBEMAP_DXT3;
break;
case DDS_CUBEMAP_DXT5:
*c_type = BM_TYPE_CUBEMAP_DXT5;
break;
case DDS_CUBEMAP_UNCOMPRESSED:
*c_type = BM_TYPE_CUBEMAP_DDS;
break;
default:
Error(LOCATION, "Bad DDS file compression! Not using DXT1,3,5: %s", filename);
return -1;
}
}
// if its a tga file
else if (type == BM_TYPE_TGA) {
int tga_error = targa_read_header( filename, img_cfp, w, h, bpp, NULL );
if ( tga_error != TARGA_ERROR_NONE ) {
mprintf(( "tga: Couldn't open '%s'\n", filename ));
return -1;
}
}
// if its a png file
else if (type == BM_TYPE_PNG) {
int png_error=png_read_header( filename, img_cfp, w, h, bpp, NULL );
if ( png_error != PNG_ERROR_NONE ) {
mprintf(( "png: Couldn't open '%s'\n", filename ));
return -1;
}
}
// if its a jpg file
else if (type == BM_TYPE_JPG) {
int jpg_error=jpeg_read_header( filename, img_cfp, w, h, bpp, NULL );
if ( jpg_error != JPEG_ERROR_NONE ) {
mprintf(( "jpg: Couldn't open '%s'\n", filename ));
return -1;
}
}
// if its a pcx file
else if (type == BM_TYPE_PCX) {
int pcx_error = pcx_read_header( filename, img_cfp, w, h, bpp, NULL );
if ( pcx_error != PCX_ERROR_NONE ) {
mprintf(( "pcx: Couldn't open '%s'\n", filename ));
return -1;
}
} else {
Assert( 0 );
return -1;
}
return 0;
}
/**
* API specific init instructions
*/
@@ -95,9 +197,352 @@ void gr_opengl_bm_page_in_start()
}
extern void bm_clean_slot(int n);
extern int opengl_compress_image( ubyte **out_data, ubyte *in_data, int width, int height, int alpha = 1, int num_mipmaps = 1 );
static int opengl_bm_lock_ani_compress( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags )
{
anim *the_anim;
anim_instance *the_anim_instance;
bitmap *bm;
ubyte *frame_data;
int size, i;
int first_frame, nframes;
ubyte *compressed_data = NULL;
int out_size = 0;
int alpha = 0;
int num_mipmaps = 1;
first_frame = be->info.ani.first_frame;
nframes = bm_bitmaps[first_frame].info.ani.num_frames;
// bpp can always be 24-bit since we don't do images with alpha here
bpp = 24;
alpha = (bpp == 32);
if ( (the_anim = anim_load(bm_bitmaps[first_frame].filename, bm_bitmaps[first_frame].dir_type)) == NULL ) {
nprintf(("BMPMAN", "Error opening %s in bm_lock\n", be->filename));
return 1;
}
if ( (the_anim_instance = init_anim_instance(the_anim, bpp)) == NULL ) {
nprintf(("BMPMAN", "Error opening %s in bm_lock\n", be->filename));
anim_free(the_anim);
return 1;
}
int can_drop_frames = 0;
if ( the_anim->total_frames != bm_bitmaps[first_frame].info.ani.num_frames ) {
can_drop_frames = 1;
}
bm = &bm_bitmaps[first_frame].bm;
size = bm->w * bm->h * (bpp >> 3);
num_mipmaps = get_num_mipmap_levels( bm->w, bm->h );
Assert( num_mipmaps > 0 );
nprintf(("BMPMAN", "Attempting to compress '%s' with %d frames, original size %.3fM ... ", bm_bitmaps[first_frame].filename, nframes, ((float)(size*nframes)/1024.0f)/1024.0f));
for ( i=0; i<nframes; i++ ) {
be = &bm_bitmaps[first_frame+i];
bmp = &bm_bitmaps[first_frame+i].bm;
// Unload any existing data
bm_clean_slot( first_frame+i );
bmp->flags = 0;
bmp->bpp = bpp;
frame_data = anim_get_next_raw_buffer(the_anim_instance, 0, 0, bmp->bpp);
Assert( frame_data != NULL );
out_size = opengl_compress_image(&compressed_data, frame_data, bmp->w, bmp->h, alpha, num_mipmaps);
if (out_size == 0) {
if (compressed_data != NULL) {
vm_free(compressed_data);
compressed_data = NULL;
}
nprintf(("BMPMAN", "compression failed!!\n"));
return 1;
}
Assert( compressed_data != NULL );
bmp->data = (ptr_u)compressed_data;
bmp->bpp = (alpha) ? 32 : 24;
bmp->palette = NULL;
be->comp_type = (alpha) ? BM_TYPE_DXT5 : BM_TYPE_DXT1;
be->mem_taken = out_size;
be->num_mipmaps = num_mipmaps;
bm_update_memory_used( first_frame + i, out_size );
// Skip a frame
if ( (i < nframes-1) && can_drop_frames ) {
frame_data = anim_get_next_raw_buffer(the_anim_instance, 0, 0, bm->bpp);
}
compressed_data = NULL;
}
if (num_mipmaps > 1) {
nprintf(("BMPMAN", "new size is %.3fM with %d mipmap levels.\n", ((float)(out_size*nframes)/1024.0f)/1024.0f, num_mipmaps));
} else {
nprintf(("BMPMAN", "new size is %.3fM.\n", ((float)(out_size*nframes)/1024.0f)/1024.0f));
}
free_anim_instance(the_anim_instance);
anim_free(the_anim);
return 0;
}
static int opengl_bm_lock_compress( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, int bpp, int flags )
{
ubyte *data = NULL;
ubyte *compressed_data = NULL;
int error_code = 1;
int out_size = 0;
int byte_size = 0;
int alpha = 1;
int num_mipmaps = 1;
// don't use for EFFs, if they were wanting to be DDS then they should already be that way
if ( be->type == BM_TYPE_EFF ) {
return 1;
}
Assert( (be->type == BM_TYPE_PCX) ||
(be->type == BM_TYPE_TGA) ||
(be->type == BM_TYPE_PNG) ||
(be->type == BM_TYPE_JPG) );
Assert( !(flags & BMP_AABITMAP) );
// PCX need to be loaded as 32-bit
if ( (be->type == BM_TYPE_PCX) && (bpp == 16) )
bpp = 32;
bm_clean_slot( bitmapnum );
byte_size = (bpp >> 3);
Assert( (byte_size == 3) || (byte_size == 4) );
alpha = (byte_size != 3);
data = (ubyte*)vm_malloc(bmp->w * bmp->h * byte_size);
Assert( data != NULL );
if ( data == NULL )
return 1;
// read in bitmap data
if (be->type == BM_TYPE_PCX) {
Assert( bpp == 32 );
error_code = pcx_read_bitmap( be->filename, data, NULL, byte_size );
} else if (be->type == BM_TYPE_TGA) {
error_code = targa_read_bitmap( be->filename, data, NULL, byte_size );
} else if (be->type == BM_TYPE_PNG) {
error_code = png_read_bitmap( be->filename, data, NULL, byte_size );
} else if (be->type == BM_TYPE_JPG) {
error_code = jpeg_read_bitmap( be->filename, data, NULL, byte_size );
} else {
Assert( 0 );
}
nprintf(("BMPMAN", "Attempting to compress '%s', original size %.3fM ... ", be->filename, ((float)(bmp->w * bmp->h * byte_size)/1024.0f)/1024.0f));
// NOTE: this assumes that the *_ERROR_NONE #define's are going to be 0
if (error_code) {
if (data != NULL) {
vm_free(data);
data = NULL;
}
nprintf(("BMPMAN", "initial read failed!!\n"));
return 1;
}
num_mipmaps = get_num_mipmap_levels( bmp->w, bmp->h );
Assert( num_mipmaps > 0 );
// now for the attempt to compress the data
out_size = opengl_compress_image(&compressed_data, data, bmp->w, bmp->h, alpha, num_mipmaps);
if (data != NULL) {
vm_free(data);
data = NULL;
}
if (out_size == 0) {
if (compressed_data != NULL) {
vm_free(compressed_data);
compressed_data = NULL;
}
nprintf(("BMPMAN", "compression failed!!\n"));
return 1;
}
Assert( compressed_data != NULL );
if (num_mipmaps > 1) {
nprintf(("BMPMAN", "new size is %.3fM with %d mipmap levels.\n", ((float)out_size/1024.0f)/1024.0f, num_mipmaps));
} else {
nprintf(("BMPMAN", "new size is %.3fM.\n", ((float)out_size/1024.0f)/1024.0f));
}
bmp->data = (ptr_u)compressed_data;
bmp->bpp = (alpha) ? (ubyte)32 : (ubyte)24;
bmp->palette = NULL;
be->comp_type = (alpha) ? BM_TYPE_DXT5 : BM_TYPE_DXT1;
be->mem_taken = out_size;
be->num_mipmaps = num_mipmaps;
bm_update_memory_used( bitmapnum, out_size );
return 0;
}
extern bool opengl_texture_slot_valid(int n, int handle);
/**
* Lock an image files data into memory
*/
int gr_opengl_bm_lock( const char *filename, int handle, int bitmapnum, ubyte bpp, ubyte flags, bool nodebug)
{
BM_TYPE c_type = BM_TYPE_NONE;
ubyte true_bpp;
int try_compress = 0;
bitmap_entry *be = &bm_bitmaps[bitmapnum];
bitmap *bmp = &be->bm;
Assert( !Is_standalone );
if (bmp->true_bpp > bpp)
true_bpp = bmp->true_bpp;
else
true_bpp = bpp;
// don't do a bpp check here since it could be different in OGL - taylor
if ( (bmp->data == 0) && !opengl_texture_slot_valid(bitmapnum, handle) ) {
Assert(be->ref_count == 1);
if (be->type != BM_TYPE_USER && !nodebug) {
if (bmp->data == 0)
nprintf (("BmpMan", "Loading %s for the first time.\n", be->filename));
}
if ( !Bm_paging ) {
if (be->type != BM_TYPE_USER && !nodebug)
nprintf(("Paging", "Loading %s (%dx%dx%d)\n", be->filename, bmp->w, bmp->h, true_bpp));
}
// select proper format
if (flags & BMP_AABITMAP)
BM_SELECT_ALPHA_TEX_FORMAT();
else if (flags & BMP_TEX_ANY)
BM_SELECT_TEX_FORMAT();
else
BM_SELECT_SCREEN_FORMAT();
// make sure we use the real graphic type for EFFs
if ( be->type == BM_TYPE_EFF ) {
c_type = be->info.ani.eff.type;
} else {
c_type = be->type;
}
try_compress = (Cmdline_img2dds && Texture_compression_available && is_power_of_two(bmp->w, bmp->h) && !(flags & BMP_AABITMAP) && !Is_standalone);
switch ( c_type )
{
case BM_TYPE_PCX:
if (try_compress && (true_bpp >= 16)) {
if ( !opengl_bm_lock_compress(handle, bitmapnum, be, bmp, true_bpp, flags) ) {
break;
}
}
bm_lock_pcx( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_ANI:
if (try_compress && (true_bpp >= 16) && !(flags & BMP_TEX_XPARENT)) {
if ( !opengl_bm_lock_ani_compress(handle, bitmapnum, be, bmp, true_bpp, flags) ) {
break;
}
}
bm_lock_ani( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_TGA:
if (try_compress && (true_bpp >= 24)) {
if ( !opengl_bm_lock_compress(handle, bitmapnum, be, bmp, true_bpp, flags) ) {
break;
}
}
bm_lock_tga( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_PNG:
//libpng handles compression with zlib
bm_lock_png( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_JPG:
if (try_compress) {
if ( !opengl_bm_lock_compress(handle, bitmapnum, be, bmp, true_bpp, flags) ) {
break;
}
}
bm_lock_jpg( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_DDS:
case BM_TYPE_DXT1:
case BM_TYPE_DXT3:
case BM_TYPE_DXT5:
case BM_TYPE_CUBEMAP_DDS:
case BM_TYPE_CUBEMAP_DXT1:
case BM_TYPE_CUBEMAP_DXT3:
case BM_TYPE_CUBEMAP_DXT5:
bm_lock_dds( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_USER:
bm_lock_user( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
default:
Warning(LOCATION, "Unsupported type in bm_lock -- %d\n", c_type );
return -1;
}
// always go back to screen format
BM_SELECT_SCREEN_FORMAT();
// make sure we actually did something
if ( !(bmp->data) )
return -1;
}
return 0;
}
void gr_opengl_bm_save_render_target(int n)
{
Assert( (n >= 0) && (n < MAX_BITMAPS) );
@@ -171,9 +616,3 @@ int gr_opengl_bm_set_render_target(int n, int face)
return 0;
}
bool gr_opengl_bm_data(int n, bitmap* bm)
{
// Do nothing here
return true;
}
+16 -1
View File
@@ -22,13 +22,28 @@ void gr_opengl_bm_free_data(int n, bool release);
// API specifics for creating a user bitmap
void gr_opengl_bm_create(int n);
// Load an image and validate it while retrieving information for later use
// Input: type = current BM_TYPE_*
// n = location in bm_bitmaps[]
// filename = name of the current file
// img_cfp = already open CFILE handle, if available
//
// Output: w = bmp width
// h = bmp height
// bpp = bmp bits per pixel
// c_type = output for an updated BM_TYPE_*
// mm_lvl = number of mipmap levels for the image
// size = size of the data contained in the image
int gr_opengl_bm_load(BM_TYPE type, int n, const char *filename, CFILE *img_cfp = NULL, int *w = 0, int *h = 0, int *bpp = 0, BM_TYPE *c_type = 0, int *mm_lvl = 0, int *size = 0);
// API specific init instructions
void gr_opengl_bm_init(int n);
// specific instructions for setting up the start of a page-in session
void gr_opengl_bm_page_in_start();
bool gr_opengl_bm_data(int n, bitmap* bm);
// Lock an image files data into memory
int gr_opengl_bm_lock(const char *filename, int handle, int bitmapnum, ubyte bpp, ubyte flags, bool nodebug);
void gr_opengl_bm_save_render_target(int slot);
int gr_opengl_bm_make_render_target(int n, int *width, int *height, ubyte *bpp, int *mm_lvl, int flags);
+14 -3
View File
@@ -2036,6 +2036,17 @@ void gr_opengl_flash_alpha(int r, int g, int b, int a)
opengl_draw_coloured_quad((GLint)x1, (GLint)y1, (GLint)x2, (GLint)y2);
}
void gr_opengl_fade_in(int instantaneous)
{
// Empty - DDOI
}
void gr_opengl_fade_out(int instantaneous)
{
// Empty - DDOI
}
void opengl_bitmap_ex_internal(int x, int y, int w, int h, int sx, int sy, int resize_mode)
{
if ( (w < 1) || (h < 1) ) {
@@ -2535,7 +2546,7 @@ void opengl_setup_scene_textures()
{
Scene_texture_initialized = 0;
if ( !is_minimum_GLSL_version() || Cmdline_no_fbo || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
if ( !Use_GLSL || Cmdline_no_fbo || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
Cmdline_postprocess = 0;
Cmdline_softparticles = 0;
Cmdline_fb_explosions = 0;
@@ -3056,7 +3067,7 @@ void opengl_clear_deferred_buffers()
void gr_opengl_deferred_lighting_begin()
{
if (GLSL_version < 120 || Cmdline_no_deferred_lighting)
if (Use_GLSL < 2 || Cmdline_no_deferred_lighting)
return;
Deferred_lighting = true;
@@ -3082,7 +3093,7 @@ extern float static_tube_factor;
void gr_opengl_deferred_lighting_finish()
{
if ( GLSL_version < 120 || Cmdline_no_deferred_lighting ) {
if ( Use_GLSL < 2 || Cmdline_no_deferred_lighting ) {
return;
}
+2
View File
@@ -31,6 +31,8 @@ void gr_opengl_cross_fade(int bmap1, int bmap2, int x1, int y1, int x2, int y2,
void gr_opengl_shade(int x, int y, int w, int h, int resize_mode);
void gr_opengl_flash(int r, int g, int b);
void gr_opengl_flash_alpha(int r, int g, int b, int a);
void gr_opengl_fade_in(int instantaneous);
void gr_opengl_fade_out(int instantaneous);
void gr_opengl_tmapper(int nverts, vertex **verts, uint flags);
void gr_opengl_render(int nverts, vertex *verts, uint flags);
void gr_opengl_render_effect(int nverts, vertex *verts, float *radius_list, uint flags);
+19 -8
View File
@@ -444,16 +444,27 @@ void opengl_extensions_init()
sscanf(glsl_ver, "%d.%d", &major, &minor);
ver = (major * 100) + minor;
GLSL_version = ver;
// we require a minimum GLSL version
if (!is_minimum_GLSL_version()) {
// SM 4.0 compatible or better
if (ver >= 400) {
Use_GLSL = 4;
}
// SM 3.0 compatible
else if ( ver >= 130 ) {
Use_GLSL = 3;
}
// SM 2.0 compatible
else if (ver >= 120) {
Use_GLSL = 2;
}
// we require GLSL 1.20 or higher
else if (ver < 110) {
Use_GLSL = 0;
mprintf((" OpenGL Shading Language version %s is not sufficient to use GLSL mode in FSO. Defaulting to fixed-function renderer.\n", glGetString(GL_SHADING_LANGUAGE_VERSION) ));
}
}
// can't have this stuff without GLSL support
if ( !is_minimum_GLSL_version() ) {
if ( !Use_GLSL ) {
Cmdline_normal = 0;
Cmdline_height = 0;
Cmdline_postprocess = 0;
@@ -461,13 +472,13 @@ void opengl_extensions_init()
Cmdline_no_deferred_lighting = 1;
}
if ( GLSL_version < 120 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) || !Is_Extension_Enabled(OGL_ARB_FLOATING_POINT_TEXTURES) ) {
if ( Use_GLSL < 2 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) || !Is_Extension_Enabled(OGL_ARB_FLOATING_POINT_TEXTURES) ) {
mprintf((" No hardware support for deferred lighting. Deferred lighting will be disabled. \n"));
Cmdline_no_deferred_lighting = 1;
Cmdline_no_batching = true;
}
if (is_minimum_GLSL_version()) {
if (Use_GLSL) {
GLint max_texture_units;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &max_texture_units);
@@ -482,7 +493,7 @@ void opengl_extensions_init()
Cmdline_height = 0;
} else if (max_texture_units < 4) {
mprintf(( "Not enough texture units found for GLSL support. We need at least 4, we found %d.\n", max_texture_units ));
GLSL_version = 0;
Use_GLSL = 0;
}
}
}
+2 -2
View File
@@ -118,7 +118,7 @@ void FSLight2GLLight(light *FSLight, opengl_light *GLLight)
GLLight->Position[2] = FSLight->vec2.xyz.z;
GLLight->Position[3] = 1.0f;
if ( is_minimum_GLSL_version() ) {
if ( Use_GLSL > 1 ) {
// Valathil: When using shaders pass the beam direction (not normalized IMPORTANT for calculation of tube)
vec3d a;
vm_vec_sub(&a, &FSLight->vec2, &FSLight->vec);
@@ -164,7 +164,7 @@ void opengl_set_light(int light_num, opengl_light *ltp)
GLfloat diffuse[4];
memcpy(diffuse, ltp->Diffuse, sizeof(GLfloat) * 4);
if ( !is_minimum_GLSL_version() && (ltp->type == LT_DIRECTIONAL) && (GL_light_factor < 1.0f) ) {
if ( !Use_GLSL && (ltp->type == LT_DIRECTIONAL) && (GL_light_factor < 1.0f) ) {
// if we're not using shaders, manually adjust the diffuse light factor.
diffuse[0] *= GL_light_factor;
diffuse[1] *= GL_light_factor;
+47 -59
View File
@@ -678,94 +678,82 @@ static bool opengl_post_init_table()
}
}
void opengl_post_shader_header(SCP_stringstream &sflags, shader_type shader_t, int flags)
void opengl_post_load_shader(SCP_string &sflags, shader_type shader_t, int flags)
{
if ( shader_t == SDR_TYPE_POST_PROCESS_MAIN ) {
for (size_t idx = 0; idx < Post_effects.size(); idx++) {
if (flags & (1 << idx)) {
sflags << "#define ";
sflags << Post_effects[idx].define_name.c_str();
sflags << "\n";
sflags += "#define ";
sflags += Post_effects[idx].define_name.c_str();
sflags += "\n";
}
}
} else if ( shader_t == SDR_TYPE_POST_PROCESS_LIGHTSHAFTS ) {
char temp[64];
sprintf(temp, "#define SAMPLE_NUM %d\n", ls_samplenum);
sflags << temp;
sflags += temp;
} else if ( shader_t == SDR_TYPE_POST_PROCESS_FXAA ) {
/* GLSL version < 120 are guarded against reaching this code
path via testing is_minimum_GLSL_version().
Accordingly do not test for them again here. */
if (GLSL_version == 120) {
sflags << "#define FXAA_GLSL_120 1\n";
sflags << "#define FXAA_GLSL_130 0\n";
}
if (GLSL_version > 120) {
sflags << "#define FXAA_GLSL_120 0\n";
sflags << "#define FXAA_GLSL_130 1\n";
}
switch (Cmdline_fxaa_preset) {
case 0:
sflags << "#define FXAA_QUALITY_PRESET 10\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/6.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/12.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 10\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/6.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/12.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 1:
sflags << "#define FXAA_QUALITY_PRESET 11\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/7.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/14.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 11\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/7.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/14.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 2:
sflags << "#define FXAA_QUALITY_PRESET 12\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/8.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/16.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 12\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/8.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/16.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 3:
sflags << "#define FXAA_QUALITY_PRESET 13\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/9.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/18.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 13\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/9.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/18.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 4:
sflags << "#define FXAA_QUALITY_PRESET 14\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/10.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/20.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 14\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/10.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/20.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 5:
sflags << "#define FXAA_QUALITY_PRESET 25\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/11.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/22.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 25\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/11.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/22.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 6:
sflags << "#define FXAA_QUALITY_PRESET 26\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/12.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/24.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 26\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/12.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/24.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 7:
sflags << "#define FXAA_PC 1\n";
sflags << "#define FXAA_QUALITY_PRESET 27\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/13.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/26.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_PC 1\n";
sflags += "#define FXAA_QUALITY_PRESET 27\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/13.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/26.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 8:
sflags << "#define FXAA_QUALITY_PRESET 28\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/14.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/28.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 28\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/14.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/28.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
case 9:
sflags << "#define FXAA_QUALITY_PRESET 39\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/15.0)\n";
sflags << "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/32.0)\n";
sflags << "#define FXAA_QUALITY_SUBPIX 0.33\n";
sflags += "#define FXAA_QUALITY_PRESET 39\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/15.0)\n";
sflags += "#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/32.0)\n";
sflags += "#define FXAA_QUALITY_SUBPIX 0.33\n";
break;
}
}
@@ -982,7 +970,7 @@ void opengl_post_process_init()
return;
}
if ( !is_minimum_GLSL_version() || Cmdline_no_fbo || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
if ( !Use_GLSL || Cmdline_no_fbo || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
Cmdline_postprocess = 0;
return;
}
+1 -1
View File
@@ -13,6 +13,6 @@ void gr_opengl_post_process_end();
void get_post_process_effect_names(SCP_vector<SCP_string> &names);
void opengl_post_init_uniforms(int flags);
void opengl_post_shader_header(SCP_stringstream &sflags, shader_type shader_t, int flags);
void opengl_post_load_shader(SCP_string &sflags, shader_type shader_t, int flags);
#endif // _GROPENGLPOSTPROCESSING_H
+100 -69
View File
@@ -125,7 +125,7 @@ static opengl_shader_variant_t GL_shader_variants[] = {
"Utility mapping" },
{ SDR_TYPE_MODEL, false, SDR_FLAG_MODEL_TEAMCOLOR, "FLAG_TEAMCOLOR",
3, { "stripe_color", "base_color", "team_glow_enabled" }, 0, { NULL },
2, { "stripe_color", "base_color" }, 0, { NULL },
"Team Colors" },
{ SDR_TYPE_MODEL, false, SDR_FLAG_MODEL_DEFERRED, "FLAG_DEFERRED",
@@ -169,8 +169,6 @@ static const int GL_num_shader_variants = sizeof(GL_shader_variants) / sizeof(op
opengl_shader_t *Current_shader = NULL;
// Forward declarations
GLhandleARB opengl_shader_create(const SCP_vector<SCP_string>& vs, const SCP_vector<SCP_string>& fs, const SCP_vector<SCP_string>& gs);
void opengl_shader_check_info_log(GLhandleARB shader_object);
/**
@@ -228,7 +226,7 @@ void opengl_shader_set_current(int handle)
*/
int gr_opengl_maybe_create_shader(shader_type shader_t, unsigned int flags)
{
if (!is_minimum_GLSL_version())
if (Use_GLSL < 2)
return -1;
size_t idx;
@@ -270,7 +268,7 @@ void opengl_shader_shutdown()
{
size_t i;
if ( !is_minimum_GLSL_version() ) {
if ( !Use_GLSL ) {
return;
}
@@ -293,31 +291,6 @@ void opengl_shader_shutdown()
}
}
static SCP_string get_shader_header(shader_type type_id, int flags) {
SCP_stringstream sflags;
#ifdef __APPLE__
sflags << "#version 120\n";
sflags << "#define APPLE\n";
#endif
if (type_id == SDR_TYPE_POST_PROCESS_MAIN || type_id == SDR_TYPE_POST_PROCESS_LIGHTSHAFTS || type_id == SDR_TYPE_POST_PROCESS_FXAA) {
// ignore looking for variants. main post process, lightshafts, and FXAA shaders need special headers to be hacked in
opengl_post_shader_header(sflags, type_id, flags);
}
else {
for (int i = 0; i < GL_num_shader_variants; ++i) {
opengl_shader_variant_t &variant = GL_shader_variants[i];
if (type_id == variant.type_id && flags & variant.flag) {
sflags << "#define " << variant.flag_text << "\n";
}
}
}
return sflags.str();
}
/**
* Load a shader file from disc or from the builtin defaults in def_files.cpp if none can be found.
* This function will also create a list of preprocessor defines for the GLSL compiler based on the shader flags
@@ -328,38 +301,70 @@ static SCP_string get_shader_header(shader_type type_id, int flags) {
* @param flags integer variable holding a combination of SDR_* flags
* @return C-string holding the complete shader source code
*/
static SCP_string opengl_load_shader(const char *filename)
static char *opengl_load_shader(shader_type type_id, char *filename, int flags)
{
SCP_string content;
SCP_string sflags;
#ifdef __APPLE__
sflags += "#version 120\n";
#endif
if (Use_GLSL >= 4) {
sflags += "#define SHADER_MODEL 4\n";
}
else if (Use_GLSL == 3) {
sflags += "#define SHADER_MODEL 3\n";
}
else {
sflags += "#define SHADER_MODEL 2\n";
}
#ifdef __APPLE__
sflags += "#define APPLE\n";
#endif
if (type_id == SDR_TYPE_POST_PROCESS_MAIN || type_id == SDR_TYPE_POST_PROCESS_LIGHTSHAFTS || type_id == SDR_TYPE_POST_PROCESS_FXAA) {
// ignore looking for variants. main post process, lightshafts, and FXAA shaders need special headers to be hacked in
opengl_post_load_shader(sflags, type_id, flags);
} else {
for (int i = 0; i < GL_num_shader_variants; ++i) {
opengl_shader_variant_t &variant = GL_shader_variants[i];
if (type_id == variant.type_id && flags & variant.flag) {
sflags += "#define " + variant.flag_text + "\n";
}
}
}
const char *shader_flags = sflags.c_str();
int flags_len = strlen(shader_flags);
if (Enable_external_shaders) {
CFILE *cf_shader = cfopen(filename, "rt", CFILE_NORMAL, CF_TYPE_EFFECTS);
if (cf_shader != NULL) {
int len = cfilelength(cf_shader);
content.resize(len);
char *shader_c = (char*)vm_malloc(len + flags_len + 1);
cfread(&content[0], len + 1, 1, cf_shader);
strcpy(shader_c, shader_flags);
memset(shader_c + flags_len, 0, len + 1);
cfread(shader_c + flags_len, len + 1, 1, cf_shader);
cfclose(cf_shader);
return content;
return shader_c;
}
}
//If we're still here, proceed with internals
mprintf((" Loading built-in default shader for: %s\n", filename));
auto def_shader = defaults_get_file(filename);
content.assign(def_shader);
char* def_shader = defaults_get_file(filename);
size_t len = strlen(def_shader);
char *shader_c = (char*)vm_malloc(len + flags_len + 1);
return content;
}
strcpy(shader_c, shader_flags);
strcat(shader_c, def_shader);
static SCP_vector<SCP_string> opengl_get_shader_content(shader_type type_id, const char* filename, int flags) {
SCP_vector<SCP_string> parts;
parts.push_back(get_shader_header(type_id, flags));
parts.push_back(opengl_load_shader(filename));
return parts;
return shader_c;
}
/**
@@ -373,6 +378,7 @@ int opengl_compile_shader(shader_type sdr, uint flags)
{
int sdr_index = -1;
int empty_idx;
char *vert = NULL, *frag = NULL, *geom = NULL;
opengl_shader_t new_shader;
Assert(sdr < NUM_SHADER_TYPES);
@@ -397,25 +403,36 @@ int opengl_compile_shader(shader_type sdr, uint flags)
}
}
auto vertex_content = opengl_get_shader_content(sdr_info->type_id, sdr_info->vert, flags);
auto fragment_content = opengl_get_shader_content(sdr_info->type_id, sdr_info->frag, flags);
SCP_vector<SCP_string> geom_content;
// read vertex shader
if ((vert = opengl_load_shader(sdr_info->type_id, sdr_info->vert, flags)) == NULL) {
goto Done;
}
// read fragment shader
if ((frag = opengl_load_shader(sdr_info->type_id, sdr_info->frag, flags)) == NULL) {
goto Done;
}
if ( use_geo_sdr ) {
if (!Is_Extension_Enabled(OGL_EXT_GEOMETRY_SHADER4)) {
return -1;
goto Done;
}
// read geometry shader
geom_content = opengl_get_shader_content(sdr_info->type_id, sdr_info->geo, flags);
if ((geom = opengl_load_shader(sdr_info->type_id, sdr_info->geo, flags)) == NULL) {
goto Done;
}
Current_geo_sdr_params = &sdr_info->geo_sdr_info;
}
new_shader.program_id = opengl_shader_create(vertex_content, fragment_content, geom_content);
Verify(vert != NULL);
Verify(frag != NULL);
new_shader.program_id = opengl_shader_create(vert, frag, geom);
if (!new_shader.program_id) {
return -1;
goto Done;
}
new_shader.shader = sdr_info->type_id;
@@ -477,6 +494,22 @@ int opengl_compile_shader(shader_type sdr, uint flags)
GL_shader.push_back(new_shader);
}
Done:
if (vert != NULL) {
vm_free(vert);
vert = NULL;
}
if (frag != NULL) {
vm_free(frag);
frag = NULL;
}
if (geom != NULL ) {
vm_free(geom);
geom = NULL;
}
return sdr_index;
}
@@ -486,7 +519,7 @@ int opengl_compile_shader(shader_type sdr, uint flags)
*/
void opengl_shader_init()
{
if ( !is_minimum_GLSL_version() ) {
if ( !Use_GLSL ) {
return;
}
@@ -503,6 +536,10 @@ void opengl_shader_init()
GLuint pixels[4] = {0,0,0,0};
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &pixels);
if (Cmdline_no_glsl_model_rendering) {
Use_GLSL = 1;
}
GL_shader.clear();
// Reserve 32 shader slots. This should cover most use cases in real life.
@@ -543,20 +580,14 @@ void opengl_shader_check_info_log(GLhandleARB shader_object)
* @param shader_type OpenGL ID for the type of shader being used, like GL_FRAGMENT_SHADER_ARB, GL_VERTEX_SHADER_ARB
* @return OpenGL handle for the compiled shader object
*/
GLhandleARB opengl_shader_compile_object(const SCP_vector<SCP_string>& shader_source, GLenum shader_type)
GLhandleARB opengl_shader_compile_object(const GLcharARB *shader_source, GLenum shader_type)
{
GLhandleARB shader_object = 0;
GLint status = 0;
SCP_vector<const GLcharARB*> sources;
sources.reserve(shader_source.size());
for (auto it = shader_source.begin(); it != shader_source.end(); ++it) {
sources.push_back(it->c_str());
}
shader_object = vglCreateShaderObjectARB(shader_type);
vglShaderSourceARB(shader_object, sources.size(), &sources[0], NULL);
vglShaderSourceARB(shader_object, 1, &shader_source, NULL);
vglCompileShaderARB(shader_object);
// check if the compile was successful
@@ -660,15 +691,15 @@ GLhandleARB opengl_shader_link_object(GLhandleARB vertex_object, GLhandleARB fra
* @param gs Geometry shader source code
* @return Internal ID of compiled and linked shader generated by OpenGL
*/
GLhandleARB opengl_shader_create(const SCP_vector<SCP_string>& vs, const SCP_vector<SCP_string>& fs, const SCP_vector<SCP_string>& gs)
GLhandleARB opengl_shader_create(const char *vs, const char *fs, const char *gs)
{
GLhandleARB vs_o = 0;
GLhandleARB fs_o = 0;
GLhandleARB gs_o = 0;
GLhandleARB program = 0;
if (!vs.empty()) {
vs_o = opengl_shader_compile_object( vs, GL_VERTEX_SHADER_ARB );
if (vs) {
vs_o = opengl_shader_compile_object( (const GLcharARB*)vs, GL_VERTEX_SHADER_ARB );
if ( !vs_o ) {
mprintf(("ERROR! Unable to create vertex shader!\n"));
@@ -676,8 +707,8 @@ GLhandleARB opengl_shader_create(const SCP_vector<SCP_string>& vs, const SCP_vec
}
}
if (!fs.empty()) {
fs_o = opengl_shader_compile_object( fs, GL_FRAGMENT_SHADER_ARB );
if (fs) {
fs_o = opengl_shader_compile_object( (const GLcharARB*)fs, GL_FRAGMENT_SHADER_ARB );
if ( !fs_o ) {
mprintf(("ERROR! Unable to create fragment shader!\n"));
@@ -685,8 +716,8 @@ GLhandleARB opengl_shader_create(const SCP_vector<SCP_string>& vs, const SCP_vec
}
}
if (!gs.empty()) {
gs_o = opengl_shader_compile_object( gs, GL_GEOMETRY_SHADER_EXT );
if (gs) {
gs_o = opengl_shader_compile_object( (const GLcharARB*)gs, GL_GEOMETRY_SHADER_EXT );
if ( !gs_o ) {
mprintf(("ERROR! Unable to create fragment shader!\n"));
+1
View File
@@ -137,6 +137,7 @@ void opengl_shader_init();
void opengl_shader_shutdown();
int opengl_compile_shader(shader_type sdr, uint flags);
GLhandleARB opengl_shader_create(const char *vs, const char *fs, const char *gs);
void opengl_shader_init_attribute(const char *attribute_text);
GLint opengl_shader_get_attribute(const char *attribute_text);
+113 -3
View File
@@ -1198,6 +1198,116 @@ void gr_opengl_set_texture_addressing(int mode)
GL_CHECK_FOR_ERRORS("end of set_texture_addressing()");
}
int opengl_compress_image( ubyte **compressed_data, ubyte *in_data, int width, int height, int alpha, int num_mipmaps )
{
Assert( in_data != NULL );
if ( !Texture_compression_available ) {
return 0;
}
GL_CHECK_FOR_ERRORS("start of compress_image()");
GLuint tex;
GLint compressed = GL_FALSE;
GLint compressed_size = 0;
ubyte *out_data = NULL;
GLint testing = 0;
GLint intFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
GLenum texFormat = GL_UNSIGNED_BYTE;
GLenum glFormat = GL_BGR;
int i;
if (alpha) {
intFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
texFormat = GL_UNSIGNED_INT_8_8_8_8_REV;
glFormat = GL_BGRA;
}
glGenTextures(1, &tex);
GL_state.Texture.SetActiveUnit(0);
GL_state.Texture.SetTarget(GL_TEXTURE_2D);
GL_state.Texture.Enable(tex);
// a quick proxy test. this will tell us if it's possible without wasting a lot of time and resources in the attempt
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, intFormat, width, height, 0, glFormat, texFormat, in_data);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &compressed);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &testing);
if (compressed == GL_TRUE) {
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &compressed);
}
if ( (compressed == GL_FALSE) || (compressed != intFormat) || (testing == 0) ) {
GL_state.Texture.Disable();
GL_state.Texture.Delete(tex);
glDeleteTextures(1, &tex);
return 0;
}
// if mipmaps are requested then make them with the nicest possible settings
if (num_mipmaps > 1) {
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
}
// use best compression quality
glHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST);
// alright, it should work if we are still here, now do it for real
glTexImage2D(GL_TEXTURE_2D, 0, intFormat, width, height, 0, glFormat, texFormat, in_data);
// if we got this far then it should have worked, but check anyway
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &compressed);
Assert( compressed != GL_FALSE );
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &compressed);
Assert( compressed == intFormat );
// for each mipmap level we generate go ahead and figure up the total memory required
for (i = 0; i < num_mipmaps; i++) {
glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &testing);
compressed_size += testing;
}
out_data = (ubyte*)vm_malloc(compressed_size * sizeof(ubyte));
Assert( out_data != NULL );
memset(out_data, 0, compressed_size * sizeof(ubyte));
// reset compressed_size and go back through each mipmap level to get both size and the image data itself
compressed_size = 0;
for (i = 0; i < num_mipmaps; i++) {
glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &testing);
vglGetCompressedTexImageARB(GL_TEXTURE_2D, i, out_data + compressed_size);
compressed_size += testing;
}
// done with everything so reset hints to default values
if (num_mipmaps > 1) {
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE);
}
glHint(GL_TEXTURE_COMPRESSION_HINT, GL_DONT_CARE);
GL_state.Texture.Disable();
GL_state.Texture.Delete(tex);
glDeleteTextures(1, &tex);
// send the data back out
*compressed_data = out_data;
GL_CHECK_FOR_ERRORS("end of compress_image()");
return compressed_size;
}
void gr_opengl_get_bitmap_from_texture(void* data_out, int bitmap_num)
{
float u,v;
@@ -1208,12 +1318,12 @@ void gr_opengl_get_bitmap_from_texture(void* data_out, int bitmap_num)
tcache_slot_opengl *ts = &Textures[n];
GLenum pixel_format = GL_RGB;
GLenum data_format = GL_UNSIGNED_BYTE;
int bytes_per_pixel = 3 * sizeof(ubyte);
GLenum data_format = GL_FLOAT;
int bytes_per_pixel = 3 * sizeof(float);
if ( bm_has_alpha_channel(bitmap_num) ) {
pixel_format = GL_RGBA;
bytes_per_pixel = 4 * sizeof(ubyte);
bytes_per_pixel = 4 * sizeof(float);
}
opengl_get_texture(ts->texture_target, pixel_format, data_format, 1, ts->w, ts->h, bytes_per_pixel, data_out, 0);
+77 -15
View File
@@ -226,7 +226,7 @@ int gr_opengl_create_stream_buffer_object()
int opengl_create_texture_buffer_object()
{
if ( GLSL_version < 130 || !Is_Extension_Enabled(OGL_ARB_TEXTURE_BUFFER) || !Is_Extension_Enabled(OGL_ARB_FLOATING_POINT_TEXTURES) ) {
if ( Use_GLSL < 3 || !Is_Extension_Enabled(OGL_ARB_TEXTURE_BUFFER) || !Is_Extension_Enabled(OGL_ARB_FLOATING_POINT_TEXTURES) ) {
return -1;
}
@@ -406,7 +406,7 @@ bool gr_opengl_config_buffer(const int buffer_id, vertex_buffer *vb, bool update
}
if (vb->flags & VB_FLAG_MODEL_ID) {
Assert( GLSL_version >= 130 );
Assert( Use_GLSL >= 3 );
Verify( update_ibuffer_only || vb->model_list->submodels != NULL );
vb->stride += (1 * sizeof(GLfloat));
@@ -563,7 +563,7 @@ void gr_opengl_set_buffer(int idx)
GL_state.Array.BindElementBuffer(0);
}
if ( is_minimum_GLSL_version() && !GLSL_override ) {
if ( (Use_GLSL > 1) && !GLSL_override ) {
opengl_shader_set_current();
}
@@ -1342,7 +1342,7 @@ void gr_opengl_render_buffer(int start, const vertex_buffer *bufferp, int texi,
const buffer_data *datap = &bufferp->tex_buf[texi];
if ( is_minimum_GLSL_version() && !GLSL_override ) {
if ( (Use_GLSL > 1) && !GLSL_override ) {
opengl_render_pipeline_program(start, bufferp, datap, flags);
} else {
opengl_render_pipeline_fixed(start, bufferp, datap, flags);
@@ -1837,7 +1837,7 @@ void gr_opengl_end_clip_plane()
return;
}
if ( is_minimum_GLSL_version() ) {
if ( Use_GLSL > 1 ) {
return;
}
@@ -1850,7 +1850,7 @@ void gr_opengl_start_clip_plane()
return;
}
if ( is_minimum_GLSL_version() ) {
if ( Use_GLSL > 1 ) {
// bail since we're gonna clip in the shader
return;
}
@@ -1871,6 +1871,70 @@ void gr_opengl_start_clip_plane()
GL_state.ClipPlane(0, GL_TRUE);
}
//************************************State blocks************************************
//this is an array of reference counts for state block IDs
//static GLuint *state_blocks = NULL;
//static uint n_state_blocks = 0;
//static GLuint current_state_block;
//this is used for places in the array that a state block ID no longer exists
//#define EMPTY_STATE_BOX_REF_COUNT 0xffffffff
int opengl_get_new_state_block_internal()
{
/* uint i;
if (state_blocks == NULL) {
state_blocks = (GLuint*)vm_malloc(sizeof(GLuint));
memset(&state_blocks[n_state_blocks], 'f', sizeof(GLuint));
n_state_blocks++;
}
for (i = 0; i < n_state_blocks; i++) {
if (state_blocks[i] == EMPTY_STATE_BOX_REF_COUNT) {
return i;
}
}
// "i" should be n_state_blocks since we got here.
state_blocks = (GLuint*)vm_realloc(state_blocks, sizeof(GLuint) * i);
memset(&state_blocks[i], 'f', sizeof(GLuint));
n_state_blocks++;
return n_state_blocks-1;*/
return -1;
}
void gr_opengl_start_state_block()
{
/* gr_screen.recording_state_block = true;
current_state_block = opengl_get_new_state_block_internal();
glNewList(current_state_block, GL_COMPILE);*/
}
int gr_opengl_end_state_block()
{
/* //sanity check
if(!gr_screen.recording_state_block)
return -1;
//End the display list
gr_screen.recording_state_block = false;
glEndList();
//now return
return current_state_block;*/
return -1;
}
void gr_opengl_set_state_block(int handle)
{
/* if(handle < 0) return;
glCallList(handle);*/
}
extern bool Glowpoint_override;
bool Glowpoint_override_save;
@@ -2017,14 +2081,18 @@ void opengl_tnl_set_material(int flags, uint shader_flags, int tmap_type)
// 0 == env with non-alpha specmap, 1 == env with alpha specmap
int alpha_spec = bm_has_alpha_channel(SPECMAP) ? 1 : 0;
matrix4 texture_mat;
matrix4 texture_mat, envMatrix;
for ( int i = 0; i < 16; ++i ) {
texture_mat.a1d[i] = GL_env_texture_matrix[i];
}
if (!vm_inverse_matrix4(&texture_mat, &envMatrix)) {
Error(LOCATION, "Unable to invert environment mapping matrix.\n");
}
GL_state.Uniform.setUniformi("alpha_spec", alpha_spec);
GL_state.Uniform.setUniformMatrix4fv("envMatrix", 1, &texture_mat);
GL_state.Uniform.setUniformMatrix4fv("envMatrix", 1, &envMatrix);
GL_state.Uniform.setUniformi("sEnvmap", render_pass);
gr_opengl_tcache_set(ENVMAP, TCACHE_TYPE_CUBEMAP, &u_scale, &v_scale, render_pass);
@@ -2119,7 +2187,7 @@ void opengl_tnl_set_material(int flags, uint shader_flags, int tmap_type)
// Team colors are passed to the shader here, but the shader needs to handle their application.
// By default, this is handled through the r and g channels of the misc map, but this can be changed
// in the shader; test versions of this used the normal map r and b channels
if ( (shader_flags & SDR_FLAG_MODEL_TEAMCOLOR) && (shader_flags & SDR_FLAG_MODEL_MISC_MAP) ) {
if ( shader_flags & SDR_FLAG_MODEL_TEAMCOLOR ) {
vec3d stripe_color;
vec3d base_color;
@@ -2133,12 +2201,6 @@ void opengl_tnl_set_material(int flags, uint shader_flags, int tmap_type)
GL_state.Uniform.setUniform3f("stripe_color", stripe_color);
GL_state.Uniform.setUniform3f("base_color", base_color);
if ( bm_has_alpha_channel(MISCMAP) ) {
GL_state.Uniform.setUniformi("team_glow_enabled", 1);
} else {
GL_state.Uniform.setUniformi("team_glow_enabled", 0);
}
}
if ( shader_flags & SDR_FLAG_MODEL_THRUSTER ) {
+4
View File
@@ -63,6 +63,10 @@ void gr_opengl_set_transform_buffer_offset(int offset);
int gr_opengl_create_stream_buffer_object();
void gr_opengl_render_stream_buffer(int buffer_handle, int offset, int n_verts, int flags);
void gr_opengl_start_state_block();
int gr_opengl_end_state_block();
void gr_opengl_set_state_block(int);
void gr_opengl_set_thrust_scale(float scale = -1.0f);
void gr_opengl_set_team_color(const team_color *colors);
+238 -7
View File
@@ -138,6 +138,18 @@ void gr_stub_destroy_light(int idx)
{
}
void gr_stub_dump_frame()
{
}
void gr_stub_dump_frame_start(int first_frame, int frames_between_dumps)
{
}
void gr_stub_dump_frame_stop()
{
}
void gr_stub_end_clip_plane()
{
}
@@ -154,6 +166,14 @@ void gr_stub_end_view_matrix()
{
}
void gr_stub_fade_in(int instantaneous)
{
}
void gr_stub_fade_out(int instantaneous)
{
}
void gr_stub_flash_alpha(int r, int g, int b, int a)
{
}
@@ -454,6 +474,24 @@ void gr_stub_set_texture_panning(float u, float v, bool enable)
{
}
void gr_stub_setup_background_fog(bool set)
{
}
void gr_stub_start_state_block()
{
gr_screen.recording_state_block = false;
}
int gr_stub_end_state_block()
{
return -1;
}
void gr_stub_set_state_block(int handle)
{
}
void gr_stub_set_line_width(float width)
{
}
@@ -483,6 +521,191 @@ void gr_stub_get_bitmap_from_texture(void* data_out, int bitmap_num)
}
// bitmap functions
int gr_stub_bm_load(BM_TYPE type, int n, const char *filename, CFILE *img_cfp, int *w, int *h, int *bpp, BM_TYPE *c_type, int *mm_lvl, int *size)
{
int dds_ct;
if (type == BM_TYPE_DDS) {
int dds_error = dds_read_header( filename, img_cfp, w, h, bpp, &dds_ct, mm_lvl, size );
if (dds_error != DDS_ERROR_NONE) {
mprintf(("DDS ERROR: Couldn't open '%s' -- %s\n", filename, dds_error_string(dds_error)));
return -1;
}
switch (dds_ct) {
case DDS_DXT1:
*c_type = BM_TYPE_DXT1;
break;
case DDS_DXT3:
*c_type = BM_TYPE_DXT3;
break;
case DDS_DXT5:
*c_type = BM_TYPE_DXT5;
break;
case DDS_UNCOMPRESSED:
*c_type = BM_TYPE_DDS;
break;
case DDS_CUBEMAP_DXT1:
*c_type = BM_TYPE_CUBEMAP_DXT1;
break;
case DDS_CUBEMAP_DXT3:
*c_type = BM_TYPE_CUBEMAP_DXT3;
break;
case DDS_CUBEMAP_DXT5:
*c_type = BM_TYPE_CUBEMAP_DXT5;
break;
case DDS_CUBEMAP_UNCOMPRESSED:
*c_type = BM_TYPE_CUBEMAP_DDS;
break;
default:
Error(LOCATION, "bad DDS file compression. Not using DXT1,3,5 %s", filename);
return -1;
}
}
// if its a tga file
else if (type == BM_TYPE_TGA) {
int tga_error = targa_read_header( filename, img_cfp, w, h, bpp, NULL );
if ( tga_error != TARGA_ERROR_NONE ) {
mprintf(( "tga: Couldn't open '%s'\n", filename ));
return -1;
}
}
// if its a png file
else if (type == BM_TYPE_PNG) {
int png_error=png_read_header( filename, img_cfp, w, h, bpp, NULL );
if ( png_error != PNG_ERROR_NONE ) {
mprintf(( "png: Couldn't open '%s'\n", filename ));
return -1;
}
}
// if its a jpg file
else if (type == BM_TYPE_JPG) {
int jpg_error=jpeg_read_header( filename, img_cfp, w, h, bpp, NULL );
if ( jpg_error != JPEG_ERROR_NONE ) {
mprintf(( "jpg: Couldn't open '%s'\n", filename ));
return -1;
}
}
// if its a pcx file
else if (type == BM_TYPE_PCX) {
int pcx_error = pcx_read_header( filename, img_cfp, w, h, bpp, NULL );
if ( pcx_error != PCX_ERROR_NONE ) {
mprintf(( "pcx: Couldn't open '%s'\n", filename ));
return -1;
}
} else {
Assert( 0 );
return -1;
}
return 0;
}
int gr_stub_bm_lock(const char *filename, int handle, int bitmapnum, ubyte bpp, ubyte flags, bool nodebug)
{
BM_TYPE c_type = BM_TYPE_NONE;
ubyte true_bpp;
bitmap_entry *be = &bm_bitmaps[bitmapnum];
bitmap *bmp = &be->bm;
true_bpp = 8;
// don't do a bpp check here since it could be different in OGL - taylor
if ( bmp->data == 0 ) {
Assert(be->ref_count == 1);
if ( be->type != BM_TYPE_USER ) {
if ( bmp->data == 0 ) {
nprintf (("BmpMan","Loading %s for the first time.\n", be->filename));
}
}
if ( !Bm_paging ) {
if ( be->type != BM_TYPE_USER ) {
nprintf(( "Paging", "Loading %s (%dx%dx%d)\n", be->filename, bmp->w, bmp->h, true_bpp ));
}
}
// select proper format
if(flags & BMP_AABITMAP){
BM_SELECT_ALPHA_TEX_FORMAT();
} else if(flags & BMP_TEX_ANY){
BM_SELECT_TEX_FORMAT();
} else {
BM_SELECT_SCREEN_FORMAT();
}
// make sure we use the real graphic type for EFFs
if ( be->type == BM_TYPE_EFF ) {
c_type = be->info.ani.eff.type;
} else {
c_type = be->type;
}
switch ( c_type ) {
case BM_TYPE_PCX:
bm_lock_pcx( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_ANI:
bm_lock_ani( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_TGA:
bm_lock_tga( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_PNG:
bm_lock_png( handle, bitmapnum, be, bmp, bmp->true_bpp, flags );
break;
case BM_TYPE_JPG:
bm_lock_jpg( handle, bitmapnum, be, bmp, bmp->true_bpp, flags );
break;
case BM_TYPE_DDS:
case BM_TYPE_DXT1:
case BM_TYPE_DXT3:
case BM_TYPE_DXT5:
case BM_TYPE_CUBEMAP_DDS:
case BM_TYPE_CUBEMAP_DXT1:
case BM_TYPE_CUBEMAP_DXT3:
case BM_TYPE_CUBEMAP_DXT5:
bm_lock_dds( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
case BM_TYPE_USER:
bm_lock_user( handle, bitmapnum, be, bmp, true_bpp, flags );
break;
default:
Warning(LOCATION, "Unsupported type in bm_lock -- %d\n", c_type );
return -1;
}
// always go back to screen format
BM_SELECT_SCREEN_FORMAT();
}
// make sure we actually did something
if ( !(bmp->data) ) {
// crap, bail...
return -1;
}
return 0;
}
int gr_stub_bm_make_render_target(int n, int *width, int *height, ubyte *bpp, int *mm_lvl, int flags)
{
return 0;
@@ -509,11 +732,6 @@ void gr_stub_bm_page_in_start()
{
}
bool gr_stub_bm_data(int n, bitmap* bm)
{
return true;
}
int gr_stub_maybe_create_shader(shader_type shader_t, unsigned int flags) {
return -1;
}
@@ -591,6 +809,8 @@ bool gr_stub_init()
gr_screen.gf_set_palette = gr_stub_set_palette;
gr_screen.gf_print_screen = gr_stub_print_screen;
gr_screen.gf_fade_in = gr_stub_fade_in;
gr_screen.gf_fade_out = gr_stub_fade_out;
gr_screen.gf_flash = gr_stub_flash;
gr_screen.gf_flash_alpha = gr_stub_flash_alpha;
@@ -607,6 +827,10 @@ bool gr_stub_init()
gr_screen.gf_restore_screen = gr_stub_restore_screen;
gr_screen.gf_free_screen = gr_stub_free_screen;
gr_screen.gf_dump_frame_start = gr_stub_dump_frame_start;
gr_screen.gf_dump_frame_stop = gr_stub_dump_frame_stop;
gr_screen.gf_dump_frame = gr_stub_dump_frame;
gr_screen.gf_set_gamma = gr_stub_set_gamma;
gr_screen.gf_fog_set = gr_stub_fog_set;
@@ -618,8 +842,9 @@ bool gr_stub_init()
gr_screen.gf_bm_free_data = gr_stub_bm_free_data;
gr_screen.gf_bm_create = gr_stub_bm_create;
gr_screen.gf_bm_init = gr_stub_bm_init;
gr_screen.gf_bm_load = gr_stub_bm_load;
gr_screen.gf_bm_page_in_start = gr_stub_bm_page_in_start;
gr_screen.gf_bm_data = gr_stub_bm_data;
gr_screen.gf_bm_lock = gr_stub_bm_lock;
gr_screen.gf_bm_make_render_target = gr_stub_bm_make_render_target;
gr_screen.gf_bm_set_render_target = gr_stub_bm_set_render_target;
@@ -699,7 +924,13 @@ bool gr_stub_init()
gr_screen.gf_pop_scale_matrix = gr_stub_pop_scale_matrix;
gr_screen.gf_center_alpha = gr_stub_center_alpha;
gr_screen.gf_set_thrust_scale = gr_stub_set_thrust_scale;
gr_screen.gf_setup_background_fog = gr_stub_setup_background_fog;
gr_screen.gf_start_state_block = gr_stub_start_state_block;
gr_screen.gf_end_state_block = gr_stub_end_state_block;
gr_screen.gf_set_state_block = gr_stub_set_state_block;
gr_screen.gf_draw_line_list = gr_stub_draw_line_list;
gr_screen.gf_set_line_width = gr_stub_set_line_width;
+58 -29
View File
@@ -35,6 +35,7 @@
vec3d lock_world_pos;
static float Lock_start_dist;
static int Rotate_time_id = 1; // timer id for controlling how often to rotate triangles around lock indicator
int Missile_track_loop = -1;
int Missile_lock_loop = -1;
@@ -67,6 +68,9 @@ int Lock_gauge_half_h[GR_NUM_RESOLUTIONS] = {
25
};
int Lock_gauge_loaded = 0;
int Lock_gauge_draw = 0;
int Lock_gauge_draw_stamp = -1;
#define LOCK_GAUGE_BLINK_RATE 5 // blinks/sec
int Lockspin_half_w[NUM_HUD_RETICLE_STYLES][GR_NUM_RESOLUTIONS] = {
@@ -102,6 +106,43 @@ void hud_init_missile_lock()
Player_ai->current_target_is_locked = 0;
Player_ai->last_secondary_index = -1;
Rotate_time_id = 1;
// Load in the frames need for the lead indicator
//if (!Lock_gauge_loaded) {
//Commented out due to changes in HUD loading behaviour. These checks are no longer needed at this point.
Lock_gauge_loaded = 1;
Lock_gauge_draw_stamp = -1;
Lock_gauge_draw = 0;
//}
}
void hud_draw_diamond(int x, int y, int width, int height)
{
Assert(height>0);
Assert(width>0);
int x1,x2,x3,x4,y1,y2,y3,y4;
x1=x;
y1=y-height/2;
x2=x+width/2;
y2=y;
x3=x;
y3=y+height/2;
x4=x-width/2;
y4=y;
gr_line(x1,y1,x2,y2);
gr_line(x2,y2,x3,y3);
gr_line(x3,y3,x4,y4);
gr_line(x4,y4,x1,y1);
}
HudGaugeLock::HudGaugeLock():
@@ -156,10 +197,6 @@ void HudGaugeLock::initialize()
Lock_gauge_draw_stamp = -1;
Lock_gauge_draw = 0;
Rotate_time_id = 1;
Last_lock_status = false;
Lock_anim.time_elapsed = 0.0f;
Lock_gauge.time_elapsed = 0.0f;
HudGauge::initialize();
}
@@ -174,15 +211,6 @@ void HudGaugeLock::render(float frametime)
object *targetp;
vertex lock_point;
bool locked = Player_ai->current_target_is_locked ? true : false;
bool reset_timers = false;
if ( locked != Last_lock_status ) {
// check if player lock status has changed since the last frame.
reset_timers = true;
Last_lock_status = locked;
}
if (Player_ai->target_objnum == -1) {
return;
}
@@ -236,27 +264,26 @@ void HudGaugeLock::render(float frametime)
// show the rotating triangles if target is locked
renderLockTriangles(sx, sy, frametime);
if ( reset_timers ) {
Lock_gauge.time_elapsed = 0.0f;
}
} else {
const float scaling_factor = (gr_screen.clip_center_x < gr_screen.clip_center_y) ? (gr_screen.clip_center_x / VIRTUAL_FRAME_HALF_WIDTH) : (gr_screen.clip_center_y / VIRTUAL_FRAME_HALF_HEIGHT);
sx = fl2i(lock_point.screen.xyw.x) - fl2i(i2fl(Player->current_target_sx - Players[Player_num].lock_indicator_x) * scaling_factor);
sy = fl2i(lock_point.screen.xyw.y) - fl2i(i2fl(Player->current_target_sy - Players[Player_num].lock_indicator_y) * scaling_factor);
gr_unsize_screen_pos(&sx, &sy);
if ( reset_timers ) {
Lock_gauge_draw_stamp = -1;
Lock_gauge_draw = 0;
Lock_anim.time_elapsed = 0.0f;
}
}
// show locked indicator
/*
if ( Lock_gauge.first_frame >= 0 ) {
gr_set_bitmap(Lock_gauge.first_frame);
gr_aabitmap(sx - Lock_gauge_half_w[gr_screen.res], sy - Lock_gauge_half_h[gr_screen.res]);
} else {
hud_draw_diamond(sx, sy, Lock_target_box_width[gr_screen.res], Lock_target_box_height[gr_screen.res]);
}
*/
Lock_gauge.sx = sx - Lock_gauge_half_w;
Lock_gauge.sy = sy - Lock_gauge_half_h;
if (Player_ai->current_target_is_locked) {
if(Player_ai->current_target_is_locked){
Lock_gauge.time_elapsed = 0.0f;
hud_anim_render(&Lock_gauge, 0.0f, 1);
} else {
hud_anim_render(&Lock_gauge, frametime, 1);
@@ -293,6 +320,12 @@ void hud_lock_reset(float lock_time_scale)
Player->locking_on_center=0;
Player->locking_subsys_parent=-1;
hud_stop_looped_locking_sounds();
Lock_gauge_draw_stamp = -1;
Lock_gauge_draw = 0;
// reset the lock anim time elapsed
// Lock_anim.time_elapsed = 0.0f;
}
// Determine if the locking code has a point to track
@@ -694,11 +727,7 @@ void HudGaugeLock::renderLockTriangles(int center_x, int center_y, float frameti
// maybe draw the anim
Lock_gauge.time_elapsed = 0.0f;
if(Lock_gauge_draw){
if ( loop_locked_anim ) {
hud_anim_render(&Lock_anim, frametime, 1, 1, 0);
} else {
hud_anim_render(&Lock_anim, frametime, 1, 0, 1);
}
hud_anim_render(&Lock_anim, frametime, 1, 0, 1);
}
}
}
-2
View File
@@ -43,8 +43,6 @@ protected:
int Rotate_time_id;
int Lock_gauge_draw_stamp;
int Lock_gauge_draw;
bool Last_lock_status;
public:
HudGaugeLock();
void initBitmaps(char *lock_gauge_fname, char *lock_anim_fname);
+795 -820
View File
File diff suppressed because it is too large. Load diff
+57 -88
View File
@@ -20,37 +20,6 @@ extern float Hud_speed_multiplier;
#define HUD_RETICLE_STYLE_FS2 1
extern int Hud_reticle_style;
extern bool Scale_retail_gauges;
extern int Force_scaling_above_res_global[2];
extern int Hud_font;
typedef struct gauge_settings {
int base_res[2];
int font_num;
bool scale_gauge;
int force_scaling_above_res[2];
SCP_vector<int>* ship_idx;
color *use_clr;
float origin[2];
int offset[2];
bool use_coords;
int coords[2];
bool set_position;
bool set_colour;
bool slew;
gauge_settings() : font_num(Hud_font), scale_gauge(Scale_retail_gauges), ship_idx(nullptr), use_clr(nullptr), use_coords(false), set_position(true), set_colour(true), slew(false) {
base_res[0] = -1;
base_res[1] = -1;
memcpy(force_scaling_above_res, Force_scaling_above_res_global, sizeof(force_scaling_above_res));
origin[0] = 0.0f;
origin[1] = 0.0f;
offset[0] = 0;
offset[1] = 0;
coords[0] = 0;
coords[1] = 0;
}
} gauge_settings;
//Functions
int hud_get_gauge_index(char* name);
@@ -62,174 +31,174 @@ void check_color(int *colorp);
#define NUM_HUD_OBJECT_ENTRIES 56 // not used anywhere?
int parse_gauge_type();
void load_gauge(int gauge, gauge_settings* settings);
void load_gauge(int gauge, int base_w = -1, int base_h = -1, int font = -1, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_CUSTOM 0
void load_gauge_custom(gauge_settings* settings);
void load_gauge_custom(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_MESSAGES 1
void load_gauge_messages(gauge_settings* settings);
void load_gauge_messages(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_TRAINING_MESSAGES 2
void load_gauge_training_messages(gauge_settings* settings);
void load_gauge_training_messages(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_SUPPORT 3
void load_gauge_support(gauge_settings* settings);
void load_gauge_support(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_DAMAGE 4
void load_gauge_damage(gauge_settings* settings);
void load_gauge_damage(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_WINGMAN_STATUS 5
void load_gauge_wingman_status(gauge_settings* settings);
void load_gauge_wingman_status(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_AUTO_SPEED 6
void load_gauge_auto_speed(gauge_settings* settings);
void load_gauge_auto_speed(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_AUTO_TARGET 7
void load_gauge_auto_target(gauge_settings* settings);
void load_gauge_auto_target(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_CMEASURES 8
void load_gauge_countermeasures(gauge_settings* settings);
void load_gauge_countermeasures(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_TALKING_HEAD 9
void load_gauge_talking_head(gauge_settings* settings);
void load_gauge_talking_head(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_DIRECTIVES 10
void load_gauge_directives(gauge_settings* settings);
void load_gauge_directives(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_WEAPONS 11
void load_gauge_weapons(gauge_settings* settings);
void load_gauge_weapons(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_OBJ_NOTIFY 12
void load_gauge_objective_notify(gauge_settings* settings);
void load_gauge_objective_notify(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_SQUAD_MSG 13
void load_gauge_squad_message(gauge_settings* settings);
void load_gauge_squad_message(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_LAG 14
void load_gauge_lag(gauge_settings* settings);
void load_gauge_lag(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_MINI_SHIELD 15
void load_gauge_mini_shields(gauge_settings* settings);
void load_gauge_mini_shields(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_PLAYER_SHIELD 16
void load_gauge_player_shields(gauge_settings* settings);
void load_gauge_player_shields(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_TARGET_SHIELD 17
void load_gauge_target_shields(gauge_settings* settings);
void load_gauge_target_shields(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_ESCORT 18
void load_gauge_escort_view(gauge_settings* settings);
void load_gauge_escort_view(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_MISSION_TIME 19
void load_gauge_mission_time(gauge_settings* settings);
void load_gauge_mission_time(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_ETS_WEAPONS 20
void load_gauge_ets_weapons(gauge_settings* settings);
void load_gauge_ets_weapons(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_ETS_SHIELDS 21
void load_gauge_ets_shields(gauge_settings* settings);
void load_gauge_ets_shields(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_ETS_ENGINES 22
void load_gauge_ets_engines(gauge_settings* settings);
void load_gauge_ets_engines(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_TARGET_MONITOR 23
void load_gauge_target_monitor(gauge_settings* settings);
void load_gauge_target_monitor(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_EXTRA_TARGET_DATA 24
void load_gauge_extra_target_data(gauge_settings* settings);
void load_gauge_extra_target_data(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_RADAR_STD 25
void load_gauge_radar_std(gauge_settings* settings);
void load_gauge_radar_std(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_RADAR_ORB 26
void load_gauge_radar_orb(gauge_settings* settings);
void load_gauge_radar_orb(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_RADAR_BSG 27
void load_gauge_radar_dradis(gauge_settings* settings);
void load_gauge_radar_dradis(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_AFTERBURNER 28
void load_gauge_afterburner(gauge_settings* settings);
void load_gauge_afterburner(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_WEAPON_ENERGY 29
void load_gauge_weapon_energy(gauge_settings* settings);
void load_gauge_weapon_energy(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_TEXT_WARNINGS 30
void load_gauge_text_warnings(gauge_settings* settings);
void load_gauge_text_warnings(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_CENTER_RETICLE 31
void load_gauge_center_reticle(gauge_settings* settings);
void load_gauge_center_reticle(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_THROTTLE 32
void load_gauge_throttle(gauge_settings* settings);
void load_gauge_throttle(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_THREAT 33
void load_gauge_threat_indicator(gauge_settings* settings);
void load_gauge_threat_indicator(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_LEAD 34
void load_gauge_lead(gauge_settings* settings);
void load_gauge_lead(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_LEAD_SIGHT 35
void load_gauge_lead_sight(gauge_settings* settings);
void load_gauge_lead_sight(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_LOCK 36
void load_gauge_lock(gauge_settings* settings);
void load_gauge_lock(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_WEAPON_LINKING 37
void load_gauge_weapon_linking(gauge_settings* settings);
void load_gauge_weapon_linking(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_MULTI_MSG 38
void load_gauge_multi_msg(gauge_settings* settings);
void load_gauge_multi_msg(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_VOICE_STATUS 39
void load_gauge_voice_status(gauge_settings* settings);
void load_gauge_voice_status(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_PING 40
void load_gauge_ping(gauge_settings* settings);
void load_gauge_ping(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_SUPERNOVA 41
void load_gauge_supernova(gauge_settings* settings);
void load_gauge_supernova(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_OFFSCREEN 42
void load_gauge_offscreen(gauge_settings* settings);
void load_gauge_offscreen(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_BRACKETS 43
void load_gauge_brackets(gauge_settings* settings);
void load_gauge_brackets(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_ORIENTATION_TEE 44
void load_gauge_orientation_tee(gauge_settings* settings);
void load_gauge_orientation_tee(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_HOSTILE_TRI 45
void load_gauge_hostile_tri(gauge_settings* settings);
void load_gauge_hostile_tri(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_TARGET_TRI 46
void load_gauge_target_tri(gauge_settings* settings);
void load_gauge_target_tri(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_MISSILE_TRI 47
void load_gauge_missile_tri(gauge_settings* settings);
void load_gauge_missile_tri(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_KILLS 48
void load_gauge_kills(gauge_settings* settings);
void load_gauge_kills(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_FIXED_MESSAGES 49
void load_gauge_fixed_messages(gauge_settings* settings);
void load_gauge_fixed_messages(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_ETS_RETAIL 50
void load_gauge_ets_retail(gauge_settings* settings);
void load_gauge_ets_retail(int base_w, int base_h, int hud_font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_FLIGHT_PATH 51
void load_gauge_flight_path(gauge_settings* settings);
void load_gauge_flight_path(int base_w, int base_h, int font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_WARHEAD_COUNT 52
void load_gauge_warhead_count(gauge_settings* settings);
void load_gauge_warhead_count(int base_w, int base_h, int font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_HARDPOINTS 53
void load_gauge_hardpoints(gauge_settings* settings);
void load_gauge_hardpoints(int base_w, int base_h, int font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_PRIMARY_WEAPONS 54
void load_gauge_primary_weapons(gauge_settings* settings);
void load_gauge_primary_weapons(int base_w, int base_h, int font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#define HUD_OBJECT_SECONDARY_WEAPONS 55
void load_gauge_secondary_weapons(gauge_settings* settings);
void load_gauge_secondary_weapons(int base_w, int base_h, int font, bool scale_gauge = true, SCP_vector<int>* ship_idx = NULL, color *use_clr = NULL);
#endif // _HUDPARSE_H
+1 -1
View File
@@ -328,7 +328,7 @@ void HudGaugeReticle::getFirepointStatus() {
matrix eye_orient, player_transpose;
vm_copy_transpose(&player_transpose, &Objects[Player->objnum].orient);
vm_copy_transpose_matrix(&player_transpose, &Objects[Player->objnum].orient);
vm_matrix_x_matrix(&eye_orient, &player_transpose, &Eye_matrix);
vm_vec_rotate(&fpfromeye, &pm->gun_banks[i].pnt[j], &eye_orient);
+3 -2
View File
@@ -680,6 +680,7 @@ void HudGaugeShield::showShields(object *objp, int mode)
}
//We're ready to show stuff
ship_model_start(objp);
//if(!digitus_improbus)
{
model_render_params render_info;
@@ -687,7 +688,6 @@ void HudGaugeShield::showShields(object *objp, int mode)
render_info.set_flags(MR_NO_LIGHTING | MR_AUTOCENTER | MR_NO_FOGGING);
render_info.set_replacement_textures(sp->ship_replacement_textures);
render_info.set_detail_level_lock(1);
render_info.set_object_number(OBJ_INDEX(objp));
model_render_immediate( &render_info, sip->model_num, &object_orient, &vmd_zero_vector );
}
@@ -704,6 +704,7 @@ void HudGaugeShield::showShields(object *objp, int mode)
}
model_render(fod_model, &object_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, -1, -1);
}*/
ship_model_stop( objp );
//We're done
if(!Cmdline_nohtl)
@@ -742,7 +743,7 @@ void HudGaugeShield::showShields(object *objp, int mode)
continue;
}
range = MAX(HUD_COLOR_ALPHA_MAX, HUD_color_alpha + objp->n_quadrants);
range = MAX(HUD_COLOR_ALPHA_MAX, HUD_color_alpha + 4);
if ( !(sip->flags2 & SIF2_MODEL_POINT_SHIELDS) )
hud_color_index = fl2i( (objp->shield_quadrant[Quadrant_xlate[i]] / max_shield) * range);
+5 -4
View File
@@ -1792,7 +1792,7 @@ void hud_target_live_turret(int next_flag, int auto_advance, int only_player_tar
if (!auto_advance && get_closest_turret && !only_player_target) {
// if within 3 degrees and not previous subsys, use subsys in front
dot = vm_vec_dot(&vec_to_subsys, &Player_obj->orient.vec.fvec);
dot = vm_vec_dotprod(&vec_to_subsys, &Player_obj->orient.vec.fvec);
if ((dot > 0.9986) && facing) {
use_straight_ahead_turret = TRUE;
break;
@@ -2760,9 +2760,9 @@ void HudGaugeOrientationTee::renderOrientation(object *from_objp, object *to_obj
// 0 - vectors are perpendicular
// 1 - vectors are collinear and in the same direction (target is facing player)
// -1 - vectors are collinear and in the opposite direction (target is facing away from player)
dot_product = vm_vec_dot(&from_orientp->vec.fvec, &target_to_obj);
dot_product = vm_vec_dotprod(&from_orientp->vec.fvec, &target_to_obj);
if (vm_vec_dot(&from_orientp->vec.rvec, &target_to_obj) >= 0) {
if (vm_vec_dotprod(&from_orientp->vec.rvec, &target_to_obj) >= 0) {
if (dot_product >= 0){
dot_product = -PI_2*dot_product + PI;
} else {
@@ -7146,8 +7146,8 @@ void HudGaugeHardpoints::render(float frametime)
render_info.set_color(gauge_color);
render_info.set_detail_level_lock(detail_level_lock);
render_info.set_flags(MR_NO_LIGHTING | MR_AUTOCENTER | MR_NO_FOGGING | MR_NO_TEXTURING | MR_NO_CULL);
render_info.set_object_number(OBJ_INDEX(objp));
ship_model_start(objp);
model_render_immediate( &render_info, sip->model_num, &object_orient, &vmd_zero_vector);
gr_set_color_buffer(1);
@@ -7165,6 +7165,7 @@ void HudGaugeHardpoints::render(float frametime)
&object_orient,
&vmd_zero_vector
);
ship_model_stop( objp );
gr_stencil_set(GR_STENCIL_NONE);
gr_zbuffer_set(zbuffer);
+6 -2
View File
@@ -568,8 +568,8 @@ void HudGaugeTargetBox::renderTargetShip(object *target_objp)
// IMPORTANT NOTE! Code handling the case 'missile_view == TRUE' in rendering section of renderTargetWeapon()
// is largely copied over from renderTargetShip(). To keep the codes similar please update
// both if and when needed
ship_model_start( target_objp );
model_render_params render_info;
render_info.set_object_number(OBJ_INDEX(target_objp));
switch (Targetbox_wire) {
case 0:
@@ -643,6 +643,8 @@ void HudGaugeTargetBox::renderTargetShip(object *target_objp)
Interp_desaturate = false;
Glowpoint_override = false;
ship_model_stop( target_objp );
if ( Monitor_mask >= 0 ) {
gr_stencil_set(GR_STENCIL_NONE);
}
@@ -916,7 +918,7 @@ void HudGaugeTargetBox::renderTargetWeapon(object *target_objp)
break;
}
} else {
render_info.set_object_number(OBJ_INDEX(viewed_obj));
ship_model_start( viewed_obj );
switch (Targetbox_wire) {
case 0:
@@ -1001,6 +1003,8 @@ void HudGaugeTargetBox::renderTargetWeapon(object *target_objp)
if (missile_view == TRUE) {
Glowpoint_override = false;
ship_model_stop( viewed_obj );
}
if ( Monitor_mask >= 0 ) {
+223 -2
View File
@@ -27,6 +27,11 @@
#include "osapi/osapi.h" // for multi-thread macros
#ifndef NDEBUG
#define USE_TIMING
#endif
#ifdef _WIN32
static longlong Timer_last_value = 0, Timer_base = 0, Timer_freq = 0;
static const int precision = 1;
@@ -209,9 +214,9 @@ void timestamp_reset()
// something like 1 minute (6000).
#define MAX_TIME (INT_MAX/2)
void timestamp_inc(int frametime_ms)
void timestamp_inc(float frametime)
{
timestamp_ticker += frametime_ms;
timestamp_ticker += (int)(frametime*TIMESTAMP_FREQUENCY);
if ( timestamp_ticker > MAX_TIME ) {
timestamp_ticker = 2; // Roll!
@@ -283,3 +288,219 @@ int timestamp_has_time_elapsed(int stamp, int time)
return 0;
}
// timing functions -------------------------------------------------------------------------------
#define MAX_TIMING_EVENTS 15
// timing struct
#ifdef USE_TIMING
typedef struct timing {
char name[64];
int microseconds_total;
int start;
int ref_count;
} timing;
timing Timing_frame;
timing Timing_events[MAX_TIMING_EVENTS];
int Timing_event_count = 0;
#endif
// lookup a timing event
int timing_event_lookup(char *event_name)
{
#ifndef USE_TIMING
return -1;
#else
int idx;
// sanity
if(event_name == NULL){
return -1;
}
// look through all events
for(idx=0; idx<MAX_TIMING_EVENTS; idx++){
if(!stricmp(Timing_events[idx].name, event_name)){
return idx;
}
}
return -1;
#endif
}
// start timing frame stuff
void timing_frame_start()
{
#ifndef USE_TIMING
return;
#else
int idx;
// restart the frame
Timing_event_count = 0;
Timing_frame.start = timer_get_microseconds();
for(idx=0; idx<MAX_TIMING_EVENTS; idx++){
Timing_events[idx].microseconds_total = 0;
strcpy_s(Timing_events[idx].name, "");
Timing_events[idx].ref_count = 0;
}
#endif
}
// done timing the frame
void timing_frame_stop()
{
#ifndef USE_TIMING
return;
#else
int stop_time;
// stop time
stop_time = timer_get_microseconds();
// calc times
Timing_frame.microseconds_total = stop_time - Timing_frame.start;
#endif
}
// get the total frame time in microseconds
int timing_frame_total()
{
#ifndef USE_TIMING
return 0;
#else
return Timing_frame.microseconds_total;
#endif
}
// time an individual event
void timing_event_start(char *event_name)
{
#ifndef USE_TIMING
return;
#else
int event;
// sanity
if(event_name == NULL){
return;
}
// try and find the event
event = timing_event_lookup(event_name);
// if we already have one
if(event != -1){
Assert(Timing_events[event].ref_count == 0);
Timing_events[event].start = timer_get_microseconds();
Timing_events[event].ref_count++;
}
// if we need to add a new one
else {
if(Timing_event_count < MAX_TIMING_EVENTS){
strcpy_s(Timing_events[Timing_event_count].name, event_name);
Timing_events[Timing_event_count].start = timer_get_microseconds();
Timing_events[Timing_event_count++].ref_count++;
}
}
#endif
}
// stop timing an event
void timing_event_stop(char *event_name)
{
#ifndef USE_TIMING
return;
#else
int event;
// sanity
if(event_name == NULL){
return;
}
// try and find the event
event = timing_event_lookup(event_name);
// if we already have one
if(event != -1){
Assert(Timing_events[event].ref_count == 1);
Timing_events[event].microseconds_total += timer_get_microseconds() - Timing_events[event].start;
Timing_events[event].ref_count--;
}
#endif
}
// get the total time for an event in microseconds
int timing_event_total(char *event_name)
{
#ifndef USE_TIMING
return -1;
#else
int event;
// sanity
if(event_name == NULL){
return -1;
}
// try and find the event
event = timing_event_lookup(event_name);
if(event == -1){
return -1;
}
return Timing_events[event].microseconds_total;
#endif
}
// get the percentage of total frametime for the event (0.0 to 1.0)
float timing_event_pct(char *event_name)
{
#ifndef USE_TIMING
return 0.0f;
#else
int event;
// sanity
if(event_name == NULL){
return -1.0f;
}
// try and find the event
event = timing_event_lookup(event_name);
if(event == -1){
return -1.0f;
}
return (float)((double)Timing_events[event].microseconds_total / (double)Timing_frame.microseconds_total);
#endif
}
// display timing
void timing_display(int x, int y)
{
#ifndef USE_TIMING
return;
#else
int idx;
int line_height = gr_get_font_height() + 1;
gr_set_color_fast(&Color_bright_blue);
// total time
gr_printf_no_resize(x, y, "Total time %f\n", (float)timing_frame_total() / 1000000.0f);
y += line_height;
// each event percentage
for(idx=0; idx<Timing_event_count; idx++){
gr_printf_no_resize(x, y, "%s: %f\n", Timing_events[idx].name, timing_event_pct(Timing_events[idx].name));
y += line_height;
}
#endif
}
+33 -1
View File
@@ -28,6 +28,8 @@
extern void timer_init();
extern void timer_close();
extern void timer_set_rate(int count_val);
extern void timer_set_function( void * function );
//==========================================================================
// These functions return the time since the timer was initialized in
@@ -46,6 +48,10 @@ extern uint timer_get_high_res_microseconds();
extern int timer_get_seconds(); // seconds since program started... not accurate, but good for long
// runtimes with second-based timeouts
//==========================================================================
// Use to access the BIOS ticker... ie... i = TICKER
void timer_delay(fix seconds);
//=================================================================
//=================================================================
@@ -67,7 +73,7 @@ extern int timestamp_ticker;
extern void timestamp_reset();
// Call this once every frame with the frametime.
extern void timestamp_inc(int frametime_ms);
extern void timestamp_inc(float frametime);
// To do timing, call this with the interval you
// want to check. Then, pass this to timestamp_elapsed
@@ -114,4 +120,30 @@ int timestamp_has_time_elapsed(int stamp, int time);
#define timestamp_elapsed_safe(_a, _b) ( (_a != 0) ? (((timestamp_ticker >= (_a)) || (timestamp_ticker < (_a - (_b + 100)))) ? 1 : 0) : 1 )
// timing functions -------------------------------------------------------------------------------
// start timing frame stuff
void timing_frame_start();
// done timing the frame
void timing_frame_stop();
// get the total frame time in microseconds
int timing_frame_total();
// time an individual event
void timing_event_start(char *event_name);
// stop timing an event
void timing_event_stop(char *event_name);
// get the total time for an event in microseconds
int timing_event_total(char *event_name);
// get the percentage of total frametime for the event (0.0 to 1.0)
float timing_event_pct(char *event_name);
// display timing
void timing_display(int x, int y);
#endif
+3 -1
View File
@@ -1907,6 +1907,8 @@ void labviewer_close_render_options_window(GUIObject *caller)
y += cbp->GetHeight() + 1; \
}
extern int Use_GLSL;
void labviewer_make_render_options_window(Button *caller)
{
Checkbox *cbp;
@@ -1928,7 +1930,7 @@ void labviewer_make_render_options_window(Button *caller)
ADD_RENDER_FLAG("Show Insignia", Lab_viewer_flags, LAB_FLAG_SHOW_INSIGNIA);
ADD_RENDER_FLAG("Show Damage Lightning", Lab_viewer_flags, LAB_FLAG_LIGHTNING_ARCS);
ADD_RENDER_FLAG("Rotate Subsystems", Lab_viewer_flags, LAB_FLAG_SUBMODEL_ROTATE);
if (is_minimum_GLSL_version()) {
if (Use_GLSL) {
ADD_RENDER_BOOL("Fixed Render Pipeline", GLSL_override);
if (Cmdline_postprocess) {
ADD_RENDER_BOOL("Hide Post Processing", PostProcessing_override);
+5 -4
View File
@@ -340,6 +340,7 @@ void light_add_point_unique(const vec3d *pos, float r1, float r2, float intensit
}
// beams affect every ship except the firing ship
extern int Use_GLSL;
void light_add_tube(const vec3d *p0, const vec3d *p1, float r1, float r2, float intensity, float r, float g, float b, int affected_objnum, float spec_r, float spec_g, float spec_b, bool specular)
{
Assert(r1 >0);
@@ -376,8 +377,8 @@ void light_add_tube(const vec3d *p0, const vec3d *p1, float r1, float r2, float
l->radb = r2;
l->rada_squared = l->rada*l->rada;
l->radb_squared = l->radb*l->radb;
l->light_ignore_objnum = is_minimum_GLSL_version() ? affected_objnum : -1;
l->affected_objnum = is_minimum_GLSL_version() ? -1 : affected_objnum;
l->light_ignore_objnum = Use_GLSL>1 ?affected_objnum : -1;
l->affected_objnum = Use_GLSL>1 ? -1 : affected_objnum;
l->instance = Num_lights-1;
Assert( Num_light_levels <= 1 );
@@ -474,7 +475,7 @@ int light_filter_push( int objnum, const vec3d *pos, float rad )
// hmm. this could probably be more optimal
case LT_TUBE:
if(is_minimum_GLSL_version()) {
if(Use_GLSL > 1) {
if(l->light_ignore_objnum != objnum){
vec3d nearest;
float dist_squared, max_dist_squared;
@@ -1159,7 +1160,7 @@ void scene_lights::setLightFilter(int objnum, const vec3d *pos, float rad)
}
break;
case LT_TUBE: {
if ( is_minimum_GLSL_version() ) {
if ( Use_GLSL > 1 ) {
if ( l.light_ignore_objnum != objnum ) {
vec3d nearest;
float dist_squared, max_dist_squared;
+25 -22
View File
@@ -18,7 +18,7 @@
#define UNINITIALIZED_VALUE -1234567.8f
#define WARN_DIST 1.0
static void accurate_square_root( float A, float B, float C, float discriminant, float *root1, float *root2 ) __UNUSED;
static void accurate_square_root( float A, float B, float C, float discriminant, float *root1, float *root2 );
static float matrix_determinant_from_vectors(const vec3d *v1, const vec3d *v2, const vec3d *v3)
{
@@ -42,7 +42,7 @@ static float matrix_determinant_from_vectors(const vec3d *v1, const vec3d *v2, c
void fvi_two_lines_in_3space(const vec3d *p1, const vec3d *v1, const vec3d *p2, const vec3d *v2, float *s, float *t)
{
vec3d cross,delta;
vm_vec_cross(&cross, v1, v2);
vm_vec_crossprod(&cross, v1, v2);
vm_vec_sub(&delta, p2, p1);
float denominator = vm_vec_mag_squared(&cross);
@@ -520,9 +520,9 @@ int fvi_sphere_plane(vec3d *intersect_point, const vec3d *sphere_center_start, c
float t1, t2;
// find the time and position of the ray-plane intersection
D = -vm_vec_dot( plane_normal, plane_point );
xs0_dot_norm = vm_vec_dot( plane_normal, sphere_center_start );
vs_dot_norm = vm_vec_dot( plane_normal, sphere_velocity);
D = -vm_vec_dotprod( plane_normal, plane_point );
xs0_dot_norm = vm_vec_dotprod( plane_normal, sphere_center_start );
vs_dot_norm = vm_vec_dotprod( plane_normal, sphere_velocity);
// protect against divide by zero
if (fl_abs(vs_dot_norm) > 1e-30) {
@@ -589,7 +589,7 @@ int fvi_sphere_perp_edge(vec3d *intersect_point, const vec3d *sphere_center_star
vm_vec_copy_normalize( &x_hat, &edge_velocity );
vm_vec_copy_normalize( &y_hat, sphere_velocity );
vm_vec_cross( &z_hat, &x_hat, &y_hat );
vm_vec_crossprod( &z_hat, &x_hat, &y_hat );
max_edge_parameter = vm_vec_mag( &edge_velocity );
vec3d temp;
@@ -606,9 +606,9 @@ int fvi_sphere_perp_edge(vec3d *intersect_point, const vec3d *sphere_center_star
vm_project_point_onto_plane(&Xs_proj, sphere_center_start, &z_hat, &V0);
vec3d plane_coord;
plane_coord.xyz.x = vm_vec_dot(&Xs_proj, &x_hat);
plane_coord.xyz.y = vm_vec_dot(&Xe_proj, &y_hat);
plane_coord.xyz.z = vm_vec_dot(&Xe_proj, &z_hat);
plane_coord.xyz.x = vm_vec_dotprod(&Xs_proj, &x_hat);
plane_coord.xyz.y = vm_vec_dotprod(&Xe_proj, &y_hat);
plane_coord.xyz.z = vm_vec_dotprod(&Xe_proj, &z_hat);
// determime the position on the edge line
vm_vec_copy_scale( intersect_point, &x_hat, plane_coord.xyz.x );
@@ -620,7 +620,7 @@ int fvi_sphere_perp_edge(vec3d *intersect_point, const vec3d *sphere_center_star
vec3d temp_vec;
vm_vec_sub( &temp_vec, intersect_point, &V0 );
edge_parameter = vm_vec_dot( &temp_vec, &x_hat );
edge_parameter = vm_vec_dotprod( &temp_vec, &x_hat );
if ( edge_parameter < 0 || edge_parameter > max_edge_parameter ) {
return 0;
@@ -647,7 +647,7 @@ static int check_sphere_point(const vec3d *point, const vec3d *sphere_start, con
vm_vec_sub( &delta_x, sphere_start, point );
delta_x_sqr = vm_vec_mag_squared( &delta_x );
vs_sqr = vm_vec_mag_squared( sphere_vel );
delta_x_dot_vs = vm_vec_dot( &delta_x, sphere_vel );
delta_x_dot_vs = vm_vec_dotprod( &delta_x, sphere_vel );
float discriminant = delta_x_dot_vs*delta_x_dot_vs - vs_sqr*(delta_x_sqr - radius*radius);
if (discriminant < 0) {
@@ -726,10 +726,10 @@ int fvi_polyedge_sphereline(vec3d *hit_point, const vec3d *xs0, const vec3d *vs,
// First find the closest intersection between the edge_line and the sphere_line.
vm_vec_sub(&delta_x, xs0, &v0);
delta_x_dot_ve = vm_vec_dot(&delta_x, &ve);
delta_x_dot_vs = vm_vec_dot(&delta_x, vs);
delta_x_dot_ve = vm_vec_dotprod(&delta_x, &ve);
delta_x_dot_vs = vm_vec_dotprod(&delta_x, vs);
delta_x_sqr = vm_vec_mag_squared(&delta_x);
ve_dot_vs = vm_vec_dot(&ve, vs);
ve_dot_vs = vm_vec_dotprod(&ve, vs);
ve_sqr = vm_vec_mag_squared(&ve);
/*
@@ -858,7 +858,7 @@ TryVertex:
// try V1
vm_vec_sub( &delta_x, xs0, &v1 );
delta_x_sqr = vm_vec_mag_squared( &delta_x );
delta_x_dot_vs = vm_vec_dot( &delta_x, vs );
delta_x_dot_vs = vm_vec_dotprod( &delta_x, vs );
int v1_hit;
B = delta_x_dot_vs;
@@ -939,7 +939,7 @@ void fvi_closest_point_on_line_segment(vec3d *closest_point, const vec3d *fixed_
vm_vec_sub(&line_velocity, line_point2, line_point1);
vm_vec_sub(&delta_x, line_point1, fixed_point);
t = -vm_vec_dot(&delta_x, &line_velocity) / vm_vec_mag_squared(&line_velocity);
t = -vm_vec_dotprod(&delta_x, &line_velocity) / vm_vec_mag_squared(&line_velocity);
// Constrain t to be in range [0,1]
if (t < 0) {
@@ -992,7 +992,7 @@ int fvi_check_sphere_sphere(const vec3d *x_p0, const vec3d *x_p1, const vec3d *x
vm_vec_add2(&delta_v, x_p0);
vm_vec_sub2(&delta_v, x_p1);
delta_x_dot_delta_v = vm_vec_dot(&delta_x, &delta_v);
delta_x_dot_delta_v = vm_vec_dotprod(&delta_x, &delta_v);
delta_v_sqr = vm_vec_mag_squared(&delta_v);
discriminant = delta_x_dot_delta_v*delta_x_dot_delta_v - delta_v_sqr*(delta_x_sqr - separation*separation);
@@ -1068,17 +1068,19 @@ void fvi_closest_line_line(const vec3d *x0, const vec3d *vx, const vec3d *y0, co
vm_vec_sub(&delta_l, y0, x0);
vm_vec_cross(&vx_cross_vy, vx, vy);
vm_vec_cross(&delta_l_cross_vx, &delta_l, vx);
vm_vec_cross(&delta_l_cross_vy, &delta_l, vy);
vm_vec_crossprod(&vx_cross_vy, vx, vy);
vm_vec_crossprod(&delta_l_cross_vx, &delta_l, vx);
vm_vec_crossprod(&delta_l_cross_vy, &delta_l, vy);
denominator = vm_vec_mag_squared(&vx_cross_vy);
*x_time = vm_vec_dot(&delta_l_cross_vy, &vx_cross_vy) / denominator;
*y_time = vm_vec_dot(&delta_l_cross_vx, &vx_cross_vy) / denominator;
*x_time = vm_vec_dotprod(&delta_l_cross_vy, &vx_cross_vy) / denominator;
*y_time = vm_vec_dotprod(&delta_l_cross_vx, &vx_cross_vy) / denominator;
}
// --------------------------------------------------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
static void accurate_square_root( float A, float B, float C, float discriminant, float *root1, float *root2 )
{
float root = fl_sqrt(discriminant);
@@ -1091,6 +1093,7 @@ static void accurate_square_root( float A, float B, float C, float discriminant,
*root2 = 2.0f*C / (-B + root);
}
}
#pragma GCC diagnostic pop
/**
* Project point on bounding box
+126 -126
View File
@@ -29,8 +29,6 @@ matrix vmd_identity_matrix = IDENTITY_MATRIX;
#define UNINITIALIZED_VALUE -12345678.9f
static void rotate_z ( matrix *m, float theta ) __UNUSED;
bool vm_vec_equal(const vec4 &self, const vec4 &other)
{
return fl_equal(self.a1d[0], other.a1d[0]) && fl_equal(self.a1d[1], other.a1d[1]) && fl_equal(self.a1d[2], other.a1d[2]) && fl_equal(self.a1d[3], other.a1d[3]);
@@ -99,7 +97,7 @@ float vm_vec_projection_parallel(vec3d *component, const vec3d *src, const vec3d
float mag;
Assert( vm_vec_mag(unit_vec) > 0.999f && vm_vec_mag(unit_vec) < 1.001f );
mag = vm_vec_dot(src, unit_vec);
mag = vm_vec_dotprod(src, unit_vec);
vm_vec_copy_scale(component, unit_vec, mag);
return mag;
}
@@ -114,7 +112,7 @@ void vm_vec_projection_onto_plane(vec3d *projection, const vec3d *src, const vec
float mag;
Assert( vm_vec_mag(unit_normal) > 0.999f && vm_vec_mag(unit_normal) < 1.001f );
mag = vm_vec_dot(src, unit_normal);
mag = vm_vec_dotprod(src, unit_normal);
*projection = *src;
vm_vec_scale_add2(projection, unit_normal, -mag);
}
@@ -131,8 +129,8 @@ void vm_project_point_onto_plane(vec3d *new_point, const vec3d *point, const vec
float dist;
Assert( vm_vec_mag(plane_normal) > 0.999f && vm_vec_mag(plane_normal) < 1.001f );
D = -vm_vec_dot(plane_point, plane_normal);
dist = vm_vec_dot(point, plane_normal) + D;
D = -vm_vec_dotprod(plane_point, plane_normal);
dist = vm_vec_dotprod(point, plane_normal) + D;
*new_point = *point;
vm_vec_scale_add2(new_point, plane_normal, -dist);
@@ -309,7 +307,7 @@ void vm_vec_scale2(vec3d *dest, float n, float d)
}
//returns dot product of 2 vectors
float vm_vec_dot(const vec3d *v0, const vec3d *v1)
float vm_vec_dotprod(const vec3d *v0, const vec3d *v1)
{
return (v1->xyz.x*v0->xyz.x)+(v1->xyz.y*v0->xyz.y)+(v1->xyz.z*v0->xyz.z);
}
@@ -642,7 +640,7 @@ vec3d *vm_vec_normal(vec3d *dest, const vec3d *p0, const vec3d *p1, const vec3d
//product of the magnitudes of the two source vectors. This means it is
//quite easy for this routine to overflow and underflow. Be careful that
//your inputs are ok.
vec3d *vm_vec_cross(vec3d *dest, const vec3d *src0, const vec3d *src1)
vec3d *vm_vec_crossprod(vec3d *dest, const vec3d *src0, const vec3d *src1)
{
dest->xyz.x = (src0->xyz.y * src1->xyz.z) - (src0->xyz.z * src1->xyz.y);
dest->xyz.y = (src0->xyz.z * src1->xyz.x) - (src0->xyz.x * src1->xyz.z);
@@ -675,7 +673,7 @@ vec3d *vm_vec_perp(vec3d *dest, const vec3d *p0, const vec3d *p1,const vec3d *p2
vm_vec_sub(&t0,p1,p0);
vm_vec_sub(&t1,p2,p1);
return vm_vec_cross(dest,&t0,&t1);
return vm_vec_crossprod(dest,&t0,&t1);
}
@@ -712,7 +710,7 @@ float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1, const vec3d *fvec)
if (fvec) {
vm_vec_cross(&t,v0,v1);
if ( vm_vec_dot(&t,fvec) < 0.0 ) {
if ( vm_vec_dotprod(&t,fvec) < 0.0 ) {
a = -a;
}
}
@@ -837,7 +835,7 @@ void vm_vector_2_matrix_gen_vectors(matrix *m)
vm_vec_normalize(xvec);
vm_vec_cross(yvec,zvec,xvec);
vm_vec_crossprod(yvec,zvec,xvec);
}
}
@@ -864,25 +862,25 @@ matrix *vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, cons
else { //use right vec
vm_vec_copy_normalize(xvec,rvec);
vm_vec_cross(yvec,zvec,xvec);
vm_vec_crossprod(yvec,zvec,xvec);
//normalize new perpendicular vector
vm_vec_normalize(yvec);
//now recompute right vector, in case it wasn't entirely perpendiclar
vm_vec_cross(xvec,yvec,zvec);
vm_vec_crossprod(xvec,yvec,zvec);
}
}
else { //use up vec
vm_vec_copy_normalize(yvec,uvec);
vm_vec_cross(xvec,yvec,zvec);
vm_vec_crossprod(xvec,yvec,zvec);
//normalize new perpendicular vector
vm_vec_normalize(xvec);
//now recompute up vector, in case it wasn't entirely perpendiclar
vm_vec_cross(yvec,zvec,xvec);
vm_vec_crossprod(yvec,zvec,xvec);
}
return m;
}
@@ -903,23 +901,23 @@ matrix *vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec,
vm_vector_2_matrix_gen_vectors(m);
}
else { //use right vec
vm_vec_cross(yvec,zvec,xvec);
vm_vec_crossprod(yvec,zvec,xvec);
//normalize new perpendicular vector
vm_vec_normalize(yvec);
//now recompute right vector, in case it wasn't entirely perpendiclar
vm_vec_cross(xvec,yvec,zvec);
vm_vec_crossprod(xvec,yvec,zvec);
}
}
else { //use up vec
vm_vec_cross(xvec,yvec,zvec);
vm_vec_crossprod(xvec,yvec,zvec);
//normalize new perpendicular vector
vm_vec_normalize(xvec);
//now recompute up vector, in case it wasn't entirely perpendiclar
vm_vec_cross(yvec,zvec,xvec);
vm_vec_crossprod(yvec,zvec,xvec);
}
return m;
}
@@ -945,7 +943,7 @@ vec3d *vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m)
//returns ptr to dest vector
//dest CANNOT equal source
// This is a faster replacement for this common code sequence:
// vm_copy_transpose(&tempm,src_matrix);
// vm_copy_transpose_matrix(&tempm,src_matrix);
// vm_vec_rotate(dst_vec,src_vect,&tempm);
// Replace with:
// vm_vec_unrotate(dst_vec,src_vect, src_matrix)
@@ -968,7 +966,7 @@ vec3d *vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m)
}
//transpose a matrix in place. returns ptr to matrix
matrix *vm_transpose(matrix *m)
matrix *vm_transpose_matrix(matrix *m)
{
float t;
@@ -980,8 +978,8 @@ matrix *vm_transpose(matrix *m)
}
//copy and transpose a matrix. returns ptr to matrix
//dest CANNOT equal source. use vm_transpose() if this is the case
matrix *vm_copy_transpose(matrix *dest, const matrix *src)
//dest CANNOT equal source. use vm_transpose_matrix() if this is the case
matrix *vm_copy_transpose_matrix(matrix *dest, const matrix *src)
{
Assert(dest != src);
@@ -1262,7 +1260,7 @@ void vm_orthogonalize_matrix(matrix *m_src)
vm_vec_make(&m->vec.uvec, 0.0f, 1.0f, 0.0f);
} else { // use the right vector to figure up vector
vm_vec_cross(&m->vec.uvec, &m->vec.fvec, &m_src->vec.rvec);
vm_vec_crossprod(&m->vec.uvec, &m->vec.fvec, &m_src->vec.rvec);
vm_vec_normalize(&m->vec.uvec);
}
@@ -1271,13 +1269,13 @@ void vm_orthogonalize_matrix(matrix *m_src)
}
// use forward and up vectors as good vectors to calculate right vector
vm_vec_cross(&m->vec.rvec, &m->vec.uvec, &m->vec.fvec);
vm_vec_crossprod(&m->vec.rvec, &m->vec.uvec, &m->vec.fvec);
//normalize new perpendicular vector
vm_vec_normalize(&m->vec.rvec);
//now recompute up vector, in case it wasn't entirely perpendicular
vm_vec_cross(&m->vec.uvec, &m->vec.fvec, &m->vec.rvec);
vm_vec_crossprod(&m->vec.uvec, &m->vec.fvec, &m->vec.rvec);
*m_src = tempm;
}
@@ -1292,7 +1290,7 @@ void vm_fix_matrix(matrix *m)
rmag = vm_vec_mag(&m->vec.rvec);
if (fmag <= 0.0f) {
if ((umag > 0.0f) && (rmag > 0.0f) && !vm_test_parallel(&m->vec.uvec, &m->vec.rvec)) {
vm_vec_cross(&m->vec.fvec, &m->vec.uvec, &m->vec.rvec);
vm_vec_crossprod(&m->vec.fvec, &m->vec.uvec, &m->vec.rvec);
vm_vec_normalize(&m->vec.fvec);
} else if (umag > 0.0f) {
@@ -1315,7 +1313,7 @@ void vm_fix_matrix(matrix *m)
vm_vec_make(&m->vec.uvec, 0.0f, 1.0f, 0.0f);
} else { // use the right vector to figure up vector
vm_vec_cross(&m->vec.uvec, &m->vec.fvec, &m->vec.rvec);
vm_vec_crossprod(&m->vec.uvec, &m->vec.fvec, &m->vec.rvec);
vm_vec_normalize(&m->vec.uvec);
}
@@ -1324,13 +1322,13 @@ void vm_fix_matrix(matrix *m)
// we now have both valid and normalized forward and up vectors
vm_vec_cross(&m->vec.rvec, &m->vec.uvec, &m->vec.fvec);
vm_vec_crossprod(&m->vec.rvec, &m->vec.uvec, &m->vec.fvec);
//normalize new perpendicular vector
vm_vec_normalize(&m->vec.rvec);
//now recompute up vector, in case it wasn't entirely perpendiclar
vm_vec_cross(&m->vec.uvec, &m->vec.fvec, &m->vec.rvec);
vm_vec_crossprod(&m->vec.uvec, &m->vec.fvec, &m->vec.rvec);
}
//Rotates the orient matrix by the angles in tangles and then
@@ -1583,6 +1581,8 @@ void vm_quaternion_rotate(matrix *M, float theta, const vec3d *u)
// inputs: m => point to resultant rotation matrix
// angle => rotation angle about z axis (in radians)
//
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
static void rotate_z ( matrix *m, float theta )
{
m->vec.rvec.xyz.x = cosf (theta);
@@ -1597,6 +1597,7 @@ static void rotate_z ( matrix *m, float theta )
m->vec.fvec.xyz.y = 0.0f;
m->vec.fvec.xyz.z = 1.0f;
}
#pragma GCC diagnostic pop
// --------------------------------------------------------------------------------------
@@ -1868,7 +1869,7 @@ void vm_matrix_interpolate(const matrix *goal_orient, const matrix *curr_orient,
// FIND ROTATION NEEDED FOR GOAL
// goal_orient = R curr_orient, so R = goal_orient curr_orient^-1
vm_copy_transpose(&Mtemp1, curr_orient); // Mtemp1 = curr ^-1
vm_copy_transpose_matrix(&Mtemp1, curr_orient); // Mtemp1 = curr ^-1
vm_matrix_x_matrix(&rot_matrix, &Mtemp1, goal_orient); // R = goal * Mtemp1
vm_orthogonalize_matrix(&rot_matrix);
vm_matrix_to_rot_axis_and_angle(&rot_matrix, &theta, &rot_axis); // determines angle and rotation axis from curr to goal
@@ -2010,7 +2011,7 @@ void get_camera_limits(const matrix *start_camera, const matrix *end_camera, flo
vec3d angle;
// determine the necessary rotation matrix
vm_copy_transpose(&temp, start_camera);
vm_copy_transpose_matrix(&temp, start_camera);
vm_matrix_x_matrix(&rot_matrix, &temp, end_camera);
vm_orthogonalize_matrix(&rot_matrix);
@@ -2075,13 +2076,13 @@ void vm_forward_interpolate(const vec3d *goal_f, const matrix *orient, const vec
// FIND ROTATION NEEDED FOR GOAL
// rotation vector is (current fvec) orient->vec.fvec x goal_f
// magnitude = asin ( magnitude of crossprod )
vm_vec_cross( &rot_axis, &orient->vec.fvec, goal_f );
vm_vec_crossprod( &rot_axis, &orient->vec.fvec, goal_f );
float t = vm_vec_mag(&rot_axis);
if (t > 1.0f)
t = 1.0f;
z_dotprod = vm_vec_dot( &orient->vec.fvec, goal_f );
z_dotprod = vm_vec_dotprod( &orient->vec.fvec, goal_f );
if ( t < SMALLER_NUM ) {
if ( z_dotprod > 0.0f )
@@ -2380,7 +2381,7 @@ void vm_estimate_next_orientation(const matrix *last_orient, const matrix *curre
matrix Mtemp;
matrix Rot_matrix;
vm_copy_transpose(&Mtemp, last_orient); // Mtemp = (L)^-1
vm_copy_transpose_matrix(&Mtemp, last_orient); // Mtemp = (L)^-1
vm_matrix_x_matrix(&Rot_matrix, &Mtemp, current_orient); // R = C Mtemp1
vm_matrix_x_matrix(next_orient, current_orient, &Rot_matrix);
}
@@ -2404,7 +2405,7 @@ void vm_vec_interp_constant(vec3d *out, const vec3d *v0, const vec3d *v1, float
float total_ang;
// get the cross-product of the 2 vectors
vm_vec_cross(&cross, v0, v1);
vm_vec_crossprod(&cross, v0, v1);
vm_vec_normalize(&cross);
// get the total angle between the 2 vectors
@@ -2518,7 +2519,7 @@ int vm_vec_dist_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d
b_mag = vm_vec_copy_normalize(&c, &b);
// calculate component
comp = vm_vec_dot(&a, &b) / b_mag;
comp = vm_vec_dotprod(&a, &b) / b_mag;
// stuff nearest
vm_vec_scale_add(nearest, l0, &c, comp);
@@ -2558,7 +2559,7 @@ void vm_vec_dist_squared_to_line(const vec3d *p, const vec3d *l0, const vec3d *l
b_mag = vm_vec_copy_normalize(&c, &b);
// calculate component
comp = vm_vec_dot(&a, &b) / b_mag;
comp = vm_vec_dotprod(&a, &b) / b_mag;
// stuff nearest
vm_vec_scale_add(nearest, l0, &c, comp);
@@ -2576,132 +2577,131 @@ void vm_vec_boxscale(vec2d *vec, float scale)
vec->y *= ratio;
}
// TODO Remove this function if we ever move to a math library like glm
/**
* @brief Attempts to invert a 4x4 matrix
* @param[in] m Pointer to the matrix we want to invert
* @param[inout] invOut The inverted matrix, or nullptr if inversion is impossible
*
* @returns Whether or not the matrix is invertible
*/
* @brief Attempts to invert a 4x4 matrix
* @param[in] m Pointer to the matrix we want to invert
* @param[inout] invOut The inverted matrix, or nullptr if inversion is impossible
*
* @returns Whether or not the matrix is invertible
*/
bool vm_inverse_matrix4(const matrix4 *m, matrix4 *invOut)
{
matrix4 inv; // create a temp matrix so we can avoid getting a determinant that is 0
float det;
int i, j;
int i,j;
// Use a2d so it's easier for people to read
inv.a2d[0][0] = m->a2d[1][1] * m->a2d[2][2] * m->a2d[3][3] -
m->a2d[1][1] * m->a2d[2][3] * m->a2d[3][2] -
m->a2d[2][1] * m->a2d[1][2] * m->a2d[3][3] +
m->a2d[2][1] * m->a2d[1][3] * m->a2d[3][2] +
m->a2d[3][1] * m->a2d[1][2] * m->a2d[2][3] -
m->a2d[3][1] * m->a2d[1][3] * m->a2d[2][2];
m->a2d[1][1] * m->a2d[2][3] * m->a2d[3][2] -
m->a2d[2][1] * m->a2d[1][2] * m->a2d[3][3] +
m->a2d[2][1] * m->a2d[1][3] * m->a2d[3][2] +
m->a2d[3][1] * m->a2d[1][2] * m->a2d[2][3] -
m->a2d[3][1] * m->a2d[1][3] * m->a2d[2][2];
inv.a2d[1][0] = -m->a2d[1][0] * m->a2d[2][2] * m->a2d[3][3] +
m->a2d[1][0] * m->a2d[2][3] * m->a2d[3][2] +
m->a2d[2][0] * m->a2d[1][2] * m->a2d[3][3] -
m->a2d[2][0] * m->a2d[1][3] * m->a2d[3][2] -
m->a2d[3][0] * m->a2d[1][2] * m->a2d[2][3] +
m->a2d[3][0] * m->a2d[1][3] * m->a2d[2][2];
m->a2d[1][0] * m->a2d[2][3] * m->a2d[3][2] +
m->a2d[2][0] * m->a2d[1][2] * m->a2d[3][3] -
m->a2d[2][0] * m->a2d[1][3] * m->a2d[3][2] -
m->a2d[3][0] * m->a2d[1][2] * m->a2d[2][3] +
m->a2d[3][0] * m->a2d[1][3] * m->a2d[2][2];
inv.a2d[2][0] = m->a2d[1][0] * m->a2d[2][1] * m->a2d[3][3] -
m->a2d[1][0] * m->a2d[2][3] * m->a2d[3][1] -
m->a2d[2][0] * m->a2d[1][1] * m->a2d[3][3] +
m->a2d[2][0] * m->a2d[1][3] * m->a2d[3][1] +
m->a2d[3][0] * m->a2d[1][1] * m->a2d[2][3] -
m->a2d[3][0] * m->a2d[1][3] * m->a2d[2][1];
m->a2d[1][0] * m->a2d[2][3] * m->a2d[3][1] -
m->a2d[2][0] * m->a2d[1][1] * m->a2d[3][3] +
m->a2d[2][0] * m->a2d[1][3] * m->a2d[3][1] +
m->a2d[3][0] * m->a2d[1][1] * m->a2d[2][3] -
m->a2d[3][0] * m->a2d[1][3] * m->a2d[2][1];
inv.a2d[3][0] = -m->a2d[1][0] * m->a2d[2][1] * m->a2d[3][2] +
m->a2d[1][0] * m->a2d[2][2] * m->a2d[3][1] +
m->a2d[2][0] * m->a2d[1][1] * m->a2d[3][2] -
m->a2d[2][0] * m->a2d[1][2] * m->a2d[3][1] -
m->a2d[3][0] * m->a2d[1][1] * m->a2d[2][2] +
m->a2d[3][0] * m->a2d[1][2] * m->a2d[2][1];
m->a2d[1][0] * m->a2d[2][2] * m->a2d[3][1] +
m->a2d[2][0] * m->a2d[1][1] * m->a2d[3][2] -
m->a2d[2][0] * m->a2d[1][2] * m->a2d[3][1] -
m->a2d[3][0] * m->a2d[1][1] * m->a2d[2][2] +
m->a2d[3][0] * m->a2d[1][2] * m->a2d[2][1];
inv.a2d[0][1] = -m->a2d[0][1] * m->a2d[2][2] * m->a2d[3][3] +
m->a2d[0][1] * m->a2d[2][3] * m->a2d[3][2] +
m->a2d[2][1] * m->a2d[0][2] * m->a2d[3][3] -
m->a2d[2][1] * m->a2d[0][3] * m->a2d[3][2] -
m->a2d[3][1] * m->a2d[0][2] * m->a2d[2][3] +
m->a2d[3][1] * m->a2d[0][3] * m->a2d[2][2];
m->a2d[0][1] * m->a2d[2][3] * m->a2d[3][2] +
m->a2d[2][1] * m->a2d[0][2] * m->a2d[3][3] -
m->a2d[2][1] * m->a2d[0][3] * m->a2d[3][2] -
m->a2d[3][1] * m->a2d[0][2] * m->a2d[2][3] +
m->a2d[3][1] * m->a2d[0][3] * m->a2d[2][2];
inv.a2d[1][1] = m->a2d[0][0] * m->a2d[2][2] * m->a2d[3][3] -
m->a2d[0][0] * m->a2d[2][3] * m->a2d[3][2] -
m->a2d[2][0] * m->a2d[0][2] * m->a2d[3][3] +
m->a2d[2][0] * m->a2d[0][3] * m->a2d[3][2] +
m->a2d[3][0] * m->a2d[0][2] * m->a2d[2][3] -
m->a2d[3][0] * m->a2d[0][3] * m->a2d[2][2];
m->a2d[0][0] * m->a2d[2][3] * m->a2d[3][2] -
m->a2d[2][0] * m->a2d[0][2] * m->a2d[3][3] +
m->a2d[2][0] * m->a2d[0][3] * m->a2d[3][2] +
m->a2d[3][0] * m->a2d[0][2] * m->a2d[2][3] -
m->a2d[3][0] * m->a2d[0][3] * m->a2d[2][2];
inv.a2d[2][1] = -m->a2d[0][0] * m->a2d[2][1] * m->a2d[3][3] +
m->a2d[0][0] * m->a2d[2][3] * m->a2d[3][1] +
m->a2d[2][0] * m->a2d[0][1] * m->a2d[3][3] -
m->a2d[2][0] * m->a2d[0][3] * m->a2d[3][1] -
m->a2d[3][0] * m->a2d[0][1] * m->a2d[2][3] +
m->a2d[3][0] * m->a2d[0][3] * m->a2d[2][1];
m->a2d[0][0] * m->a2d[2][3] * m->a2d[3][1] +
m->a2d[2][0] * m->a2d[0][1] * m->a2d[3][3] -
m->a2d[2][0] * m->a2d[0][3] * m->a2d[3][1] -
m->a2d[3][0] * m->a2d[0][1] * m->a2d[2][3] +
m->a2d[3][0] * m->a2d[0][3] * m->a2d[2][1];
inv.a2d[3][1] = m->a2d[0][0] * m->a2d[2][1] * m->a2d[3][2] -
m->a2d[0][0] * m->a2d[2][2] * m->a2d[3][1] -
m->a2d[2][0] * m->a2d[0][1] * m->a2d[3][2] +
m->a2d[2][0] * m->a2d[0][2] * m->a2d[3][1] +
m->a2d[3][0] * m->a2d[0][1] * m->a2d[2][2] -
m->a2d[3][0] * m->a2d[0][2] * m->a2d[2][1];
m->a2d[0][0] * m->a2d[2][2] * m->a2d[3][1] -
m->a2d[2][0] * m->a2d[0][1] * m->a2d[3][2] +
m->a2d[2][0] * m->a2d[0][2] * m->a2d[3][1] +
m->a2d[3][0] * m->a2d[0][1] * m->a2d[2][2] -
m->a2d[3][0] * m->a2d[0][2] * m->a2d[2][1];
inv.a2d[0][2] = m->a2d[0][1] * m->a2d[1][2] * m->a2d[3][3] -
m->a2d[0][1] * m->a2d[1][3] * m->a2d[3][2] -
m->a2d[1][1] * m->a2d[0][2] * m->a2d[3][3] +
m->a2d[1][1] * m->a2d[0][3] * m->a2d[3][2] +
m->a2d[3][1] * m->a2d[0][2] * m->a2d[1][3] -
m->a2d[3][1] * m->a2d[0][3] * m->a2d[1][2];
m->a2d[0][1] * m->a2d[1][3] * m->a2d[3][2] -
m->a2d[1][1] * m->a2d[0][2] * m->a2d[3][3] +
m->a2d[1][1] * m->a2d[0][3] * m->a2d[3][2] +
m->a2d[3][1] * m->a2d[0][2] * m->a2d[1][3] -
m->a2d[3][1] * m->a2d[0][3] * m->a2d[1][2];
inv.a2d[1][2] = -m->a2d[0][0] * m->a2d[1][2] * m->a2d[3][3] +
m->a2d[0][0] * m->a2d[1][3] * m->a2d[3][2] +
m->a2d[1][0] * m->a2d[0][2] * m->a2d[3][3] -
m->a2d[1][0] * m->a2d[0][3] * m->a2d[3][2] -
m->a2d[3][0] * m->a2d[0][2] * m->a2d[1][3] +
m->a2d[3][0] * m->a2d[0][3] * m->a2d[1][2];
m->a2d[0][0] * m->a2d[1][3] * m->a2d[3][2] +
m->a2d[1][0] * m->a2d[0][2] * m->a2d[3][3] -
m->a2d[1][0] * m->a2d[0][3] * m->a2d[3][2] -
m->a2d[3][0] * m->a2d[0][2] * m->a2d[1][3] +
m->a2d[3][0] * m->a2d[0][3] * m->a2d[1][2];
inv.a2d[2][2] = m->a2d[0][0] * m->a2d[1][1] * m->a2d[3][3] -
m->a2d[0][0] * m->a2d[1][3] * m->a2d[3][1] -
m->a2d[1][0] * m->a2d[0][1] * m->a2d[3][3] +
m->a2d[1][0] * m->a2d[0][3] * m->a2d[3][1] +
m->a2d[3][0] * m->a2d[0][1] * m->a2d[1][3] -
m->a2d[3][0] * m->a2d[0][3] * m->a2d[1][1];
m->a2d[0][0] * m->a2d[1][3] * m->a2d[3][1] -
m->a2d[1][0] * m->a2d[0][1] * m->a2d[3][3] +
m->a2d[1][0] * m->a2d[0][3] * m->a2d[3][1] +
m->a2d[3][0] * m->a2d[0][1] * m->a2d[1][3] -
m->a2d[3][0] * m->a2d[0][3] * m->a2d[1][1];
inv.a2d[3][2] = -m->a2d[0][0] * m->a2d[1][1] * m->a2d[3][2] +
m->a2d[0][0] * m->a2d[1][2] * m->a2d[3][1] +
m->a2d[1][0] * m->a2d[0][1] * m->a2d[3][2] -
m->a2d[1][0] * m->a2d[0][2] * m->a2d[3][1] -
m->a2d[3][0] * m->a2d[0][1] * m->a2d[1][2] +
m->a2d[3][0] * m->a2d[0][2] * m->a2d[1][1];
m->a2d[0][0] * m->a2d[1][2] * m->a2d[3][1] +
m->a2d[1][0] * m->a2d[0][1] * m->a2d[3][2] -
m->a2d[1][0] * m->a2d[0][2] * m->a2d[3][1] -
m->a2d[3][0] * m->a2d[0][1] * m->a2d[1][2] +
m->a2d[3][0] * m->a2d[0][2] * m->a2d[1][1];
inv.a2d[0][3] = -m->a2d[0][1] * m->a2d[1][2] * m->a2d[2][3] +
m->a2d[0][1] * m->a2d[1][3] * m->a2d[2][2] +
m->a2d[1][1] * m->a2d[0][2] * m->a2d[2][3] -
m->a2d[1][1] * m->a2d[0][3] * m->a2d[2][2] -
m->a2d[2][1] * m->a2d[0][2] * m->a2d[1][3] +
m->a2d[2][1] * m->a2d[0][3] * m->a2d[1][2];
m->a2d[0][1] * m->a2d[1][3] * m->a2d[2][2] +
m->a2d[1][1] * m->a2d[0][2] * m->a2d[2][3] -
m->a2d[1][1] * m->a2d[0][3] * m->a2d[2][2] -
m->a2d[2][1] * m->a2d[0][2] * m->a2d[1][3] +
m->a2d[2][1] * m->a2d[0][3] * m->a2d[1][2];
inv.a2d[1][3] = m->a2d[0][0] * m->a2d[1][2] * m->a2d[2][3] -
m->a2d[0][0] * m->a2d[1][3] * m->a2d[2][2] -
m->a2d[1][0] * m->a2d[0][2] * m->a2d[2][3] +
m->a2d[1][0] * m->a2d[0][3] * m->a2d[2][2] +
m->a2d[2][0] * m->a2d[0][2] * m->a2d[1][3] -
m->a2d[2][0] * m->a2d[0][3] * m->a2d[1][2];
m->a2d[0][0] * m->a2d[1][3] * m->a2d[2][2] -
m->a2d[1][0] * m->a2d[0][2] * m->a2d[2][3] +
m->a2d[1][0] * m->a2d[0][3] * m->a2d[2][2] +
m->a2d[2][0] * m->a2d[0][2] * m->a2d[1][3] -
m->a2d[2][0] * m->a2d[0][3] * m->a2d[1][2];
inv.a2d[2][3] = -m->a2d[0][0] * m->a2d[1][1] * m->a2d[2][3] +
m->a2d[0][0] * m->a2d[1][3] * m->a2d[2][1] +
m->a2d[1][0] * m->a2d[0][1] * m->a2d[2][3] -
m->a2d[1][0] * m->a2d[0][3] * m->a2d[2][1] -
m->a2d[2][0] * m->a2d[0][1] * m->a2d[1][3] +
m->a2d[2][0] * m->a2d[0][3] * m->a2d[1][1];
m->a2d[0][0] * m->a2d[1][3] * m->a2d[2][1] +
m->a2d[1][0] * m->a2d[0][1] * m->a2d[2][3] -
m->a2d[1][0] * m->a2d[0][3] * m->a2d[2][1] -
m->a2d[2][0] * m->a2d[0][1] * m->a2d[1][3] +
m->a2d[2][0] * m->a2d[0][3] * m->a2d[1][1];
inv.a2d[3][3] = m->a2d[0][0] * m->a2d[1][1] * m->a2d[2][2] -
m->a2d[0][0] * m->a2d[1][2] * m->a2d[2][1] -
m->a2d[1][0] * m->a2d[0][1] * m->a2d[2][2] +
m->a2d[1][0] * m->a2d[0][2] * m->a2d[2][1] +
m->a2d[2][0] * m->a2d[0][1] * m->a2d[1][2] -
m->a2d[2][0] * m->a2d[0][2] * m->a2d[1][1];
m->a2d[0][0] * m->a2d[1][2] * m->a2d[2][1] -
m->a2d[1][0] * m->a2d[0][1] * m->a2d[2][2] +
m->a2d[1][0] * m->a2d[0][2] * m->a2d[2][1] +
m->a2d[2][0] * m->a2d[0][1] * m->a2d[1][2] -
m->a2d[2][0] * m->a2d[0][2] * m->a2d[1][1];
det = m->a2d[0][0] * inv.a2d[0][0] + m->a2d[0][1] * inv.a2d[1][0] + m->a2d[0][2] * inv.a2d[2][0] + m->a2d[0][3] * inv.a2d[3][0];
+10 -6
View File
@@ -193,13 +193,15 @@ float vm_vec_normalized_dir_quick_mag(vec3d *dest, const vec3d *end, const vec3d
float vm_vec_normalized_dir_quick(vec3d *dest, const vec3d *end, const vec3d *start);
////returns dot product of two vectors
float vm_vec_dot(const vec3d *v0, const vec3d *v1);
float vm_vec_dotprod(const vec3d *v0, const vec3d *v1);
#define vm_vec_dot vm_vec_dotprod
float vm_vec_dot3(float x, float y, float z, vec3d *v);
//computes cross product of two vectors. returns ptr to dest
//dest CANNOT equal either source
vec3d *vm_vec_cross(vec3d *dest, const vec3d *src0, const vec3d *src1);
vec3d *vm_vec_crossprod(vec3d *dest, const vec3d *src0, const vec3d *src1);
#define vm_vec_cross vm_vec_crossprod
// test if 2 vectors are parallel or not.
int vm_test_parallel(const vec3d *src0, const vec3d *src1);
@@ -253,7 +255,7 @@ vec3d *vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m);
//returns ptr to dest vector
//dest CANNOT equal source
// This is a faster replacement for this common code sequence:
// vm_copy_transpose(&tempm,src_matrix);
// vm_copy_transpose_matrix(&tempm,src_matrix);
// vm_vec_rotate(dst_vec,src_vect,&tempm);
// Replace with:
// vm_vec_unrotate(dst_vec,src_vect, src_matrix)
@@ -264,11 +266,13 @@ vec3d *vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m);
vec3d *vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m);
//transpose a matrix in place. returns ptr to matrix
matrix *vm_transpose(matrix *m);
matrix *vm_transpose_matrix(matrix *m);
#define vm_transpose(m) vm_transpose_matrix(m)
//copy and transpose a matrix. returns ptr to matrix
//dest CANNOT equal source. use vm_transpose() if this is the case
matrix *vm_copy_transpose(matrix *dest, const matrix *src);
//dest CANNOT equal source. use vm_transpose_matrix() if this is the case
matrix *vm_copy_transpose_matrix(matrix *dest, const matrix *src);
#define vm_copy_transpose(dest,src) vm_copy_transpose_matrix((dest),(src))
//mulitply 2 matrices, fill in dest. returns ptr to dest
//dest CANNOT equal either source
-5
View File
@@ -1508,13 +1508,8 @@ void barracks_do_frame(float frametime)
}
if (Player_sel_mode == PLAYER_SELECT_MODE_SINGLE) {
Cur_pilot->flags |= PLAYER_FLAGS_IS_MULTI;
Pilot.save_player(Cur_pilot);
barracks_init_player_stuff(PLAYER_SELECT_MODE_MULTI);
} else {
// make sure we don't carry over the multi flag
Cur_pilot->flags &= ~PLAYER_FLAGS_IS_MULTI;
Pilot.save_player(Cur_pilot);
barracks_init_player_stuff(PLAYER_SELECT_MODE_SINGLE);
}
+1 -1
View File
@@ -803,7 +803,7 @@ void credits_do_frame(float frametime)
Credits_frametime = temp_time - Credits_last_time;
Credits_last_time = temp_time;
timestamp_inc(Credits_frametime);
timestamp_inc(Credits_frametime / 1000.0f);
float fl_frametime = i2fl(Credits_frametime) / 1000.f;
if (keyd_pressed[KEY_LSHIFT]) {
+8
View File
@@ -319,6 +319,9 @@ void main_hall_do_multi_ready()
case NETWORK_ERROR_NO_PROTOCOL:
if (Multi_options_g.protocol == NET_TCP) {
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "TCP/IP protocol not found. This protocol is required for multiplayer FreeSpace.", 1602));
} else {
Assert(Multi_options_g.protocol == NET_IPX);
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "IPX protocol not found. This protocol is required for multiplayer FreeSpace.", 1603));
}
break;
case NETWORK_ERROR_CONNECT_TO_ISP:
@@ -343,6 +346,11 @@ void main_hall_do_multi_ready()
return;
}
if ((Multi_options_g.protocol == NET_IPX) && !Ipx_active) {
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected IPX for multiplayer FreeSpace, but the IPX protocol was not detected on your machine.", 1402));
return;
}
if (error != NETWORK_ERROR_NONE) {
return;
}
+12 -4
View File
@@ -714,6 +714,10 @@ void options_multi_load_protocol_controls()
Om_ip_input.hide();
Om_ip_input.disable();
// disable IPX button in demo
Om_pro_buttons[gr_screen.res][OM_PRO_IPX].button.disable();
Om_pro_buttons[gr_screen.res][OM_PRO_IPX].button.hide();
// bogus control
Om_pro_bogus.base_create(Om_window, UI_KIND_ICON, 0, 0, 0, 0);
}
@@ -883,7 +887,11 @@ void options_multi_protocol_do(int key)
}
// force draw the proper protocol
Om_pro_buttons[gr_screen.res][OM_PRO_TCP].button.draw_forced(2);
if (Om_protocol == NET_IPX) {
Om_pro_buttons[gr_screen.res][OM_PRO_IPX].button.draw_forced(2);
} else {
Om_pro_buttons[gr_screen.res][OM_PRO_TCP].button.draw_forced(2);
}
// force draw the proper tab button
switch (Om_mode) {
@@ -1110,10 +1118,10 @@ void options_multi_protocol_button_pressed(int n)
gamesnd_play_iface(SND_USER_SELECT);
break;
// ipx mode, no longer supported
// ipx mode
case OM_PRO_IPX:
gamesnd_play_iface(SND_GENERAL_FAIL);
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, "The old IPX protocol is no longer supported.");
Om_protocol = NET_IPX;
gamesnd_play_iface(SND_USER_SELECT);
break;
}
}
+1 -2
View File
@@ -335,8 +335,7 @@ void player_select_init()
player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE);
}
if (Cmdline_benchmark_mode || ((Player_select_num_pilots == 1) && Player_select_input_mode)) {
// When benchmarking, just accept automatically
if ( (Player_select_num_pilots == 1) && Player_select_input_mode ) {
Player_select_autoaccept = 1;
}
}
+1 -1
View File
@@ -573,7 +573,7 @@ void techroom_ships_render(float frametime)
model_render_immediate(&render_info, Techroom_ship_modelnum, &Techroom_ship_orient, &vmd_zero_vector);
shadows_end_render();
gr_set_clip(Tech_ship_display_coords[gr_screen.res][SHIP_X_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_Y_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_W_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_H_COORD], GR_RESIZE_MENU);
gr_set_clip(Tech_ship_display_coords[gr_screen.res][SHIP_X_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_Y_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_W_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_H_COORD]);
}
if (!Cmdline_nohtl) {
-4
View File
@@ -312,7 +312,6 @@ char *Parse_object_flags_2[MAX_PARSE_OBJECT_FLAGS_2] = {
"weapons-locked",
"scramble-messages",
"no-collide",
"no-disabled-self-destruct",
};
char *Mission_event_log_flags[MAX_MISSION_EVENT_LOG_FLAGS] = {
@@ -2648,9 +2647,6 @@ void resolve_parse_flags(object *objp, int parse_flags, int parse_flags2)
if (parse_flags2 & P2_SF2_SCRAMBLE_MESSAGES)
shipp->flags2 |= SF2_SCRAMBLE_MESSAGES;
if (parse_flags2 & P2_SF2_NO_DISABLED_SELF_DESTRUCT)
shipp->flags2 |= SF2_NO_DISABLED_SELF_DESTRUCT;
// don't remove no-collide if not set in the mission
if (parse_flags2 & P2_OF_NO_COLLIDE)
obj_set_flags(objp, objp->flags & ~OF_COLLIDES);
+1 -2
View File
@@ -483,7 +483,7 @@ public:
// same caveat: This list of bitfield indicators MUST correspond EXACTLY
// (i.e., order and position must be the same) to its counterpart in MissionParse.cpp!!!!
#define MAX_PARSE_OBJECT_FLAGS_2 25
#define MAX_PARSE_OBJECT_FLAGS_2 24
#define P2_SF2_PRIMITIVE_SENSORS (1<<0)
#define P2_SF2_NO_SUBSPACE_DRIVE (1<<1)
@@ -509,7 +509,6 @@ public:
#define P2_SF2_WEAPONS_LOCKED (1<<21)
#define P2_SF2_SCRAMBLE_MESSAGES (1<<22)
#define P2_OF_NO_COLLIDE (1<<23) // This actually changes the OF_COLLIDES object flag
#define P2_SF2_NO_DISABLED_SELF_DESTRUCT (1<<24)
// and again: these flags do not appear in the array
//#define blah (1<<28)
+3 -7
View File
@@ -1726,6 +1726,8 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,
float size = pm->rad*0.7f;
float start_scale = MIN(time,0.5f)*2.5f;
float offset = size*0.5f*MIN(MAX(time-3.0f,0.0f),0.6f)*1.66667f;
if ( (time < 1.5f) && (time >= 0.5f) ) // Clip the grid if were in phase 1
render_info->set_clip_plane(plane_point,wire_normal);
g3_start_instance_angles(&vmd_zero_vector,&view_angles);
@@ -1752,10 +1754,6 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,
gr_set_color(0,200,0);
g3_start_instance_angles(&vmd_zero_vector,&view_angles);
if (time < 1.5f) {
stop.xyz.z = -clip;
}
for (i = -3; i < 4; i++) {
start.xyz.x = stop.xyz.x = size*0.333f*i;
g3_draw_htl_line(&start,&stop);
@@ -1764,10 +1762,8 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,
start.xyz.x = size;
stop.xyz.x = -size;
for (i = 3; i > -4; i--) {
for (i = -3; i < 4; i++) {
start.xyz.z = stop.xyz.z = size*0.333f*i+offset*0.5f;
if ((time < 1.5f) && (start.xyz.z <= -clip))
break;
g3_draw_htl_line(&start,&stop);
}
+43 -45
View File
@@ -33,9 +33,8 @@ extern int model_render_flags_size;
#define MOVEMENT_TYPE_POS 0
#define MOVEMENT_TYPE_ROT 1
#define MOVEMENT_TYPE_ROT_SPECIAL 2 // for turrets only
#define MOVEMENT_TYPE_TRIGGERED 3 // triggered rotation
#define MOVEMENT_TYPE_INTRINSIC_ROTATE 4 // intrinsic (non-subsystem-based) rotation
#define MOVEMENT_TYPE_LOOK_AT 5 // the subobject is always looking at a 'look at' subobject, as best it can - Bobboau
#define MOVEMENT_TYPE_TRIGGERED 3 //triggered rotation
#define MOVEMENT_TYPE_LOOK_AT 4 // the subobject is always looking at a 'look at' subobject, as best it can - Bobboau
// DA 11/13/98 Reordered to account for difference between max and game
@@ -91,7 +90,6 @@ typedef struct submodel_instance {
matrix mc_orient;
bool collision_checked;
bool blown_off;
submodel_instance_info *sii;
} submodel_instance;
// Data specific to a particular instance of a model.
@@ -122,18 +120,19 @@ typedef struct polymodel_instance {
#define MSS_FLAG_NO_SS_TARGETING (1 << 16) // toggles the subsystem targeting for the turret
#define MSS_FLAG_TURRET_RESET_IDLE (1 << 17) // makes turret reset to their initial position if the target is out of field of view
#define MSS_FLAG_TURRET_ALT_MATH (1 << 18) // tells the game to use additional calculations should turret have a defined y fov
#define MSS_FLAG_CARRY_SHOCKWAVE (1 << 19) // subsystem - even with 'carry no damage' flag - will carry shockwave damage to the hull
#define MSS_FLAG_ALLOW_LANDING (1 << 20) // This subsystem can be landed on
#define MSS_FLAG_FOV_EDGE_CHECK (1 << 21) // Tells the game to use better FOV edge checking with this turret
#define MSS_FLAG_FOV_REQUIRED (1 << 22) // Tells game not to allow this turret to attempt targeting objects out of FOV
#define MSS_FLAG_NO_REPLACE (1 << 23) // set the subsys not to draw replacement ('destroyed') model
#define MSS_FLAG_NO_LIVE_DEBRIS (1 << 24) // sets the subsys not to release live debris
#define MSS_FLAG_IGNORE_IF_DEAD (1 << 25) // tells homing missiles to ignore the subsys if its dead and home on to hull instead of earlier subsys pos
#define MSS_FLAG_ALLOW_VANISHING (1 << 26) // allows subsystem to vanish (prevents explosions & sounds effects from being played)
#define MSS_FLAG_DAMAGE_AS_HULL (1 << 27) // applies armor damage to subsystem instead of subsystem damage - FUBAR
#define MSS_FLAG_TURRET_LOCKED (1 << 28) // Turret starts locked by default - Sushi
#define MSS_FLAG_NO_AGGREGATE (1 << 29) // Don't include with aggregate subsystem types - Goober5000
#define MSS_FLAG_TURRET_ANIM_WAIT (1 << 30) // Turret won't fire until animation is complete - Sushi
#define MSS_FLAG_DUM_ROTATES (1 << 19) // Bobboau
#define MSS_FLAG_CARRY_SHOCKWAVE (1 << 20) // subsystem - even with 'carry no damage' flag - will carry shockwave damage to the hull
#define MSS_FLAG_ALLOW_LANDING (1 << 21) // This subsystem can be landed on
#define MSS_FLAG_FOV_EDGE_CHECK (1 << 22) // Tells the game to use better FOV edge checking with this turret
#define MSS_FLAG_FOV_REQUIRED (1 << 23) // Tells game not to allow this turret to attempt targeting objects out of FOV
#define MSS_FLAG_NO_REPLACE (1 << 24) // set the subsys not to draw replacement ('destroyed') model
#define MSS_FLAG_NO_LIVE_DEBRIS (1 << 25) // sets the subsys not to release live debris
#define MSS_FLAG_IGNORE_IF_DEAD (1 << 26) // tells homing missiles to ignore the subsys if its dead and home on to hull instead of earlier subsys pos
#define MSS_FLAG_ALLOW_VANISHING (1 << 27) // allows subsystem to vanish (prevents explosions & sounds effects from being played)
#define MSS_FLAG_DAMAGE_AS_HULL (1 << 28) // applies armor damage to subsystem instead of subsystem damage - FUBAR
#define MSS_FLAG_TURRET_LOCKED (1 << 29) // Turret starts locked by default - Sushi
#define MSS_FLAG_NO_AGGREGATE (1 << 30) // Don't include with aggregate subsystem types - Goober5000
#define MSS_FLAG_TURRET_ANIM_WAIT (1 << 31) // Turret won't fire until animation is complete - Sushi
#define MSS_FLAG2_PLAYER_TURRET_SOUND (1 << 0)
#define MSS_FLAG2_TURRET_ONLY_TARGET_IF_CAN_FIRE (1 << 1) // Turrets only target things they're allowed to shoot at (e.g. if check-hull fails, won't keep targeting)
@@ -141,9 +140,6 @@ typedef struct polymodel_instance {
#define MSS_FLAG2_COLLIDE_SUBMODEL (1 << 3) // subsystem takes damage only from hits which impact the associated submodel
#define MSS_FLAG2_DESTROYED_ROTATION (1 << 4) // allows subobjects to continue to rotate even if they have been destroyed
#define MSS_FLAG2_TURRET_USE_AMMO (1 << 5) // enables ammo consumption for turrets (DahBlount)
#define MSS_FLAG2_AUTOREPAIR_IF_DISABLED (1 << 6) // Allows the subsystem to repair itself even if disabled (MageKing17)
#define MSS_FLAG2_NO_AUTOREPAIR_IF_DISABLED (1 << 7) // Inversion of the previous; disallows this particular subsystem if the ship-wide flag is set (MageKing17)
#define MSS_FLAG2_SHARE_FIRE_DIRECTION (1 << 8) // (DahBlount) Whenever the turret fires, make all firing points fire in the same direction.
#define NUM_SUBSYSTEM_FLAGS 33
@@ -300,7 +296,7 @@ class bsp_info
public:
bsp_info()
: movement_type(-1), movement_axis(0), can_move(false), bsp_data_size(0), bsp_data(NULL), collision_tree_index(-1),
rad(0.0f), blown_off(0), my_replacement(-1), i_replace(-1), is_live_debris(0), num_live_debris(0),
rad(0.0f), blown_off(0), my_replacement(-1), i_replace(-1), is_live_debris(0), num_live_debris(0), sii(NULL),
is_thruster(0), is_damaged(0), parent(-1), num_children(0), first_child(-1), next_sibling(-1), num_details(0),
num_arcs(0), outline_buffer(NULL), n_verts_outline(0), render_sphere_radius(0.0f), use_render_box(0), use_render_box_offset(false),
use_render_sphere(0), use_render_sphere_offset(false), gun_rotation(false), no_collisions(false),
@@ -352,6 +348,8 @@ public:
int num_live_debris; // num live debris models assocaiated with a submodel
int live_debris[MAX_LIVE_DEBRIS]; // array of live debris submodels for a submodel
submodel_instance_info *sii; // stuff needed for collision from rotations
int is_thruster;
int is_damaged;
@@ -617,11 +615,10 @@ typedef struct insignia {
vec3d norm[MAX_INS_VECS] ; //normal of the insignia-Bobboau
} insignia;
#define PM_FLAG_ALLOW_TILING (1<<0) // Allow texture tiling
#define PM_FLAG_AUTOCEN (1<<1) // contains autocentering info
#define PM_FLAG_TRANS_BUFFER (1<<2) // render transparency buffer
#define PM_FLAG_BATCHED (1<<3) // this model can be batch rendered
#define PM_FLAG_HAS_INTRINSIC_ROTATE (1<<4) // whether this model has an intrinsic rotation submodel somewhere
#define PM_FLAG_ALLOW_TILING (1<<0) // Allow texture tiling
#define PM_FLAG_AUTOCEN (1<<1) // contains autocentering info
#define PM_FLAG_TRANS_BUFFER (1<<2) // render transparency buffer
#define PM_FLAG_BATCHED (1<<3) // this model can be batch rendered
// Goober5000
class texture_info
@@ -830,7 +827,7 @@ void model_instance_free_all();
// Loads a model from disk and returns the model number it loaded into.
int model_load(char *filename, int n_subsystems, model_subsystem *subsystems, int ferror = 1, int duplicate = 0);
int model_create_instance(bool is_ship, int model_num);
int model_create_instance(int model_num, int submodel_num = -1);
void model_delete_instance(int model_instance_num);
// Goober5000
@@ -997,8 +994,7 @@ extern void model_make_turret_matrix(int model_num, model_subsystem * turret );
// Rotates the angle of a submodel. Use this so the right unlocked axis
// gets stuffed.
extern void submodel_rotate(model_subsystem *psub, submodel_instance_info *sii);
extern void submodel_rotate(bsp_info *sm, submodel_instance_info *sii);
extern void submodel_rotate(model_subsystem *psub, submodel_instance_info * sii);
// Rotates the angle of a submodel. Use this so the right unlocked axis
// gets stuffed. Does this for stepped rotations
@@ -1011,19 +1007,20 @@ extern void model_find_submodel_offset(vec3d *outpnt, int model_num, int sub_mod
// Given a point (pnt) that is in sub_model_num's frame of
// reference, and given the object's orient and position,
// return the point in 3-space in outpnt.
extern void model_find_world_point(vec3d *outpnt, vec3d *mpnt, int model_num, int submodel_num, const matrix *objorient, const vec3d *objpos);
extern void model_instance_find_world_point(vec3d *outpnt, vec3d *mpnt, int model_instance_num, int submodel_num, const matrix *objorient, const vec3d *objpos);
extern void model_find_world_point(vec3d * outpnt, vec3d *mpnt,int model_num, int sub_model_num, matrix * objorient, vec3d * objpos);
void model_instance_find_world_point(vec3d * outpnt, vec3d *mpnt, int model_num, int model_instance_num, int sub_model_num, matrix * objorient, vec3d * objpos );
// Given a point in the world RF, find the corresponding point in the model RF.
// This is special purpose code, specific for model collision.
// NOTE - this code ASSUMES submodel is 1 level down from hull (detail[0])
void world_find_model_point(vec3d *out, vec3d *world_pt, const polymodel *pm, int submodel_num, const matrix *orient, const vec3d *pos);
void world_find_model_instance_point(vec3d *out, vec3d *world_pt, const polymodel_instance *pmi, int submodel_num, const matrix *orient, const vec3d *pos);
void world_find_model_point(vec3d *out, vec3d *world_pt, polymodel *pm, int submodel_num, matrix *orient, vec3d *pos);
extern void find_submodel_instance_point(vec3d *outpnt, int model_instance_num, int submodel_num);
extern void find_submodel_instance_point_normal(vec3d *outpnt, vec3d *outnorm, int model_instance_num, int submodel_num, const vec3d *submodel_pnt, const vec3d *submodel_norm);
extern void find_submodel_instance_point_orient(vec3d *outpnt, matrix *outorient, int model_instance_num, int submodel_num, const vec3d *submodel_pnt, const matrix *submodel_orient);
extern void find_submodel_instance_world_point(vec3d *outpnt, int model_instance_num, int submodel_num, const matrix *objorient, const vec3d *objpos);
void world_find_model_instance_point(vec3d *out, vec3d *world_pt, polymodel *pm, polymodel_instance *pmi, int submodel_num, matrix *orient, vec3d *pos);
extern void find_submodel_instance_point(vec3d *outpnt, object *pship_obj, int submodel_num);
extern void find_submodel_instance_point_normal(vec3d *outpnt, vec3d *outnorm, object *pship_obj, int submodel_num, vec3d *submodel_pnt, vec3d *submodel_norm);
extern void find_submodel_instance_point_orient(vec3d *outpnt, matrix *outorient, object *pship_obj, int submodel_num, vec3d *submodel_pnt, matrix *submodel_orient);
extern void find_submodel_instance_world_point(vec3d *outpnt, object *pship_obj, int submodel_num);
// Given a polygon model index, find a list of rotating submodels to be used for collision
void model_get_rotating_submodel_list(SCP_vector<int> *submodel_vector, object *objp);
@@ -1037,13 +1034,13 @@ void model_init_submodel_axis_pt(submodel_instance_info *sii, int model_num, int
// Given a direction (pnt) that is in sub_model_num's frame of
// reference, and given the object's orient and position,
// return the point in 3-space in outpnt.
extern void model_find_world_dir(vec3d *out_dir, vec3d *in_dir, int model_num, int submodel_num, const matrix *objorient);
extern void model_instance_find_world_dir(vec3d *out_dir, vec3d *in_dir, int model_instance_num, int submodel_num, const matrix *objorient);
extern void model_find_world_dir(vec3d * out_dir, vec3d *in_dir,int model_num, int sub_model_num, matrix * objorient, vec3d * objpos);
extern void model_instance_find_world_dir(vec3d * out_dir, vec3d *in_dir,int model_num, int model_instance_num, int sub_model_num, matrix * objorient, vec3d * objpos);
// Clears all the submodel instances stored in a model to their defaults.
extern void model_clear_instance(int model_num);
void model_clear_submodel_instance( submodel_instance *sm_instance, bsp_info *sm );
void model_clear_submodel_instance( submodel_instance *sm_instance );
void model_clear_submodel_instances( int model_instance_num );
// Sets rotating submodel turn info to that stored in model
@@ -1053,10 +1050,11 @@ void model_set_instance_info(submodel_instance_info *sii, float turn_rate, float
extern void model_clear_instance_info(submodel_instance_info * sii);
// Sets the submodel instance data in a submodel
extern void model_set_instance(int model_num, int sub_model_num, submodel_instance_info *sii, int flags = 0);
extern void model_set_instance_techroom(int model_num, int sub_model_num, float angle_1, float angle_2);
extern void model_set_instance(int model_num, int sub_model_num, submodel_instance_info * sii, int flags = 0 );
extern void model_set_instance_techroom(int model_num, int sub_model_num, float angle_1, float angle_2 );
void model_update_instance(int model_instance_num, int sub_model_num, submodel_instance_info *sii, int flags);
void model_update_instance(int model_instance_num, int sub_model_num, submodel_instance_info *sii);
void model_instance_dumb_rotation(int model_instance_num);
// Adds an electrical arcing effect to a submodel
void model_add_arc(int model_num, int sub_model_num, vec3d *v1, vec3d *v2, int arc_type);
@@ -1097,8 +1095,8 @@ int submodel_get_num_polys(int model_num, int submodel_num);
// Given a vector that is in sub_model_num's frame of
// reference, and given the object's orient and position,
// return the vector in the model's frame of reference.
void model_find_obj_dir(vec3d *w_vec, vec3d *m_vec, int model_instance_num, int submodel_num, matrix *objorient);
void model_instance_find_obj_dir(vec3d *w_vec, vec3d *m_vec, int model_instance_num, int submodel_num, matrix *objorient);
void model_find_obj_dir(vec3d *w_vec, vec3d *m_vec, object *pship_obj, int sub_model_num);
void model_instance_find_obj_dir(vec3d *w_vec, vec3d *m_vec, object *pship_obj, int sub_model_num);
// This is the interface to model_check_collision. Rather than passing all these
@@ -1368,7 +1366,7 @@ void model_finish_cloak(int full_cloak);
void model_do_look_at(int model_num); //Bobboau
void model_do_intrinsic_rotations(int model_instance_num = -1);
void model_do_dumb_rotation(int modelnum); //Bobboau
int model_should_render_engine_glow(int objnum, int bank_obj);
+1 -1
View File
@@ -234,7 +234,7 @@ void triggered_rotation::add_queue(queued_animation *the_queue, int dir)
if (i != n_queue) {
// replace if it's not the last item on the list
if ( i < (MAX_TRIGGERED_ANIMATIONS-1) )
memmove( &queue_tmp[i], &queue_tmp[i+1], sizeof(queued_animation) * (MAX_TRIGGERED_ANIMATIONS-(i+1)) );
memcpy( &queue_tmp[i], &queue_tmp[i+1], sizeof(queued_animation) * (MAX_TRIGGERED_ANIMATIONS-(i+1)) );
// ok these two animations cancelled each other out, so he doesn't get on the queue
n_queue--;
+5 -5
View File
@@ -277,7 +277,7 @@ static void mc_check_sphereline_face( int nv, vec3d ** verts, vec3d * plane_pnt,
//mprintf(("Estimated radius error: Estimate %f, actual %f Mc->radius\n", temp_dist, Mc->radius));
}
vm_vec_sub( &temp_dir, &hit_point, &temp_sphere );
// Assert( vm_vec_dot( &temp_dir, &Mc_direction ) > 0 );
// Assert( vm_vec_dotprod( &temp_dir, &Mc_direction ) > 0 );
*/
}
}
@@ -305,7 +305,7 @@ static void mc_check_sphereline_face( int nv, vec3d ** verts, vec3d * plane_pnt,
//mprintf(("Estimated radius error: Estimate %f, actual %f Mc->radius\n", temp_dist, Mc->radius));
}
vm_vec_sub( &temp_dir, &hit_point, &temp_sphere );
// Assert( vm_vec_dot( &temp_dir, &Mc_direction ) > 0 );
// Assert( vm_vec_dotprod( &temp_dir, &Mc_direction ) > 0 );
*/
if ( (Mc->num_hits==0) || (sphere_time < Mc->hit_dist) ) {
@@ -1206,7 +1206,7 @@ NoHit:
vm_rotate_matrix_by_angles(&rotation_matrix, &angs);
matrix inv_orientation;
vm_copy_transpose(&inv_orientation, &csm->orientation);
vm_copy_transpose_matrix(&inv_orientation, &csm->orientation);
vm_matrix_x_matrix(&tm, &rotation_matrix, &inv_orientation);
}
@@ -1338,7 +1338,7 @@ int model_collide(mc_info *mc_info_obj)
vm_vec_add2(&Mc->hit_point_world, Mc->pos);
} else {
if ( Mc_pmi ) {
model_instance_find_world_point(&Mc->hit_point_world, &Mc->hit_point, Mc->model_instance_num, Mc->hit_submodel, Mc->orient, Mc->pos);
model_instance_find_world_point(&Mc->hit_point_world, &Mc->hit_point, Mc->model_num, Mc->model_instance_num, Mc->hit_submodel, Mc->orient, Mc->pos);
} else {
model_find_world_point(&Mc->hit_point_world, &Mc->hit_point, Mc->model_num, Mc->hit_submodel, Mc->orient, Mc->pos);
}
@@ -1376,7 +1376,7 @@ void model_collide_preprocess_subobj(vec3d *pos, matrix *orient, polymodel *pm,
vm_rotate_matrix_by_angles(&rotation_matrix, &angs);
matrix inv_orientation;
vm_copy_transpose(&inv_orientation, &csm->orientation);
vm_copy_transpose_matrix(&inv_orientation, &csm->orientation);
vm_matrix_x_matrix(&tm, &rotation_matrix, &inv_orientation);
}
+16 -38
View File
@@ -1628,7 +1628,7 @@ void model_interp_subcall(polymodel * pm, int mn, int detail_level)
vm_rotate_matrix_by_angles(&rotation_matrix, &pm->submodel[mn].angs);
matrix inv_orientation;
vm_copy_transpose(&inv_orientation, &pm->submodel[mn].orientation);
vm_copy_transpose_matrix(&inv_orientation, &pm->submodel[mn].orientation);
matrix submodel_matrix;
vm_matrix_x_matrix(&submodel_matrix, &rotation_matrix, &inv_orientation);
@@ -2011,6 +2011,8 @@ void model_render_DEPRECATED(int model_num, matrix *orient, vec3d * pos, uint fl
polymodel *pm = model_get(model_num);
model_do_dumb_rotation(model_num);
if (flags & MR_FORCE_CLAMP)
gr_set_texture_addressing(TMAP_ADDRESS_CLAMP);
@@ -2237,7 +2239,7 @@ void moldel_calc_facing_pts( vec3d *top, vec3d *bot, vec3d *fvec, vec3d *pos, fl
vm_vec_sub( &rvec, Eyeposition, &temp );
vm_vec_normalize( &rvec );
vm_vec_cross(&uvec,fvec,&rvec);
vm_vec_crossprod(&uvec,fvec,&rvec);
vm_vec_normalize(&uvec);
vm_vec_scale_add( top, &temp, &uvec, w/2.0f );
@@ -2347,7 +2349,7 @@ void model_render_thrusters(polymodel *pm, int objnum, ship *shipp, matrix *orie
vm_vec_sub(&loc_offset, &gpt->pnt, &submodel_static_offset);
tempv = loc_offset;
find_submodel_instance_point_normal(&loc_offset, &loc_norm, shipp->model_instance_num, bank->submodel_num, &tempv, &loc_norm);
find_submodel_instance_point_normal(&loc_offset, &loc_norm, &Objects[objnum], bank->submodel_num, &tempv, &loc_norm);
}
vm_vec_unrotate(&world_pnt, &loc_offset, orient);
@@ -2657,7 +2659,7 @@ void model_render_glow_points_DEPRECATED(polymodel *pm, ship *shipp, matrix *ori
vm_vec_sub(&loc_offset, &gpt->pnt, &submodel_static_offset);
tempv = loc_offset;
find_submodel_instance_point_normal(&loc_offset, &loc_norm, shipp->model_instance_num, bank->submodel_parent, &tempv, &loc_norm);
find_submodel_instance_point_normal(&loc_offset, &loc_norm, &Objects[shipp->objnum], bank->submodel_parent, &tempv, &loc_norm);
}
vm_vec_unrotate(&world_pnt, &loc_offset, orient);
@@ -2815,7 +2817,7 @@ void model_render_glow_points_DEPRECATED(polymodel *pm, ship *shipp, matrix *ori
} else {
cone_dir_rot = gpo->cone_direction;
}
find_submodel_instance_point_normal(&unused, &cone_dir_model, shipp->model_instance_num, bank->submodel_parent, &unused, &cone_dir_rot);
find_submodel_instance_point_normal(&unused, &cone_dir_model, &Objects[shipp->objnum], bank->submodel_parent, &unused, &cone_dir_rot);
vm_vec_unrotate(&cone_dir_world, &cone_dir_model, orient);
vm_vec_rotate(&cone_dir_screen, &cone_dir_world, &Eye_matrix);
cone_dir_screen.xyz.z = -cone_dir_screen.xyz.z;
@@ -3601,21 +3603,8 @@ void submodel_get_two_random_points(int model_num, int submodel_num, vec3d *v1,
return;
}
#ifndef NDEBUG
if (RAND_MAX < nv)
{
static int submodel_get_two_random_points_warned = false;
if (!submodel_get_two_random_points_warned)
{
polymodel *pm = model_get(model_num);
Warning(LOCATION, "RAND_MAX is only %d, but submodel %d for model %s has %d vertices! Explosions will not propagate through the entire model!\n", RAND_MAX, submodel_num, pm->filename, nv);
submodel_get_two_random_points_warned = true;
}
}
#endif
int vn1 = myrand() % nv;
int vn2 = myrand() % nv;
int vn1 = (myrand()>>5) % nv;
int vn2 = (myrand()>>5) % nv;
*v1 = *Interp_verts[vn1];
*v2 = *Interp_verts[vn2];
@@ -3652,20 +3641,9 @@ void submodel_get_two_random_points_better(int model_num, int submodel_num, vec3
return;
}
#ifndef NDEBUG
if (RAND_MAX < nv)
{
static int submodel_get_two_random_points_warned = false;
if (!submodel_get_two_random_points_warned)
{
Warning(LOCATION, "RAND_MAX is only %d, but submodel %d for model %s has %d vertices! Explosions will not propagate through the entire model!\n", RAND_MAX, submodel_num, pm->filename, nv);
submodel_get_two_random_points_warned = true;
}
}
#endif
int vn1 = myrand() % nv;
int vn2 = myrand() % nv;
Assert(nv > 0); // Goober5000 - to avoid div-0 error
int vn1 = (myrand()>>5) % nv;
int vn2 = (myrand()>>5) % nv;
*v1 = tree->point_list[vn1];
*v2 = tree->point_list[vn2];
@@ -4358,7 +4336,7 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
polygon_list[i].n_verts = vert_count;
// set submodel ID
if ( GLSL_version >= 130 ) {
if ( Use_GLSL >= 3 ) {
for ( j = 0; j < polygon_list[i].n_verts; ++j ) {
polygon_list[i].submodels[j] = mn;
}
@@ -4414,7 +4392,7 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
memcpy( (model_list->tsb) + model_list->n_verts, polygon_list[i].tsb, sizeof(tsb_t) * polygon_list[i].n_verts );
}
if ( GLSL_version >= 130 ) {
if ( Use_GLSL >= 3 ) {
memcpy( (model_list->submodels) + model_list->n_verts, polygon_list[i].submodels, sizeof(int) * polygon_list[i].n_verts );
}
@@ -4434,7 +4412,7 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
}
if ( model_list->submodels != NULL ) {
Assert( GLSL_version >= 130 );
Assert( Use_GLSL >= 3 );
vertex_flags |= VB_FLAG_MODEL_ID;
}
@@ -4793,7 +4771,7 @@ void model_render_children_buffers_DEPRECATED(polymodel *pm, int mn, int detail_
vm_rotate_matrix_by_angles(&rotation_matrix, &ang);
matrix inv_orientation;
vm_copy_transpose(&inv_orientation, &model->orientation);
vm_copy_transpose_matrix(&inv_orientation, &model->orientation);
matrix submodel_matrix;
vm_matrix_x_matrix(&submodel_matrix, &rotation_matrix, &inv_orientation);
+293 -409
View File
File diff suppressed because it is too large. Load diff
+14 -43
View File
@@ -9,7 +9,6 @@
#include <algorithm>
#include "asteroid/asteroid.h"
#include "cmdline/cmdline.h"
#include "gamesequence/gamesequence.h"
#include "graphics/gropengldraw.h"
@@ -24,7 +23,6 @@
#include "render/3dinternal.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
#include "weapon/weapon.h"
extern int Model_texturing;
extern int Model_polys;
@@ -1196,7 +1194,7 @@ void model_render_buffers(draw_list* scene, model_render_params* interp, vertex_
scale.xyz.x = 1.0f;
scale.xyz.y = 1.0f;
if ( is_minimum_GLSL_version() ) {
if ( Use_GLSL > 1 ) {
scale.xyz.z = 1.0f;
scene->set_thrust_scale(interp->get_thruster_info().length.xyz.z);
} else {
@@ -1397,7 +1395,7 @@ void model_render_buffers(draw_list* scene, model_render_params* interp, vertex_
}
}
void model_render_children_buffers(draw_list* scene, model_render_params* interp, polymodel* pm, polymodel_instance *pmi, int mn, int detail_level, uint tmap_flags, bool trans_buffer)
void model_render_children_buffers(draw_list* scene, model_render_params* interp, polymodel* pm, int mn, int detail_level, uint tmap_flags, bool trans_buffer)
{
int i;
@@ -1407,19 +1405,9 @@ void model_render_children_buffers(draw_list* scene, model_render_params* interp
}
bsp_info *model = &pm->submodel[mn];
submodel_instance *smi = NULL;
if ( pmi != NULL ) {
smi = &pmi->submodel[mn];
}
if ( smi != NULL ) {
if ( smi->blown_off ) {
return;
}
} else if ( model->blown_off ) {
if (model->blown_off)
return;
}
const uint model_flags = interp->get_model_flags();
@@ -1442,10 +1430,6 @@ void model_render_children_buffers(draw_list* scene, model_render_params* interp
// the submodel relative to its parent
angles ang = model->angs;
if ( smi != NULL ) {
ang = smi->angs;
}
// Add barrel rotation if needed
if ( model->gun_rotation ) {
if ( pm->gun_submodel_rotation > PI2 ) {
@@ -1466,7 +1450,7 @@ void model_render_children_buffers(draw_list* scene, model_render_params* interp
vm_rotate_matrix_by_angles(&rotation_matrix, &ang);
matrix inv_orientation;
vm_copy_transpose(&inv_orientation, &model->orientation);
vm_copy_transpose_matrix(&inv_orientation, &model->orientation);
matrix submodel_matrix;
vm_matrix_x_matrix(&submodel_matrix, &rotation_matrix, &inv_orientation);
@@ -1493,7 +1477,7 @@ void model_render_children_buffers(draw_list* scene, model_render_params* interp
while ( i >= 0 ) {
if ( !pm->submodel[i].is_thruster ) {
model_render_children_buffers( scene, interp, pm, pmi, i, detail_level, tmap_flags, trans_buffer );
model_render_children_buffers( scene, interp, pm, i, detail_level, tmap_flags, trans_buffer );
}
i = pm->submodel[i].next_sibling;
@@ -1810,7 +1794,7 @@ void model_render_glowpoint(int point_num, vec3d *pos, matrix *orient, glow_poin
vm_vec_sub(&loc_offset, &gpt->pnt, &submodel_static_offset);
tempv = loc_offset;
find_submodel_instance_point_normal(&loc_offset, &loc_norm, shipp->model_instance_num, bank->submodel_parent, &tempv, &loc_norm);
find_submodel_instance_point_normal(&loc_offset, &loc_norm, &Objects[shipp->objnum], bank->submodel_parent, &tempv, &loc_norm);
}
vm_vec_unrotate(&world_pnt, &loc_offset, orient);
@@ -1975,7 +1959,7 @@ void model_render_glowpoint(int point_num, vec3d *pos, matrix *orient, glow_poin
cone_dir_rot = gpo->cone_direction;
}
find_submodel_instance_point_normal(&unused, &cone_dir_model, shipp->model_instance_num, bank->submodel_parent, &unused, &cone_dir_rot);
find_submodel_instance_point_normal(&unused, &cone_dir_model, &Objects[shipp->objnum], bank->submodel_parent, &unused, &cone_dir_rot);
vm_vec_unrotate(&cone_dir_world, &cone_dir_model, orient);
vm_vec_rotate(&cone_dir_screen, &cone_dir_world, &Eye_matrix);
cone_dir_screen.xyz.z = -cone_dir_screen.xyz.z;
@@ -2276,7 +2260,7 @@ void model_queue_render_thrusters(model_render_params *interp, polymodel *pm, in
vm_vec_sub(&loc_offset, &gpt->pnt, &submodel_static_offset);
tempv = loc_offset;
find_submodel_instance_point_normal(&loc_offset, &loc_norm, shipp->model_instance_num, bank->submodel_num, &tempv, &loc_norm);
find_submodel_instance_point_normal(&loc_offset, &loc_norm, &Objects[objnum], bank->submodel_num, &tempv, &loc_norm);
}
vm_vec_unrotate(&world_pnt, &loc_offset, orient);
@@ -2546,7 +2530,7 @@ void model_render_debug_children(polymodel *pm, int mn, int detail_level, uint d
vm_rotate_matrix_by_angles(&rotation_matrix, &ang);
matrix inv_orientation;
vm_copy_transpose(&inv_orientation, &model->orientation);
vm_copy_transpose_matrix(&inv_orientation, &model->orientation);
matrix submodel_matrix;
vm_matrix_x_matrix(&submodel_matrix, &rotation_matrix, &inv_orientation);
@@ -2686,8 +2670,9 @@ void model_render_queue(model_render_params *interp, draw_list *scene, int model
const int model_flags = interp->get_model_flags();
polymodel *pm = model_get(model_num);
polymodel_instance *pmi = NULL;
model_do_dumb_rotation(model_num);
float light_factor = model_render_determine_light_factor(interp, pos, model_flags);
if ( light_factor < (1.0f/32.0f) ) {
@@ -2729,22 +2714,8 @@ void model_render_queue(model_render_params *interp, draw_list *scene, int model
if (objp->type == OBJ_SHIP) {
shipp = &Ships[objp->instance];
pmi = model_get_instance(shipp->model_instance_num);
}
else if (pm->flags & PM_FLAG_HAS_INTRINSIC_ROTATE) {
if (objp->type == OBJ_ASTEROID)
pmi = model_get_instance(Asteroids[objp->instance].model_instance_num);
else if (objp->type == OBJ_WEAPON)
pmi = model_get_instance(Weapons[objp->instance].model_instance_num);
else
Warning(LOCATION, "Unsupported object type %d for rendering intrinsic-rotate submodels!", objp->type);
}
}
// is this a skybox with a rotating submodel?
extern int Nmodel_num, Nmodel_instance_num;
if (model_num == Nmodel_num && Nmodel_instance_num >= 0)
pmi = model_get_instance(Nmodel_instance_num);
// Set the flags we will pass to the tmapper
uint tmap_flags = TMAP_FLAG_GOURAUD | TMAP_FLAG_RGB;
@@ -2878,7 +2849,7 @@ void model_render_queue(model_render_params *interp, draw_list *scene, int model
while( i >= 0 ) {
if ( !pm->submodel[i].is_thruster ) {
model_render_children_buffers( scene, interp, pm, pmi, i, detail_level, tmap_flags, trans_buffer );
model_render_children_buffers( scene, interp, pm, i, detail_level, tmap_flags, trans_buffer );
} else {
draw_thrusters = true;
}
@@ -2915,7 +2886,7 @@ void model_render_queue(model_render_params *interp, draw_list *scene, int model
while( i >= 0 ) {
if ( !pm->submodel[i].is_thruster ) {
model_render_children_buffers( scene, interp, pm, pmi, i, detail_level, tmap_flags, trans_buffer );
model_render_children_buffers( scene, interp, pm, i, detail_level, tmap_flags, trans_buffer );
}
i = pm->submodel[i].next_sibling;
@@ -2936,7 +2907,7 @@ void model_render_queue(model_render_params *interp, draw_list *scene, int model
while( i >= 0 ) {
if (pm->submodel[i].is_thruster) {
model_render_children_buffers( scene, interp, pm, pmi, i, detail_level, tmap_flags, trans_buffer );
model_render_children_buffers( scene, interp, pm, i, detail_level, tmap_flags, trans_buffer );
}
i = pm->submodel[i].next_sibling;
}
+4
View File
@@ -392,10 +392,14 @@ public:
static int sortDrawPair(const void* a, const void* b);
};
//void model_immediate_render(int model_num, matrix *orient, vec3d * pos, uint flags = MR_NORMAL, int objnum = -1, int lighting_skip = -1, int *replacement_textures = NULL);
void model_render_immediate(model_render_params *render_info, int model_num, matrix *orient, vec3d * pos, int render = MODEL_RENDER_ALL, bool sort = true);
void model_render_queue(model_render_params *render_info, draw_list* scene, int model_num, matrix *orient, vec3d *pos);
//void model_queue_render(DrawList* scene, int model_num, int model_instance_num, matrix *orient, vec3d *pos, uint flags, int objnum, int *replacement_textures, const bool is_skybox = false);
//void submodel_immediate_render(int model_num, int submodel_num, matrix *orient, vec3d * pos, uint flags = MR_NORMAL, int objnum = -1, int *replacement_textures = NULL);
void submodel_render_immediate(model_render_params *render_info, int model_num, int submodel_num, matrix *orient, vec3d * pos);
void submodel_render_queue(model_render_params *render_info, draw_list *scene, int model_num, int submodel_num, matrix *orient, vec3d * pos);
//void submodel_queue_render(model_render_params *interp, DrawList *scene, int model_num, int submodel_num, matrix *orient, vec3d * pos, uint flags, int objnum = -1);
void model_render_buffers(draw_list* scene, model_render_params* interp, vertex_buffer *buffer, polymodel *pm, int mn, int detail_level, uint tmap_flags);
void model_render_set_thrust(model_render_params *interp, int model_num, mst_info *mst);
void model_render_set_clip_plane(model_render_params *interp, vec3d *pos = NULL, vec3d *normal = NULL);
+1 -1
View File
@@ -854,7 +854,7 @@ void nebl_calc_facing_pts_smart( vec3d *top, vec3d *bot, vec3d *fvec, vec3d *pos
vm_vec_sub( &rvec, &Eye_position, &temp );
vm_vec_normalize( &rvec );
vm_vec_cross(&uvec,fvec,&rvec);
vm_vec_crossprod(&uvec,fvec,&rvec);
vm_vec_normalize(&uvec);
vm_vec_scale_add( top, &temp, &uvec, w/2.0f );
+16 -8
View File
@@ -101,8 +101,8 @@ int Multi_button_info_ok = 0; // flag saying it is ok to apply critical
int Multi_button_info_id = 0; // identifier of the stored button info to be applying
// low level networking vars
int ADDRESS_LENGTH;
int PORT_LENGTH;
int ADDRESS_LENGTH; // will be 6 for IPX, 4 for IP
int PORT_LENGTH; // will be 2 for IPX, 2 for IP
int HEADER_LENGTH; // 1 byte (packet type)
// misc data
@@ -952,6 +952,7 @@ void multi_process_bigdata(ubyte *data, int len, net_addr *from_addr, int reliab
// store fields that were passed along in the message
// store header information that was captured from the network-layer header
memcpy(header_info.addr, from_addr->addr, 6);
memcpy(header_info.net_id, from_addr->net_id, 4);
header_info.port = from_addr->port;
if(player_num >= 0){
header_info.id = Net_players[player_num].player_id;
@@ -1438,11 +1439,14 @@ void standalone_main_init()
// multi_options_read_config();
#ifdef _WIN32
// if we failed to startup on our desired protocol, fail
if ((Multi_options_g.protocol == NET_TCP) && !Tcp_active){
if((Multi_options_g.protocol == NET_IPX) && !Ipx_active){
MessageBox((HWND)os_get_window(), XSTR( "You have selected IPX for multiplayer FreeSpace, but the IPX protocol was not detected on your machine.", 1402), "Error", MB_OK);
exit(1);
}
if((Multi_options_g.protocol == NET_TCP) && !Tcp_active){
if (Tcp_failure_code == WSAEADDRINUSE) {
MessageBox((HWND)os_get_window(), XSTR("You have selected TCP/IP for multiplayer FreeSpace, but the TCP socket is already in use. Check for another instance and/or use the \"-port <port_num>\" command line option to select an available port.", 1620), "Error", MB_OK);
}
else {
} else {
MessageBox((HWND)os_get_window(), XSTR("You have selected TCP/IP for multiplayer FreeSpace, but the TCP/IP protocol was not detected on your machine.", 362), "Error", MB_OK);
}
@@ -1450,13 +1454,17 @@ void standalone_main_init()
}
#endif // ifdef _WIN32
// set the protocol
psnet_use_protocol(Multi_options_g.protocol);
switch (Multi_options_g.protocol) {
case NET_IPX:
ADDRESS_LENGTH = IPX_ADDRESS_LENGTH;
PORT_LENGTH = IPX_PORT_LENGTH;
break;
case NET_TCP:
ADDRESS_LENGTH = IP_ADDRESS_LENGTH;
PORT_LENGTH = IP_PORT_LENGTH;
ADDRESS_LENGTH = IP_ADDRESS_LENGTH;
PORT_LENGTH = IP_PORT_LENGTH;
break;
default:
+4 -2
View File
@@ -92,6 +92,8 @@ class player;
// low level networking defines
#define IP_ADDRESS_LENGTH 4 // length of the address field for an IP address
#define IP_PORT_LENGTH 2 // length of the port field for an IP address
#define IPX_ADDRESS_LENGTH 6 // length of the address field for an IPX address
#define IPX_PORT_LENGTH 2 // length of the port field for an IPX address
// netgame defines
#define MP_SINGLE_MISSION 0 // not playing a campaign - single mission
@@ -760,8 +762,8 @@ extern int Multi_button_info_ok; // flag saying it is ok to apply criti
extern int Multi_button_info_id; // identifier of the stored button info to be applying
// low level networking vars
extern int ADDRESS_LENGTH; // will be 4 for IP
extern int PORT_LENGTH; // will be 2 for IP
extern int ADDRESS_LENGTH; // will be 6 for IPX, 4 for IP
extern int PORT_LENGTH; // will be 2 for IPX, 2 for IP
extern int HEADER_LENGTH; // 1 byte (packet type)
// misc data
+3 -3
View File
@@ -181,8 +181,8 @@ bool multi_oo_sort_func(const short &index1, const short &index2)
dist1 = vm_vec_copy_normalize(&vn1, &v1);
vm_vec_sub(&v2, &OO_player_obj->pos, &obj2->pos);
dist2 = vm_vec_copy_normalize(&vn2, &v2);
dot1 = vm_vec_dot(&OO_player_obj->orient.vec.fvec, &vn1);
dot2 = vm_vec_dot(&OO_player_obj->orient.vec.fvec, &vn2);
dot1 = vm_vec_dotprod(&OO_player_obj->orient.vec.fvec, &vn1);
dot2 = vm_vec_dotprod(&OO_player_obj->orient.vec.fvec, &vn2);
// objects in front take precedence
if((dot1 < 0.0f) && (dot2 >= 0.0f)){
@@ -1984,7 +1984,7 @@ void multi_oo_calc_interp_splines(int ship_index, vec3d *cur_pos, matrix *cur_or
if(!IS_VEC_NULL_SQ_SAFE(&v_norm) && !IS_VEC_NULL_SQ_SAFE(&v_dir)){
vm_vec_normalize(&v_dir);
vm_vec_normalize(&v_norm);
if(vm_vec_dot(&v_dir, &v_norm) < 0.0f){
if(vm_vec_dotprod(&v_dir, &v_norm) < 0.0f){
*new_pos = *cur_pos;
}
}
+8 -2
View File
@@ -1456,8 +1456,14 @@ int multi_voice_max_chunk_size(int msg_mode)
header_size += 2; // targeted player's object net_signature
}
// allocate header space for my address
header_size += 4; // my address (4 bytes in TCP)
// if we're in IPX mode
if(Psnet_my_addr.type == NET_IPX){
header_size += 10; // my address (10 bytes in IPX)
}
// if we're in TCP mode
else {
header_size += 4; // my address (4 bytes in TCP)
}
// calculate max chunk size
return (MAX_PACKET_SIZE - // max freespace packet size
Loaded 100 of 217 files, more files were not shown because too many files have changed in this diff. Show more