Nicolas Cannasse пре 4 година
родитељ
комит
d893148ec7
2 измењених фајлова са 34 додато и 27 уклоњено
  1. 3 1
      hide/comp/SceneEditor.hx
  2. 31 26
      hrt/prefab/Model.hx

+ 3 - 1
hide/comp/SceneEditor.hx

@@ -1334,8 +1334,10 @@ class SceneEditor {
 
 	function refreshParents( elts : Array<PrefabElement> ) {
 		var parents = new Map();
-		for( e in elts )
+		for( e in elts ) {
+			if( e.parent == null ) throw e+" is missing parent";
 			parents.set(e.parent, true);
+		}
 		for( p in parents.keys() ) {
 			var h = p.getHideProps();
 			if( h.onChildListChanged != null ) h.onChildListChanged();

+ 31 - 26
hrt/prefab/Model.hx

@@ -47,32 +47,8 @@ class Model extends Object3D {
 			for(m in obj.getMeshes())
 				m.cullingCollider = new h3d.col.ObjectCollider(m, m.primitive.getBounds().toSphere());
 			#end
-			if( retargetAnim ) {
-				var ignorePrefix = [], ignoreNames = new Map();
-				if( retargetIgnore != null ) {
-					for( i in retargetIgnore.split(",") ) {
-						if( i.charCodeAt(i.length-1) == "*".code )
-							ignorePrefix.push(i.substr(0,-1));
-						else
-							ignoreNames.set(i, true);
-					}
-				}
-				for( o in obj.getMeshes() ) {
-					var sk = Std.downcast(o, h3d.scene.Skin);
-					if( sk == null ) continue;
-					for( j in sk.getSkinData().allJoints ) {
-						var ignored = ignoreNames.get(j.name);
-						if( ignored ) continue;
-						for( i in ignorePrefix )
-							if( StringTools.startsWith(j.name,i) ) {
-								ignored = true;
-								break;
-							}
-						if( !ignored )
-							j.retargetAnim = true;
-					}
-				}
-			}
+			if( retargetAnim ) applyRetarget(obj);
+
 			obj.name = name;
 			ctx.local3d.addChild(obj);
 			ctx.local3d = obj;
@@ -95,6 +71,35 @@ class Model extends Object3D {
 		return ctx;
 	}
 
+	function applyRetarget( obj : h3d.scene.Object ) {
+		if( !retargetAnim )
+			return;
+		var ignorePrefix = [], ignoreNames = new Map();
+		if( retargetIgnore != null ) {
+			for( i in retargetIgnore.split(",") ) {
+				if( i.charCodeAt(i.length-1) == "*".code )
+					ignorePrefix.push(i.substr(0,-1));
+				else
+					ignoreNames.set(i, true);
+			}
+		}
+		for( o in obj.getMeshes() ) {
+			var sk = Std.downcast(o, h3d.scene.Skin);
+			if( sk == null ) continue;
+			for( j in sk.getSkinData().allJoints ) {
+				var ignored = ignoreNames.get(j.name);
+				if( ignored ) continue;
+				for( i in ignorePrefix )
+					if( StringTools.startsWith(j.name,i) ) {
+						ignored = true;
+						break;
+					}
+				if( !ignored )
+					j.retargetAnim = true;
+			}
+		}
+	}
+
 	#if editor
 	override function edit( ctx : EditContext ) {
 		super.edit(ctx);