Skip to content

Commit

Permalink
Animation : Fix transition between re-targeted animation and non-re-t…
Browse files Browse the repository at this point in the history
…argeted animation
  • Loading branch information
TothBenoit committed Oct 11, 2024
1 parent ae5f306 commit 4f83b4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion h3d/anim/SmoothTarget.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SmoothTarget extends Animation {
initObjects();
}

static var tmpMat : Matrix = new h3d.Matrix();
function initObjects() {
objects = [];
for( o in target.getObjects() ) {
Expand All @@ -45,8 +46,19 @@ class SmoothTarget extends Animation {
s.targetSkin = o.targetSkin;
s.targetJoint = o.targetJoint;
objects.push(s);
if( o.targetSkin != null )
if( o.targetSkin != null ) {
mat = @:privateAccess o.targetSkin.currentRelPose[o.targetJoint];
if ( mat != null && o.targetSkin.prevEnableRetargeting ) {
var j = @:privateAccess o.targetSkin.skinData.allJoints[o.targetJoint];
if ( j != null && j.retargetAnim ) {
tmpMat.load(mat);
mat = tmpMat;
mat._41 = j.defMat._41;
mat._42 = j.defMat._42;
mat._43 = j.defMat._43;
}
}
}
else if( o.targetObject != null )
mat = o.targetObject.defaultTransform;
if( mat == null )
Expand Down
2 changes: 2 additions & 0 deletions h3d/scene/Skin.hx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Skin extends MultiMaterial {

public var showJoints : Bool;
public var enableRetargeting : Bool = true;
public var prevEnableRetargeting : Bool = true;

public function new(s, ?mat, ?parent) {
super(null, mat, parent);
Expand Down Expand Up @@ -248,6 +249,7 @@ class Skin extends MultiMaterial {
}
skinShader.bonesMatrixes = currentPalette;
jointsUpdated = false;
prevEnableRetargeting = enableRetargeting;
}

override function emit( ctx : RenderContext ) {
Expand Down

0 comments on commit 4f83b4d

Please sign in to comment.