I have no idea what happened to it, it was running like a dream, fast and clean then suddenly I change one thing and it dies, and changeing the one little thing back does not fix it, I'm thinking I might have to start back from the base code that wasn't working
I am so befudlled
incedently the new culling and rendering code is
void cull_def_points( decal *dec){
//first compare every point in every polly with every point in every other polly
//and if they are at the same place make them the same point
for(int i =0; in_poly; i++){
for(int k = i+1; kn_poly; k++){
for(int g = 0; gpoly[i].n_point; g++){
for(int h = 0; hpoly[k].n_point; h++){
if(
(dec->vert[dec->poly[i].point[g]].xyz.x == dec->vert[dec->poly[k].point[h]].xyz.x) &&
(dec->vert[dec->poly[i].point[g]].xyz.y == dec->vert[dec->poly[k].point[h]].xyz.y) &&
(dec->vert[dec->poly[i].point[g]].xyz.z == dec->vert[dec->poly[k].point[h]].xyz.z) )
dec->poly[i].point[g] = dec->poly[k].point[h];
}
}
}
}
//now go through and find every point that isn't used
int end_points = 0;
bool *p = new bool[dec->n_def];
memset((void*)p, false, dec->n_def);
for(i =0; in_poly; i++){
for(int g = 0; gpoly[i].n_point; g++){
if(!p[dec->poly[i].point[g]])end_points++;
p[dec->poly[i].point[g]] = true;
}
}
vector *new_def = new vector[end_points];
Assert( new_def );
//copy all the used def points and update those pollies that refrence them
int k = 0;
for(i = 0; in_def; i++){
if(p[i]){
new_def[k] = dec->vert[i];
for(int g = 0; gn_poly; g++){
for(int h = 0; h< dec->poly[g].n_point; h++){
if(dec->poly[g].point[h] == i)dec->poly[g].point[h] = k;
}
}
k++;
}
}
delete[] dec->vert;
dec->vert = new_def;
dec->n_def = end_points;
delete[] p;
}
and
void decal_render_all(object * obj){
#ifdef DECALS_ENABLED
if(obj->type != OBJ_SHIP){
return;
}
vertex *vecs;
vertex *vlist[MAX_DECAL_POLY_POINT];
// for(int k = 0; k
// mprintf(("about to render all decals\n"));
ship *shipp = &Ships[obj->instance];
polymodel *pm = model_get( shipp->modelnum );
for(int h = 0; h < MAX_SHIP_DECALS; h++){
decal *dec = &shipp->decals[h];
if(dec->is_valid){
mprintf(("decal %d is valid, and has %d polys\n",h,dec->n_poly));
// vector g_pos;
// vm_vec_add(&g_pos, &dec->position, &obj->pos);
float dist = vm_vec_dist(&dec->position, &View_position);
if(dist > (dec->radius*500)){
mprintf(("decal %d too far away to be drawn %0.2f\n", h, dist));
// HUD_printf("decal %d too far away to be drawn %0.2f\n", h, dist);
continue;
}
vecs = new vertex[dec->n_def];
for(int i = 0; in_def; i++){
g3_rotate_vertex(&vecs[i], &dec->vert[i]);
g3_project_vertex(&vecs[i]);
}
for(i = 0; in_poly; i++){
// if((pm->submodel[dec->submodel_parent].blown_off != 0) && (dec->submodel_parent > 0))continue;
Assert(MAX_DECAL_POLY_POINT > dec->poly[i].n_point);
if(MAX_DECAL_POLY_POINT <= dec->poly[i].n_point)break;
for( int j = 0; j < dec->poly[i].n_point; j++){
vecs[j].u = dec->poly[i].uv[j].u;
vecs[j].v = dec->poly[i].uv[j].v;
vlist[j] = &vecs[j];
}
Assert(dec->poly[i].point[j]>=0 || dec->poly[i].point[j]<1000);
gr_set_bitmap(dec->texture, 0, GR_BITBLT_MODE_NORMAL, 1.0f );
if((dec->poly[i].backfaced == 1) && (dec->backfaced_texture > -1)){
gr_set_bitmap(dec->backfaced_texture, 0, GR_BITBLT_MODE_NORMAL, 1.0f );
// mprintf(("drawing decal poly %d, with bitmap %d\n", i, dec->backfaced_texture));
}else{
// mprintf(("drawing decal poly %d, with bitmap %d\n", i, dec->texture));
}
// gr_set_cull(0);
g3_draw_poly(dec->poly[i].n_point, vlist, TMAP_FLAG_TEXTURED | TMAP_FLAG_CORRECT | TMAP_FLAG_RGB | TMAP_FLAG_GOURAUD );
// gr_set_cull(1);
}
delete[] vecs;
}
}
// mprintf(("decals rendered\n"));
#endif
}
neither one of these should be screwing it up, and I'm sure there fine becase decals are being created with 0 pollies (this is before culling), decal create should never fail as it only gets called when there is a weapon colision detected, so there must be something screwed up with the actual generation code, but that isn't posable as I havn't done anything to it!
I'm trying this one more time then going to sleep