|
@@ -252,11 +252,6 @@ class Skin extends MultiMaterial {
|
|
syncJoints();
|
|
syncJoints();
|
|
}
|
|
}
|
|
|
|
|
|
- override function syncRec( ctx : RenderContext ) {
|
|
|
|
- posChanged = posChanged || dynUpdated;
|
|
|
|
- super.syncRec(ctx);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
static var TMP_MAT = new h3d.Matrix();
|
|
static var TMP_MAT = new h3d.Matrix();
|
|
|
|
|
|
@:noDebug
|
|
@:noDebug
|
|
@@ -293,15 +288,15 @@ class Skin extends MultiMaterial {
|
|
if( bid >= 0 )
|
|
if( bid >= 0 )
|
|
currentPalette[bid].multiply3x4inline(j.transPos, m);
|
|
currentPalette[bid].multiply3x4inline(j.transPos, m);
|
|
}
|
|
}
|
|
|
|
+
|
|
skinShader.bonesMatrixes = currentPalette;
|
|
skinShader.bonesMatrixes = currentPalette;
|
|
jointsUpdated = false;
|
|
jointsUpdated = false;
|
|
prevEnableRetargeting = enableRetargeting;
|
|
prevEnableRetargeting = enableRetargeting;
|
|
-
|
|
|
|
- syncDynamicJoints();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function syncDynamicJoints() {
|
|
function syncDynamicJoints() {
|
|
// Update dynamic joints
|
|
// Update dynamic joints
|
|
|
|
+ dynUpdated = false;
|
|
for( j in skinData.allJoints ) {
|
|
for( j in skinData.allJoints ) {
|
|
if ( j.follow != null ) continue;
|
|
if ( j.follow != null ) continue;
|
|
var dynJoint = Std.downcast(j, h3d.anim.Skin.DynamicJoint);
|
|
var dynJoint = Std.downcast(j, h3d.anim.Skin.DynamicJoint);
|
|
@@ -317,8 +312,10 @@ class Skin extends MultiMaterial {
|
|
|
|
|
|
// Damping (inertia attenuation)
|
|
// Damping (inertia attenuation)
|
|
dynJoint.speed *= 1.0 - dynJoint.damping;
|
|
dynJoint.speed *= 1.0 - dynJoint.damping;
|
|
- if (dynJoint.speed.lengthSq() > DynamicJoint.SLEEP_THRESHOLD)
|
|
|
|
|
|
+ if (dynJoint.speed.lengthSq() > DynamicJoint.SLEEP_THRESHOLD) {
|
|
newWorldPos += dynJoint.speed * hxd.Timer.dt;
|
|
newWorldPos += dynJoint.speed * hxd.Timer.dt;
|
|
|
|
+ dynUpdated = true;
|
|
|
|
+ }
|
|
|
|
|
|
// Stiffness (shape keeper)
|
|
// Stiffness (shape keeper)
|
|
var parentMovement = currentAbsPose[j.parent.index].getPosition() - currentAbsPose[dynJoint.parent.index].getPosition();
|
|
var parentMovement = currentAbsPose[j.parent.index].getPosition() - currentAbsPose[dynJoint.parent.index].getPosition();
|
|
@@ -336,12 +333,10 @@ class Skin extends MultiMaterial {
|
|
currentAbsPose[j.index].setPosition(newWorldPos);
|
|
currentAbsPose[j.index].setPosition(newWorldPos);
|
|
dynJoint.absPos = currentAbsPose[j.index];
|
|
dynJoint.absPos = currentAbsPose[j.index];
|
|
|
|
|
|
- var offset = absPos.getPosition() - newWorldPos;
|
|
|
|
- if (Math.abs(offset.length()) >= DynamicJoint.SLEEP_THRESHOLD)
|
|
|
|
- dynUpdated = true;
|
|
|
|
-
|
|
|
|
if( dynJoint.bindIndex >= 0 )
|
|
if( dynJoint.bindIndex >= 0 )
|
|
currentPalette[dynJoint.bindIndex].multiply3x4inline(j.transPos, currentAbsPose[j.index]);
|
|
currentPalette[dynJoint.bindIndex].multiply3x4inline(j.transPos, currentAbsPose[j.index]);
|
|
|
|
+
|
|
|
|
+ skinShader.bonesMatrixes = currentPalette;
|
|
}
|
|
}
|
|
|
|
|
|
// Update transforms
|
|
// Update transforms
|
|
@@ -383,11 +378,17 @@ class Skin extends MultiMaterial {
|
|
recomputeAbsPosFrom(cast s);
|
|
recomputeAbsPosFrom(cast s);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (dynUpdated)
|
|
|
|
+ jointsUpdated = true;
|
|
|
|
+
|
|
|
|
+ skinShader.bonesMatrixes = currentPalette;
|
|
}
|
|
}
|
|
|
|
|
|
override function emit( ctx : RenderContext ) {
|
|
override function emit( ctx : RenderContext ) {
|
|
calcScreenRatio(ctx);
|
|
calcScreenRatio(ctx);
|
|
syncJoints(); // In case sync was not called because of culling (eg fixedPosition)
|
|
syncJoints(); // In case sync was not called because of culling (eg fixedPosition)
|
|
|
|
+ syncDynamicJoints();
|
|
if( splitPalette == null )
|
|
if( splitPalette == null )
|
|
super.emit(ctx);
|
|
super.emit(ctx);
|
|
else {
|
|
else {
|