Skip to content

Commit

Permalink
UPBGE: Minor BL_ArmatureObject cleanup.
Browse files Browse the repository at this point in the history
Replace member for vert deform type by an access to bAramture::gevertdeformer.
Directly assign time step to m_objArma->pose->ctime instead tracking it in
a member variable.
  • Loading branch information
panzergame committed Oct 14, 2017
1 parent 2e369aa commit ccbfab0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
18 changes: 7 additions & 11 deletions source/gameengine/Converter/BL_ArmatureObject.cpp
Expand Up @@ -205,13 +205,10 @@ static void game_blend_poses(bPose *dst, bPose *src, float srcweight, short mode
BL_ArmatureObject::BL_ArmatureObject(void *sgReplicationInfo,
SG_Callbacks callbacks,
Object *armature,
Scene *scene,
int vert_deform_type)
Scene *scene)
:KX_GameObject(sgReplicationInfo, callbacks),
m_scene(scene),
m_lastframe(0.0),
m_timestep(0.040),
m_vert_deform_type(vert_deform_type),
m_drawDebug(false),
m_lastapplyframe(0.0)
{
Expand Down Expand Up @@ -424,9 +421,6 @@ bool BL_ArmatureObject::UnlinkObject(SCA_IObject *clientobj)

void BL_ArmatureObject::ApplyPose() // TODO: bouger dans SetPoseByAction ?
{
// in the GE, we use ctime to store the timestep
m_objArma->pose->ctime = (float)m_timestep;
//m_scene->r.cfra++;
if (m_lastapplyframe != m_lastframe) {
// update the constraint if any, first put them all off so that only the active ones will be updated
for (BL_ArmatureConstraint *constraint : m_controlledConstraints) {
Expand Down Expand Up @@ -457,8 +451,10 @@ void BL_ArmatureObject::BlendInPose(bPose *blend_pose, float weight, short mode)
bool BL_ArmatureObject::UpdateTimestep(double curtime)
{
if (curtime != m_lastframe) {
// compute the timestep for the underlying IK algorithm
m_timestep = curtime - m_lastframe;
/* Compute the timestep for the underlying IK algorithm,
* in the GE, we use ctime to store the timestep.
*/
m_objArma->pose->ctime = (float)(curtime - m_lastframe);
m_lastframe = curtime;
}

Expand All @@ -474,9 +470,9 @@ Object *BL_ArmatureObject::GetOrigArmatureObject()
return m_origObjArma;
}

int BL_ArmatureObject::GetVertDeformType()
int BL_ArmatureObject::GetVertDeformType() const
{
return m_vert_deform_type;
return ((bArmature *)m_objArma->data)->gevertdeformer;
}

void BL_ArmatureObject::GetPose(bPose **pose) const
Expand Down
8 changes: 2 additions & 6 deletions source/gameengine/Converter/BL_ArmatureObject.h
Expand Up @@ -59,9 +59,6 @@ class BL_ArmatureObject : public KX_GameObject
// Need for BKE_pose_where_is.
Scene *m_scene;
double m_lastframe;
/// Delta since last pose evaluation.
double m_timestep;
int m_vert_deform_type;
size_t m_constraintNumber;
size_t m_channelNumber;
/// Store the original armature object matrix.
Expand All @@ -75,8 +72,7 @@ class BL_ArmatureObject : public KX_GameObject
BL_ArmatureObject(void *sgReplicationInfo,
SG_Callbacks callbacks,
Object *armature,
Scene *scene,
int vert_deform_type);
Scene *scene);
virtual ~BL_ArmatureObject();

virtual CValue *GetReplica();
Expand All @@ -99,7 +95,7 @@ class BL_ArmatureObject : public KX_GameObject

Object *GetArmatureObject();
Object *GetOrigArmatureObject();
int GetVertDeformType();
int GetVertDeformType() const;
bool GetDrawDebug() const;
void DrawDebug(RAS_DebugDraw& debugDraw);

Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Converter/BL_BlenderDataConversion.cpp
Expand Up @@ -962,7 +962,7 @@ static KX_GameObject *BL_GameObjectFromBlenderObject(Object *ob, KX_Scene *kxsce
case OB_ARMATURE:
{
bArmature *arm = (bArmature *)ob->data;
gameobj = new BL_ArmatureObject(kxscene, KX_Scene::m_callbacks, ob, kxscene->GetBlenderScene(), arm->gevertdeformer);
gameobj = new BL_ArmatureObject(kxscene, KX_Scene::m_callbacks, ob, kxscene->GetBlenderScene());

kxscene->AddAnimatedObject(gameobj);

Expand Down

0 comments on commit ccbfab0

Please sign in to comment.