浏览代码

Fix null in lookAt

trethaller 6 年之前
父节点
当前提交
8ce21bda30
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 4 2
      hide/prefab/fx/FX.hx
  2. 2 1
      hide/prefab/fx/LookAt.hx

+ 4 - 2
hide/prefab/fx/FX.hx

@@ -295,9 +295,11 @@ class FX extends hxd.prefab.Library {
 		{
 			var p = elt.getOpt(LookAt);
 			if(p != null) {
-				anyFound = true;
 				var ctx = ctx.shared.contexts.get(p);
-				lookAt = cast ctx.custom;
+				if(ctx != null) {
+					anyFound = true;
+					lookAt = cast ctx.custom;
+				}
 			}
 		}
 

+ 2 - 1
hide/prefab/fx/LookAt.hx

@@ -16,7 +16,7 @@ class LookAtInstance {
 	static var tmpMat = new h3d.Matrix();
 	static var deltaVec = new h3d.Vector();
 	static var lockAxis = new h3d.Vector();
-	static var invParentQ = new h3d.Quat();
+	static var tempQ = new h3d.Quat();
 	public function apply() {
 		if(object == null || object.getScene() == null)
 			return;
@@ -33,6 +33,7 @@ class LookAtInstance {
 
 		tmpMat.load(object.parent.getAbsPos());
 		tmpMat.invert();
+		var invParentQ = tempQ;
 		invParentQ.initRotateMatrix(tmpMat);
 
 		if(definition.lockAxis != null) {