Skip to content

Commit

Permalink
sc_light_remove(ENTITY* ent) added
Browse files Browse the repository at this point in the history
sc_light_remove(ENTITY* ent) added. This function removes the shade-c light and frees all the memory stuff.
  • Loading branch information
oliver2s committed Feb 6, 2014
1 parent 20f7013 commit 9b813c7
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion examples/shadec/sc_lights.c
Expand Up @@ -4,6 +4,40 @@

// Light handling functions

void sc_light_remove(ENTITY* ent)
{
if(ent==NULL){ return; }
if(!ent.SC_SKILL){ return; }

SC_OBJECT* myData = (SC_OBJECT*)ent.SC_SKILL;

if(myData.light!=NULL)
{
if(myData.light.view!=NULL)
{
if(myData.light.view.stage!=NULL)
{
if(myData.light.view.stage.material!=NULL){ ptr_remove(myData.light.view.stage.material); }
ptr_remove(myData.light.view.stage);
}

if(myData.light.view.material!=NULL){ ptr_remove(myData.light.view.material); }
if(myData.light.view.bmap!=NULL){ bmap_purge(myData.light.view.bmap); ptr_remove(myData.light.view.bmap); }

ptr_remove(myData.light.view);
}
if(myData.light.shadowMap!=NULL){ bmap_purge(myData.light.shadowMap); ptr_remove(myData.light.shadowMap); }
if(myData.light.matrix!=NULL){sys_free(myData.light.matrix);}

sys_free(myData.light);
}

sys_free(myData.data);
sys_free(myData);

ptr_remove(ent);
}

void sc_light_updatePointMtx(ENTITY* inLight)
{
//static D3DXMATRIX testmtx;
Expand Down Expand Up @@ -1359,4 +1393,4 @@ void sc_lights_frmSun(SC_SCREEN* screen)


}
}
}

2 comments on commit 9b813c7

@infinitehmp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes Lightsdata and gets cache Free for new lights 👍

@DavidJ75
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found a bug (if not already seen): If no model, which has a "shade-c"-material, is rendering on the screen, the hole screen is painted into a blue color. F.E.: If I watch away with my camera, where no model is to see. :(

Please sign in to comment.