diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index 66356ee..bedd1ef 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -721,7 +721,7 @@ void Avatar::applyWorldEffects(WorldType type) skeletalSprite.setFreeze(false); if (!skeletalSprite.getParent()) { - addChild(&skeletalSprite, PM_STATIC); + addChild(&skeletalSprite, PM_NONE); } skeletalSprite.position = Vector(0,0,0); skeletalSprite.scale = Vector(1,1,1); diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index c6098a3..c5f9346 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -237,9 +237,8 @@ Entity::Entity() - skeletalSprite.updateAfterParent = 1; skeletalSprite.setAnimationKeyNotify(this); - addChild(&skeletalSprite, PM_STATIC); + addChild(&skeletalSprite, PM_NONE); @@ -1471,6 +1470,8 @@ void Entity::onEndOfLife() dsq->game->entityDied(this); calledEntityDied = true; } + + skeletalSprite.safeKill(); } void Entity::setPoison(float m, float t) @@ -1692,6 +1693,8 @@ void Entity::onUpdate(float dt) } updateLance(dt); + + skeletalSprite.update(dt); } void Entity::updateBoneLock() diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index d05c92a..ff2715e 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -98,7 +98,6 @@ RenderObject::RenderObject() addType(SCO_RENDEROBJECT); useOldDT = false; - updateAfterParent = false; ignoreUpdate = false; overrideRenderPass = OVERRIDE_NONE; renderPass = 0; @@ -146,6 +145,7 @@ RenderObject::RenderObject() RenderObject::~RenderObject() { freeMotionBlur(); + assert(children.empty()); // if this fires some objects were not deleted and will leak } Vector RenderObject::getWorldPosition() const @@ -335,16 +335,9 @@ void RenderObject::destroy() // must do this first // otherwise child will try to remove THIS (*i)->parent = 0; - switch ((*i)->pm) - { - case PM_STATIC: - (*i)->destroy(); - break; - case PM_POINTER: - (*i)->destroy(); + (*i)->destroy(); + if((*i)->pm == PM_POINTER) delete (*i); - break; - } } children.clear(); @@ -766,19 +759,7 @@ void RenderObject::update(float dt) } if (!isDead()) { - onUpdate(dt); - - if (isHidden()) - return; - - for (Children::iterator i = children.begin(); i != children.end(); i++) - { - if ((*i)->updateAfterParent && (((*i)->pm == PM_POINTER) || ((*i)->pm == PM_STATIC))) - { - (*i)->update(dt); - } - } } } @@ -881,7 +862,7 @@ void RenderObject::onUpdate(float dt) if (shareColorWithChildren) (*i)->color = this->color; - if (!(*i)->updateAfterParent && (((*i)->pm == PM_POINTER) || ((*i)->pm == PM_STATIC))) + if ((*i)->pm != PM_NONE) { (*i)->update(dt); } @@ -900,7 +881,8 @@ void RenderObject::onUpdate(float dt) { ro->parent = NULL; ro->destroy(); - delete ro; + if(ro->pm == PM_POINTER) + delete ro; } else children[w++] = ro; diff --git a/BBGE/RenderObject.h b/BBGE/RenderObject.h index 3f6cdec..8e7c22b 100644 --- a/BBGE/RenderObject.h +++ b/BBGE/RenderObject.h @@ -48,9 +48,9 @@ enum AutoSize enum ParentManaged { - PM_NONE = 0, - PM_POINTER = 1, - PM_STATIC = 2 + PM_NONE = 0, // child is destroyed with parent, but not deleted. The childs' update() is NOT called. + PM_POINTER = 1, // child is deleted together with parent. update() is called. + PM_STATIC = 2 // child is destroyed with parent, but not deleted. update() is called. }; enum ChildOrder @@ -237,7 +237,6 @@ public: // TODO: this should be a bitmask bool fadeAlphaWithLife; bool renderBeforeParent; - bool updateAfterParent; bool shareAlphaWithChildren; bool shareColorWithChildren; bool cull; diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index e6320ce..5954266 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -804,6 +804,9 @@ SkeletalSprite::SkeletalSprite() : RenderObject() selectedBone = -1; } +SkeletalSprite::~SkeletalSprite() +{ +} void SkeletalSprite::setAnimationKeyNotify(RenderObject *r) { diff --git a/BBGE/SkeletalSprite.h b/BBGE/SkeletalSprite.h index f8308ec..67570c2 100644 --- a/BBGE/SkeletalSprite.h +++ b/BBGE/SkeletalSprite.h @@ -225,6 +225,8 @@ class SkeletalSprite : public RenderObject public: SkeletalSprite(); + virtual ~SkeletalSprite(); + void loadSkeletal(const std::string &fn); bool saveSkeletal(const std::string &fn); void loadSkin(const std::string &fn);