浏览代码

DynamicBones: cleaning some code

lviguier 7 月之前
父节点
当前提交
dcadec7a44
共有 3 个文件被更改,包括 8 次插入2 次删除
  1. 1 1
      h3d/anim/Skin.hx
  2. 0 1
      h3d/scene/Object.hx
  3. 7 0
      h3d/scene/Skin.hx

+ 1 - 1
h3d/anim/Skin.hx

@@ -30,7 +30,7 @@ class Joint {
 
 class DynamicJoint extends Joint {
 	public static var STAMP : Float = 0.0;
-	public static var SLEEP_THRESHOLD : Float = 0.0;
+	public static var SLEEP_THRESHOLD : Float = 0.05;
 
 
 	public var absPos : h3d.Matrix; // Abs pos of the joint computed each frame

+ 0 - 1
h3d/scene/Object.hx

@@ -770,7 +770,6 @@ class Object {
 		var prevCollider = ctx.cullingCollider;
 		if(inheritCulled)
 			ctx.cullingCollider = cullingCollider;
-
 		var changed = posChanged;
 		// absPos up to date during sync
 		if( changed ) calcAbsPos();

+ 7 - 0
h3d/scene/Skin.hx

@@ -251,6 +251,11 @@ class Skin extends MultiMaterial {
 		syncJoints();
 	}
 
+	override function syncRec( ctx : RenderContext ) {
+		posChanged = true;
+		super.syncRec(ctx);
+	}
+
 	static var TMP_MAT = new h3d.Matrix();
 
 	@:noDebug
@@ -299,11 +304,13 @@ class Skin extends MultiMaterial {
 		DynamicJoint.STAMP = Timer.stamp();
 
 		// Update dynamic joints
+		var shouldUpdate = false;
 		for( j in skinData.allJoints ) {
 			if ( j.follow != null ) continue;
 			var dynJoint = Std.downcast(j, h3d.anim.Skin.DynamicJoint);
 			if (dynJoint == null) continue;
 
+			shouldUpdate = true;
 			var absPos = dynJoint.absPos == null ? currentAbsPose[dynJoint.index] : dynJoint.absPos;
 			var newWorldPos = absPos.getPosition().clone();
 			var expectedPos = absPos.getPosition().clone();