Propagate for variables in similar/main/polyobj.cpp
This commit is contained in:
parent
6d73413170
commit
29a2e905fb
|
@ -131,9 +131,7 @@ static short pof_read_short(ubyte *bufp)
|
||||||
|
|
||||||
static void pof_read_string(char *buf,int max_char, ubyte *bufp)
|
static void pof_read_string(char *buf,int max_char, ubyte *bufp)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i=0; i<max_char; i++) {
|
||||||
|
|
||||||
for (i=0; i<max_char; i++) {
|
|
||||||
if ((*buf++ = bufp[Pof_addr++]) == 0)
|
if ((*buf++ = bufp[Pof_addr++]) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -194,9 +192,9 @@ ubyte * new_dest(chunk o) // return where chunk is (in aligned struct)
|
||||||
*/
|
*/
|
||||||
int get_first_chunks_index(chunk *chunk_list, int no_chunks)
|
int get_first_chunks_index(chunk *chunk_list, int no_chunks)
|
||||||
{
|
{
|
||||||
int i, first_index = 0;
|
int first_index = 0;
|
||||||
Assert(no_chunks >= 1);
|
Assert(no_chunks >= 1);
|
||||||
for (i = 1; i < no_chunks; i++)
|
for (int i = 1; i < no_chunks; i++)
|
||||||
if (old_dest(chunk_list[i]) < old_dest(chunk_list[first_index]))
|
if (old_dest(chunk_list[i]) < old_dest(chunk_list[first_index]))
|
||||||
first_index = i;
|
first_index = i;
|
||||||
return first_index;
|
return first_index;
|
||||||
|
@ -205,7 +203,7 @@ int get_first_chunks_index(chunk *chunk_list, int no_chunks)
|
||||||
|
|
||||||
void align_polygon_model_data(polymodel *pm)
|
void align_polygon_model_data(polymodel *pm)
|
||||||
{
|
{
|
||||||
int i, chunk_len;
|
int chunk_len;
|
||||||
int total_correction = 0;
|
int total_correction = 0;
|
||||||
ubyte *cur_old, *cur_new;
|
ubyte *cur_old, *cur_new;
|
||||||
chunk cur_ch;
|
chunk cur_ch;
|
||||||
|
@ -226,7 +224,7 @@ void align_polygon_model_data(polymodel *pm)
|
||||||
cur_ch = ch_list[first_index];
|
cur_ch = ch_list[first_index];
|
||||||
// remove first chunk from array:
|
// remove first chunk from array:
|
||||||
no_chunks--;
|
no_chunks--;
|
||||||
for (i = first_index; i < no_chunks; i++)
|
for (int i = first_index; i < no_chunks; i++)
|
||||||
ch_list[i] = ch_list[i + 1];
|
ch_list[i] = ch_list[i + 1];
|
||||||
// if (new) address unaligned:
|
// if (new) address unaligned:
|
||||||
if ((u_int32_t)new_dest(cur_ch) % 4L != 0) {
|
if ((u_int32_t)new_dest(cur_ch) % 4L != 0) {
|
||||||
|
@ -234,7 +232,7 @@ void align_polygon_model_data(polymodel *pm)
|
||||||
short to_shift = 4 - (u_int32_t)new_dest(cur_ch) % 4L;
|
short to_shift = 4 - (u_int32_t)new_dest(cur_ch) % 4L;
|
||||||
// correct chunks' addresses
|
// correct chunks' addresses
|
||||||
cur_ch.correction += to_shift;
|
cur_ch.correction += to_shift;
|
||||||
for (i = 0; i < no_chunks; i++)
|
for (int i = 0; i < no_chunks; i++)
|
||||||
ch_list[i].correction += to_shift;
|
ch_list[i].correction += to_shift;
|
||||||
total_correction += to_shift;
|
total_correction += to_shift;
|
||||||
Assert((u_int32_t)new_dest(cur_ch) % 4L == 0);
|
Assert((u_int32_t)new_dest(cur_ch) % 4L == 0);
|
||||||
|
@ -250,7 +248,7 @@ void align_polygon_model_data(polymodel *pm)
|
||||||
chunk_len = get_chunks(cur_old, cur_new, ch_list, &no_chunks);
|
chunk_len = get_chunks(cur_old, cur_new, ch_list, &no_chunks);
|
||||||
memcpy(cur_new, cur_old, chunk_len);
|
memcpy(cur_new, cur_old, chunk_len);
|
||||||
//correct submodel_ptr's for pm, too
|
//correct submodel_ptr's for pm, too
|
||||||
for (i = 0; i < MAX_SUBMODELS; i++)
|
for (int i = 0; i < MAX_SUBMODELS; i++)
|
||||||
if (&pm->model_data[pm->submodel_ptrs[i]] >= cur_old
|
if (&pm->model_data[pm->submodel_ptrs[i]] >= cur_old
|
||||||
&& &pm->model_data[pm->submodel_ptrs[i]] < cur_old + chunk_len)
|
&& &pm->model_data[pm->submodel_ptrs[i]] < cur_old + chunk_len)
|
||||||
pm->submodel_ptrs[i] += (cur_new - tmp) - (cur_old - pm->model_data.get());
|
pm->submodel_ptrs[i] += (cur_new - tmp) - (cur_old - pm->model_data.get());
|
||||||
|
@ -336,14 +334,13 @@ static polymodel *read_model_file(polymodel *pm,const char *filename,robot_info
|
||||||
case ID_GUNS: { //List of guns on this object
|
case ID_GUNS: { //List of guns on this object
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
int i;
|
|
||||||
vms_vector gun_dir;
|
vms_vector gun_dir;
|
||||||
|
|
||||||
r->n_guns = pof_read_int(model_buf);
|
r->n_guns = pof_read_int(model_buf);
|
||||||
|
|
||||||
Assert(r->n_guns <= MAX_GUNS);
|
Assert(r->n_guns <= MAX_GUNS);
|
||||||
|
|
||||||
for (i=0;i<r->n_guns;i++) {
|
for (int i=0;i<r->n_guns;i++) {
|
||||||
uint_fast32_t id;
|
uint_fast32_t id;
|
||||||
|
|
||||||
id = pof_read_short(model_buf);
|
id = pof_read_short(model_buf);
|
||||||
|
@ -369,14 +366,14 @@ static polymodel *read_model_file(polymodel *pm,const char *filename,robot_info
|
||||||
|
|
||||||
case ID_ANIM: //Animation data
|
case ID_ANIM: //Animation data
|
||||||
if (r) {
|
if (r) {
|
||||||
int n_frames,f,m;
|
int n_frames;
|
||||||
|
|
||||||
n_frames = pof_read_short(model_buf);
|
n_frames = pof_read_short(model_buf);
|
||||||
|
|
||||||
Assert(n_frames == N_ANIM_STATES);
|
Assert(n_frames == N_ANIM_STATES);
|
||||||
|
|
||||||
for (m=0;m<pm->n_models;m++)
|
for (int m=0;m<pm->n_models;m++)
|
||||||
for (f=0;f<n_frames;f++)
|
for (int f=0;f<n_frames;f++)
|
||||||
pof_read_angs(&anim_angs[f][m], 1, model_buf);
|
pof_read_angs(&anim_angs[f][m], 1, model_buf);
|
||||||
|
|
||||||
|
|
||||||
|
@ -464,12 +461,9 @@ int read_model_guns(const char *filename,vms_vector *gun_points, vms_vector *gun
|
||||||
len = pof_read_int(model_buf);
|
len = pof_read_int(model_buf);
|
||||||
|
|
||||||
if (id == ID_GUNS) { //List of guns on this object
|
if (id == ID_GUNS) { //List of guns on this object
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
n_guns = pof_read_int(model_buf);
|
n_guns = pof_read_int(model_buf);
|
||||||
|
|
||||||
for (i=0;i<n_guns;i++) {
|
for (int i=0;i<n_guns;i++) {
|
||||||
int id,sm;
|
int id,sm;
|
||||||
|
|
||||||
id = pof_read_short(model_buf);
|
id = pof_read_short(model_buf);
|
||||||
|
@ -509,8 +503,6 @@ bitmap_index texture_list_index[MAX_POLYOBJ_TEXTURES];
|
||||||
void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angles,int model_num,int flags,g3s_lrgb light,glow_values_t *glow_values,bitmap_index alt_textures[])
|
void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angles,int model_num,int flags,g3s_lrgb light,glow_values_t *glow_values,bitmap_index alt_textures[])
|
||||||
{
|
{
|
||||||
polymodel *po;
|
polymodel *po;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (model_num < 0)
|
if (model_num < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -535,14 +527,14 @@ void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angl
|
||||||
|
|
||||||
if (alt_textures)
|
if (alt_textures)
|
||||||
{
|
{
|
||||||
for (i=0;i<po->n_textures;i++) {
|
for (int i=0;i<po->n_textures;i++) {
|
||||||
texture_list_index[i] = alt_textures[i];
|
texture_list_index[i] = alt_textures[i];
|
||||||
texture_list[i] = &GameBitmaps[alt_textures[i].index];
|
texture_list[i] = &GameBitmaps[alt_textures[i].index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i=0;i<po->n_textures;i++) {
|
for (int i=0;i<po->n_textures;i++) {
|
||||||
texture_list_index[i] = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]];
|
texture_list_index[i] = ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]];
|
||||||
texture_list[i] = &GameBitmaps[ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index];
|
texture_list[i] = &GameBitmaps[ObjBitmaps[ObjBitmapPtrs[po->first_texture+i]].index];
|
||||||
}
|
}
|
||||||
|
@ -550,13 +542,13 @@ void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angl
|
||||||
|
|
||||||
// Make sure the textures for this object are paged in...
|
// Make sure the textures for this object are paged in...
|
||||||
piggy_page_flushed = 0;
|
piggy_page_flushed = 0;
|
||||||
for (i=0;i<po->n_textures;i++)
|
for (int i=0;i<po->n_textures;i++)
|
||||||
PIGGY_PAGE_IN( texture_list_index[i] );
|
PIGGY_PAGE_IN( texture_list_index[i] );
|
||||||
// Hmmm... cache got flushed in the middle of paging all these in,
|
// Hmmm... cache got flushed in the middle of paging all these in,
|
||||||
// so we need to reread them all in.
|
// so we need to reread them all in.
|
||||||
if (piggy_page_flushed) {
|
if (piggy_page_flushed) {
|
||||||
piggy_page_flushed = 0;
|
piggy_page_flushed = 0;
|
||||||
for (i=0;i<po->n_textures;i++)
|
for (int i=0;i<po->n_textures;i++)
|
||||||
PIGGY_PAGE_IN( texture_list_index[i] );
|
PIGGY_PAGE_IN( texture_list_index[i] );
|
||||||
}
|
}
|
||||||
// Make sure that they can all fit in memory.
|
// Make sure that they can all fit in memory.
|
||||||
|
@ -571,9 +563,7 @@ void draw_polygon_model(vms_vector *pos,vms_matrix *orient,vms_angvec *anim_angl
|
||||||
g3_draw_polygon_model(po->model_data.get(),&texture_list[0],anim_angles,light,glow_values);
|
g3_draw_polygon_model(po->model_data.get(),&texture_list[0],anim_angles,light,glow_values);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
int i;
|
for (int i=0;flags;flags>>=1,i++)
|
||||||
|
|
||||||
for (i=0;flags;flags>>=1,i++)
|
|
||||||
if (flags & 1) {
|
if (flags & 1) {
|
||||||
vms_vector ofs;
|
vms_vector ofs;
|
||||||
|
|
||||||
|
@ -605,13 +595,12 @@ static void polyobj_find_min_max(polymodel *pm)
|
||||||
ushort nverts;
|
ushort nverts;
|
||||||
vms_vector *vp;
|
vms_vector *vp;
|
||||||
ushort *data,type;
|
ushort *data,type;
|
||||||
int m;
|
|
||||||
vms_vector *big_mn,*big_mx;
|
vms_vector *big_mn,*big_mx;
|
||||||
|
|
||||||
big_mn = &pm->mins;
|
big_mn = &pm->mins;
|
||||||
big_mx = &pm->maxs;
|
big_mx = &pm->maxs;
|
||||||
|
|
||||||
for (m=0;m<pm->n_models;m++) {
|
for (int m=0;m<pm->n_models;m++) {
|
||||||
vms_vector *mn,*mx,*ofs;
|
vms_vector *mn,*mx,*ofs;
|
||||||
|
|
||||||
mn = &pm->submodel_mins[m];
|
mn = &pm->submodel_mins[m];
|
||||||
|
|
Loading…
Reference in a new issue