Game Development Community

StaticShape, the DecalManager and "onDeleteNofify()"

by Stefan Beffy Moises · in Torque Game Engine · 01/16/2003 (10:40 pm) · 1 replies

Ok, I've got "breakable glass", which is a StaticShape.
And I use the DecalManager to add decals to the "glass" if I shoot at it...
works very well... BUT: the decals aren't deleted if the glass is deleted... :(
So I tried to save the "hitObject" (my glass) with every DecalInstance... therefore I've added:
void addDecal(Point3F pos, Point3F normal, DecalData* decalData, SceneObject* hitObject);
and
void DecalManager::onDeleteNotify(SceneObject* Obj)
{
   Con::printf("DecalManager::onDeleteNotify called!");
   for(S32 i = mDecalQueue.size() - 1; i >= 0; i--)
   {
      DecalInstance *inst = mDecalQueue[i];
      if(inst->hitObject == Obj)
      {
         freeDecalInstance(inst);
         mDecalQueue.erase(U32(i));
      }
   }
	// Do Parent.
	Parent::onDeleteNotify(Obj);
}

void DecalManager::addDecal(Point3F pos, Point3F normal, DecalData* decalData, SceneObject* hitObject)
{
   if (smMaxNumDecals == 0)
      return;
   

	//processAfter(hitObject);
	if(hitObject != NULL)
	{
		Con::printf("deleteNotify for hitObject %s!", hitObject->getClassName());
		deleteNotify(hitObject);
	}
   // DMM: Rework this, should be based on time
   if(mDecalQueue.size() >= smMaxNumDecals)
   {
      DecalInstance* holder = mDecalQueue.front();
      mDecalQueue.pop_front();
      freeDecalInstance(holder);
   }

   Point3F vecX, vecY;
   DecalInstance* newDecal = allocateDecalInstance();
   newDecal->decalData = decalData;
   newDecal->hitObject = hitObject;
   newDecal->allocTime = Platform::getVirtualMilliseconds();

...
to the decalManager class...
but DecalManager::onDeleteNotify is never called if the "hitObject" is deleted...
Any ideas of hints how to use "deleteNotify()"?
Thanks!

#1
01/17/2003 (12:44 am)
*slaps himself*

Well, if ya use
void DecalManager::onDeleteNotify([b]SimObject*[/b] Obj)
it works just fine... ;P