Преглед на файлове

[animgraph] Fix null animations on input nodes

Clément Espeute преди 7 месеца
родител
ревизия
d8467fdee3
променени са 1 файла, в които са добавени 16 реда и са изтрити 5 реда
  1. 16 5
      hrt/animgraph/nodes/Input.hx

+ 16 - 5
hrt/animgraph/nodes/Input.hx

@@ -13,13 +13,18 @@ class Input extends AnimNode {
 	var anim : h3d.anim.Animation;
 	var proxy : AnimProxy;
 
-	@:s var path : String = "character/Kobold01/Anim_attack01.FBX";
-
-
+	@:s var path : String = "";
 
 	override function getBones(ctx: hrt.animgraph.nodes.AnimNode.GetBoneContext):Map<String, Int> {
 		proxy = new AnimProxy();
-		anim = hxd.res.Loader.currentInstance.load(ctx.resolver(path)).toModel().toHmd().loadAnimation().createInstance(proxy);
+		var pathToLoad = ctx.resolver(path);
+		if (pathToLoad == null)
+			return [];
+		try {
+			anim = hxd.res.Loader.currentInstance.load(pathToLoad).toModel().toHmd().loadAnimation().createInstance(proxy);
+		} catch (e) {
+			return [];
+		}
 
 		var map : Map<String, Int> = [];
 		for (id => obj in anim.getObjects()) {
@@ -29,14 +34,20 @@ class Input extends AnimNode {
 	}
 
 	override function tick(dt: Float) {
+		if (anim == null)
+			return;
 		anim.update(dt);
 		@:privateAccess anim.isSync = false;
 	}
 
 	override function getBoneTransform(id: Int, matrix: h3d.Matrix, ctx: AnimNode.GetBoneTransformContext) {
 		// todo : add sync outside the getBoneMatrix to avoid checks
-		@:privateAccess
+		if (anim == null) {
+			matrix.load(ctx.getDefPose());
+			return;
+		}
 
+		@:privateAccess
 		if (!anim.isSync) {
 			anim.sync(true);
 			anim.isSync = true;