Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions code/asteroid/asteroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ 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_DUMB_ROTATE) {
asp->model_instance_num = model_create_instance(false, asip->model_num[asteroid_subtype]);
}

// Add to Asteroid_used_list
asteroid_obj_list_add(objnum);
Expand Down Expand Up @@ -828,10 +833,12 @@ void asteroid_delete( object * obj )

asp = &Asteroids[num];

Assert( Num_asteroids >= 0 );
if (asp->model_instance_num >= 0)
model_delete_instance(asp->model_instance_num);

asp->flags = 0;
Num_asteroids--;
Assert(Num_asteroids >= 0);

asteroid_obj_list_remove( obj );
}
Expand Down Expand Up @@ -930,7 +937,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 = -1;
mc.model_instance_num = Asteroids[num].model_instance_num;
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
Expand Down Expand Up @@ -1107,7 +1114,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos

} else {
// Asteroid is heavier obj
mc.model_instance_num = -1;
mc.model_instance_num = Asteroids[num].model_instance_num;
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
Expand Down
1 change: 1 addition & 0 deletions code/asteroid/asteroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class asteroid_info
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
Expand Down
2 changes: 2 additions & 0 deletions code/fred2/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ 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;

Expand Down Expand Up @@ -955,6 +956,7 @@ void clear_mission()

Nmodel_flags = DEFAULT_NMODEL_FLAGS;
Nmodel_num = -1;
Nmodel_instance_num = -1;
vm_set_identity(&Nmodel_orient);
Nmodel_bitmap = -1;

Expand Down
42 changes: 21 additions & 21 deletions code/model/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern int model_render_flags_size;
#define MOVEMENT_TYPE_ROT_SPECIAL 2 // for turrets only
#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
#define MOVEMENT_TYPE_DUMB_ROTATE 5


// DA 11/13/98 Reordered to account for difference between max and game
Expand Down Expand Up @@ -121,19 +122,18 @@ 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_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_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_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)
Expand Down Expand Up @@ -300,7 +300,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), sii(NULL),
rad(0.0f), blown_off(0), my_replacement(-1), i_replace(-1), is_live_debris(0), num_live_debris(0),
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),
Expand Down Expand Up @@ -352,8 +352,6 @@ class bsp_info
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;

Expand Down Expand Up @@ -623,6 +621,7 @@ typedef struct insignia {
#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_DUMB_ROTATE (1<<4) // whether this model has a dumb-rotate submodel somewhere

// Goober5000
class texture_info
Expand Down Expand Up @@ -831,7 +830,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(int model_num);
int model_create_instance(bool is_ship, int model_num);
void model_delete_instance(int model_instance_num);

// Goober5000
Expand Down Expand Up @@ -998,7 +997,8 @@ 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(model_subsystem *psub, submodel_instance_info *sii);
extern void submodel_rotate(bsp_info *sm, submodel_instance_info *sii);

// Rotates the angle of a submodel. Use this so the right unlocked axis
// gets stuffed. Does this for stepped rotations
Expand Down Expand Up @@ -1054,8 +1054,8 @@ 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_instance_dumb_rotation(int model_instance_num);
Expand Down Expand Up @@ -1370,7 +1370,7 @@ void model_finish_cloak(int full_cloak);

void model_do_look_at(int model_num); //Bobboau

void model_do_dumb_rotation(int modelnum); //Bobboau
void model_do_dumb_rotations(int model_instance_num = -1);

int model_should_render_engine_glow(int objnum, int bank_obj);

Expand Down
2 changes: 0 additions & 2 deletions code/model/modelinterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2011,8 +2011,6 @@ 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);

Expand Down
Loading