فهرست منبع

save history for Camera CopyCurrent

Nicolas Cannasse 4 سال پیش
والد
کامیت
194f9d6b87
3فایلهای تغییر یافته به همراه30 افزوده شده و 18 حذف شده
  1. 1 1
      hide/comp/SceneEditor.hx
  2. 14 0
      hide/prefab/EditContext.hx
  3. 15 17
      hrt/prefab/l3d/Camera.hx

+ 1 - 1
hide/comp/SceneEditor.hx

@@ -98,7 +98,7 @@ class SceneEditorContext extends hide.prefab.EditContext {
 
 
 	override function rebuildProperties() {
 	override function rebuildProperties() {
 		editor.scene.setCurrent();
 		editor.scene.setCurrent();
-		editor.selectObjects(elements);
+		editor.selectObjects(elements, NoHistory);
 	}
 	}
 
 
 	override function rebuildPrefab( p : hrt.prefab.Prefab ) {
 	override function rebuildPrefab( p : hrt.prefab.Prefab ) {

+ 14 - 0
hide/prefab/EditContext.hx

@@ -53,6 +53,20 @@ class EditContext {
 			}
 			}
 	}
 	}
 
 
+	public function makeChanges( p : Prefab, f : Void -> Void ) @:privateAccess {
+		var current = p.save();
+		properties.undo.change(Custom(function(b) {
+			var old = p.save();
+			p.load(current);
+			current = old;
+			rebuildProperties();
+			onChange(p, null);
+		}));
+		f();
+		rebuildProperties();
+		onChange(p, null);
+	}
+
 	#end
 	#end
 
 
 	public function new(ctx) {
 	public function new(ctx) {

+ 15 - 17
hrt/prefab/l3d/Camera.hx

@@ -203,23 +203,21 @@ class Camera extends Object3D {
 
 
 		props.find(".copy").click(function(e) {
 		props.find(".copy").click(function(e) {
 			var cam = ctx.scene.s3d.camera;
 			var cam = ctx.scene.s3d.camera;
-			var q = new h3d.Quat();
-			q.initDirection(cam.target.sub(cam.pos));
-			var angles = q.toEuler();
-			this.rotationX = hxd.Math.fmt(angles.x * 180 / Math.PI);
-			this.rotationY = hxd.Math.fmt(angles.y * 180 / Math.PI);
-			this.rotationZ = hxd.Math.fmt(angles.z * 180 / Math.PI);
-			this.scaleX = this.scaleY = this.scaleZ = 1;
-			this.x = hxd.Math.fmt(cam.pos.x);
-			this.y = hxd.Math.fmt(cam.pos.y);
-			this.z = hxd.Math.fmt(cam.pos.z);
-			this.zFar = cam.zFar;
-			this.zNear = cam.zNear;
-			this.fovY = cam.fovY;
-			applyTo(cam);
-			ctx.scene.editor.cameraController.lockZPlanes = true;
-			ctx.scene.editor.cameraController.loadFromCamera();
-			ctx.rebuildProperties();
+			ctx.makeChanges(this, function() {
+				var q = new h3d.Quat();
+				q.initDirection(cam.target.sub(cam.pos));
+				var angles = q.toEuler();
+				this.rotationX = hxd.Math.fmt(angles.x * 180 / Math.PI);
+				this.rotationY = hxd.Math.fmt(angles.y * 180 / Math.PI);
+				this.rotationZ = hxd.Math.fmt(angles.z * 180 / Math.PI);
+				this.scaleX = this.scaleY = this.scaleZ = 1;
+				this.x = hxd.Math.fmt(cam.pos.x);
+				this.y = hxd.Math.fmt(cam.pos.y);
+				this.z = hxd.Math.fmt(cam.pos.z);
+				this.zFar = cam.zFar;
+				this.zNear = cam.zNear;
+				this.fovY = cam.fovY;
+			});
 		});
 		});