BGE: (partial?) fix for #34330 "Action Actuator "caching" the previous ran actions" reported by Dalai. The test file now works if all of the actions are using the same layer, but multiple layers can still cause problems. However, I am unsure as to what the "correct" behavior should be with multiple layers. They should probably blend somehow...

This commit is contained in:
Mitchell Stokes 2013-02-22 23:55:06 +00:00
parent 3d9dc6a2e4
commit d05cb9bca5
3 changed files with 36 additions and 14 deletions

@ -162,23 +162,29 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_B
}
}
return ipocontr;
}
SG_Controller *BL_CreateObColorIPO(struct bAction *action, KX_GameObject* gameobj, KX_BlenderSceneConverter *converter)
{
KX_ObColorIpoSGController* ipocontr_obcol=NULL;
KX_IInterpolator *interpolator;
KX_IScalarInterpolator *interp;
BL_InterpolatorList *adtList= GetAdtList(action, converter);
for (int i=0; i<4; i++) {
if ((interp = adtList->GetScalarInterpolator("color", i))) {
if (!ipocontr_obcol) {
ipocontr_obcol = new KX_ObColorIpoSGController();
gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
ipocontr_obcol->SetObject(gameobj->GetSGNode());
}
interpolator= new KX_ScalarInterpolator(&ipocontr_obcol->m_rgba[i], interp);
ipocontr_obcol->AddInterpolator(interpolator);
}
}
}
return ipocontr;
return ipocontr_obcol;
}
void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_BlenderSceneConverter *converter)
@ -187,6 +193,12 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
SG_Controller *ipocontr = BL_CreateIPO(blenderobject->adt->action, gameobj, converter);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
SG_Controller *ipocontr_obcol = BL_CreateObColorIPO(blenderobject->adt->action, gameobj, converter);
if (ipocontr_obcol) {
gameobj->GetSGNode()->AddSGController(ipocontr_obcol);
ipocontr_obcol->SetObject(gameobj->GetSGNode());
}
}
}

@ -37,7 +37,9 @@ struct Object;
class SG_Controller *BL_CreateIPO(struct bAction *action,
class KX_GameObject* gameobj,
class KX_BlenderSceneConverter *converter);
class SG_Controller *BL_CreateObColorIPO(struct bAction *action,
class KX_GameObject* gameobj,
class KX_BlenderSceneConverter *converter);
void BL_ConvertIpos(struct Object* blenderobject,
class KX_GameObject* gameobj,
class KX_BlenderSceneConverter *converter);

@ -162,6 +162,14 @@ bool BL_Action::Play(const char* name,
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
// Try obcolor
sg_contr = BL_CreateObColorIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter());
if (sg_contr) {
m_sg_contr_list.push_back(sg_contr);
m_obj->GetSGNode()->AddSGController(sg_contr);
sg_contr->SetObject(m_obj->GetSGNode());
}
// Extra controllers
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)
{