Prechádzať zdrojové kódy

Allow Prefab.setSelected to return if children should be selected as well

trethaller 5 rokov pred
rodič
commit
44472bdc65

+ 4 - 4
hide/comp/SceneEditor.hx

@@ -1083,7 +1083,7 @@ class SceneEditor {
 
 	function setObjectSelected( p : PrefabElement, ctx : hrt.prefab.Context, b : Bool ) {
 		hideGizmo = false;
-		p.setSelected(ctx, b);
+		return p.setSelected(ctx, b);
 	}
 
 	public function selectObjects( elts : Array<PrefabElement>, ?includeTree=true) {
@@ -1108,9 +1108,9 @@ class SceneEditor {
 					return;
 				map.set(e, true);
 				var ectx = context.shared.contexts.get(e);
-				setObjectSelected(e, ectx == null ? context : ectx, b);
-				for( e in e.children )
-					selectRec(e,b);
+				if(setObjectSelected(e, ectx == null ? context : ectx, b))
+					for( e in e.children )
+						selectRec(e,b);
 			}
 
 			for( e in elts )

+ 2 - 2
hide/view/FXEditor.hx

@@ -51,8 +51,8 @@ private class FXSceneEditor extends hide.comp.SceneEditor {
 
 	override function setObjectSelected( p : PrefabElement, ctx : hrt.prefab.Context, b : Bool ) {
 		if( p.getParent(hrt.prefab.fx.Emitter) != null )
-			return;
-		super.setObjectSelected(p, ctx, b);
+			return false;
+		return super.setObjectSelected(p, ctx, b);
 	}
 
 	override function selectObjects( elts, ?includeTree=true) {

+ 5 - 4
hrt/prefab/Light.hx

@@ -195,11 +195,11 @@ class Light extends Object3D {
 
 	override function updateInstance( ctx : Context, ?propName : String ) {
 		super.updateInstance(ctx, propName);
-		
+
 		var color = color | 0xff000000;
 		var pbrLight = Std.downcast(ctx.local3d, h3d.scene.pbr.Light);
 		var light = Std.downcast(ctx.local3d, h3d.scene.pbr.Light);
-		if( pbrLight != null ) { // PBR 
+		if( pbrLight != null ) { // PBR
 			pbrLight.isMainLight = isMainLight;
 			pbrLight.occlusionFactor = occlusionFactor;
 
@@ -240,9 +240,9 @@ class Light extends Object3D {
 					pbrLight.shadows.samplingKind = ESM;
 			}
 		}
-		else if( light != null ) { // FWD 
+		else if( light != null ) { // FWD
 			light.color.setColor(color | 0xFF000000);
-		} 
+		}
 
 		#if editor
 
@@ -403,6 +403,7 @@ class Light extends Object3D {
 		var sel = ctx.local3d.getObjectByName("__selection");
 		if( sel != null ) sel.visible = b;
 		updateInstance(ctx);
+		return true;
 	}
 
 	override function edit( ctx : EditContext ) {

+ 4 - 2
hrt/prefab/Prefab.hx

@@ -83,7 +83,8 @@ class Prefab {
 	}
 
 	/**
-		Allows to customize how the prefab instance changes when selected/unselected within Hide
+		Allows to customize how the prefab instance changes when selected/unselected within Hide.
+		Selection of descendants is skipped if false is returned.
 	**/
 	public function setSelected( ctx : Context, b : Bool ) {
 		var materials = ctx.shared.getMaterials(this);
@@ -93,7 +94,7 @@ class Prefab {
 				//m.mainPass.stencil = null;
 				m.removePass(m.getPass("highlight"));
 			}
-			return;
+			return true;
 		}
 
 		var shader = new h3d.shader.FixedColor(0xffffff);
@@ -103,6 +104,7 @@ class Prefab {
 			p.depthWrite = false;
 			p.addShader(shader);
 		}
+		return true;
 	}
 	#end
 

+ 2 - 1
hrt/prefab/fx/Emitter.hx

@@ -1086,7 +1086,7 @@ class Emitter extends Object3D {
 	override function setSelected( ctx : Context, b : Bool ) {
 		var emitterObj = Std.downcast(ctx.local3d, EmitterObject);
 		if(emitterObj == null)
-			return;
+			return false;
 		var debugShape : h3d.scene.Object = emitterObj.find(c -> if(c.name == "_highlight") c else null);
 		if(debugShape != null)
 			debugShape.visible = b;
@@ -1105,6 +1105,7 @@ class Emitter extends Object3D {
 			}
 			emitterObj.batch.shadersChanged = true;
 		}
+		return false;
 	}
 
 	function updateEmitShape(emitterObj: EmitterObject) {

+ 1 - 0
hrt/prefab/l3d/AdvancedDecal.hx

@@ -158,6 +158,7 @@ class AdvancedDecal extends Object3D {
 		} else {
 			clearSelection( ctx );
 		}
+		return true;
 	}
 
 	function clearSelection( ctx : Context ) {

+ 1 - 1
hrt/prefab/l3d/Camera.hx

@@ -43,7 +43,7 @@ class Camera extends Object3D {
 	#if editor
 
 	override function setSelected( ctx : Context, b : Bool ) {
-
+		return false;
 	}
 
 	override function edit( ctx : hide.prefab.EditContext ) {

+ 2 - 1
hrt/prefab/l3d/Decal.hx

@@ -76,9 +76,10 @@ class Decal extends Object3D {
 			for( o in ctx.shared.getObjects(this,h3d.scene.Box) )
 				if( o.name == "_highlight" ) {
 					o.remove();
-					return;
+					return false;
 				}
 		}
+		return true;
 	}
 
 	override function edit( ctx : EditContext ) {

+ 1 - 0
hrt/prefab/l3d/MeshGenerator.hx

@@ -406,6 +406,7 @@ class MeshGenerator extends Object3D {
 				s.remove();
 			}
 		}
+		return true;
 	}
 
 	function getHMD( ctx : Context, meshPath : String ) : hxd.fmt.hmd.Library {

+ 1 - 0
hrt/prefab/l3d/MeshSpray.hx

@@ -264,6 +264,7 @@ class MeshSpray extends Object3D {
 				wasEdited = false;
 			};
 		}
+		return false;
 	}
 
 	function addMeshPath(path : String) {

+ 1 - 0
hrt/prefab/l3d/Polygon.hx

@@ -224,6 +224,7 @@ class Polygon extends Object3D {
 		super.setSelected(ctx, b);
 		if( editor != null && shape == Custom)
 			editor.setSelected(ctx, b);
+		return true;
 	}
 
 	function createEditor( ctx : EditContext ){

+ 4 - 2
hrt/prefab/l3d/Spline.hx

@@ -97,8 +97,8 @@ class Spline extends Object3D {
 		}
 		// Clone support
 		else if( pointsData != null && pointsData.length > 0 ) {
-			obj.points =  [ for(abs in pointsData) { 
-								[for(f in abs.getFloats()) hxd.Math.fmt(f) ]; 
+			obj.points =  [ for(abs in pointsData) {
+								[for(f in abs.getFloats()) hxd.Math.fmt(f) ];
 							} ];
 		}
 		obj.shape = shape.getIndex();
@@ -418,6 +418,8 @@ class Spline extends Object3D {
 
 		if( editor != null )
 			editor.setSelected(ctx, b);
+
+		return true;
 	}
 
 	override function edit( ctx : EditContext ) {

+ 0 - 4
hrt/prefab/l3d/SplineMesh.hx

@@ -313,10 +313,6 @@ class SplineMesh extends Spline {
 
 	#if editor
 
-	override function setSelected( ctx : hrt.prefab.Context , b : Bool ) {
-		super.setSelected(ctx, b);
-	}
-
 	override function edit( ctx : EditContext ) {
 		super.edit(ctx);
 

+ 1 - 0
hrt/prefab/terrain/Terrain.hx

@@ -562,6 +562,7 @@ class Terrain extends Object3D {
 
 	override function setSelected( ctx : Context, b : Bool ) {
 		if( editor != null ) editor.setSelected(ctx, b);
+		return true;
 	}
 
 	override function getHideProps() : HideProps {

+ 2 - 1
hrt/prefab/vlm/VolumetricLightmap.hx

@@ -208,9 +208,10 @@ class VolumetricLightmap extends Object3D {
 			for( o in ctx.shared.getObjects(this,h3d.scene.Box) )
 				if( o.name == "_highlight" ) {
 					o.remove();
-					return;
+					return false;
 				}
 		}
+		return true;
 	}
 
 	override function edit( ctx : EditContext ) {