From c00cdd0ae306447a453853d15a91dab220377c9b Mon Sep 17 00:00:00 2001 From: yangxiao Date: Mon, 16 Jun 2014 18:22:32 +0800 Subject: [PATCH] use bone dirtyflag --- cocos/3d/CCAnimationCurve.inl | 2 +- cocos/3d/CCMeshSkin.cpp | 23 +++++++++++++---------- cocos/3d/CCMeshSkin.h | 2 -- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cocos/3d/CCAnimationCurve.inl b/cocos/3d/CCAnimationCurve.inl index bdcd6284be..db31834ea3 100644 --- a/cocos/3d/CCAnimationCurve.inl +++ b/cocos/3d/CCAnimationCurve.inl @@ -12,7 +12,7 @@ void AnimationCurve::evaluate(float time, float* dst, EvaluateTyp } else if (time >= _keytime[_count - 1]) { - memcpy(dst, &_value[(_count - 1) * floatSize], _componentSizeByte); + memcpy(dst, &_value[(_count - 1) * componentSize], _componentSizeByte); return; } diff --git a/cocos/3d/CCMeshSkin.cpp b/cocos/3d/CCMeshSkin.cpp index 80f8881246..e4b235b23a 100644 --- a/cocos/3d/CCMeshSkin.cpp +++ b/cocos/3d/CCMeshSkin.cpp @@ -121,6 +121,9 @@ void Bone::setAnimationValue(float* trans, float* rot, float* scale, float weigh state.localRot.set(rot); if (scale) state.localScale.set(scale); + + if (_name != "L_side01" && _name != "L_side03" && _name != "L_side02") + CCASSERT(fabs(scale[0] - 1) < 0.001f, ""); state.weight = weight; _blendStates.push_back(state); @@ -224,11 +227,13 @@ void Bone::updateLocalMat() } if (total) { - if (_blendStates.size() == 1) + //if (_blendStates.size() == 1) + if (true) { - translate = _blendStates[0].localTranslate; - scale = _blendStates[0].localScale; - quat = _blendStates[0].localRot; + int cnt = _blendStates.size(); + translate = _blendStates[cnt - 1].localTranslate; + scale = _blendStates[cnt - 1].localScale; + quat = _blendStates[cnt - 1].localRot; } else { @@ -263,13 +268,11 @@ void Bone::updateLocalMat() _blendStates.clear(); _localDirty = false; } + else + { + CCLOG("use cached local"); + } - -} - -void Bone::clearBlendState() -{ - _blendStates.clear(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/cocos/3d/CCMeshSkin.h b/cocos/3d/CCMeshSkin.h index e6295ea0f1..4bdfdaea0b 100644 --- a/cocos/3d/CCMeshSkin.h +++ b/cocos/3d/CCMeshSkin.h @@ -131,8 +131,6 @@ protected: */ void updateLocalMat(); - void clearBlendState(); - std::string _name; /** * The Mat4 representation of the Joint's bind pose.