Browse Source

Highlight material on selection

clementlandrin 1 year ago
parent
commit
d3ef15baf5
1 changed files with 18 additions and 12 deletions
  1. 18 12
      hide/view/Model.hx

+ 18 - 12
hide/view/Model.hx

@@ -32,6 +32,8 @@ class Model extends FileView {
 	var lastSelectedObject : h3d.scene.Object = null;
 	var lastSelectedObject : h3d.scene.Object = null;
 
 
 	var highlightSelection : Bool = true;
 	var highlightSelection : Bool = true;
+	var shader = new h3d.shader.FixedColor(0xffffff);
+	var shader2 = new h3d.shader.FixedColor(0xff8000);
 
 
 	override function save() {
 	override function save() {
 
 
@@ -189,6 +191,8 @@ class Model extends FileView {
 	function selectMaterial( m : h3d.mat.Material ) {
 	function selectMaterial( m : h3d.mat.Material ) {
 		refreshSelectionHighlight(null);
 		refreshSelectionHighlight(null);
 
 
+		highlightMaterial(m);
+		
 		var properties = sceneEditor.properties;
 		var properties = sceneEditor.properties;
 		properties.clear();
 		properties.clear();
 
 
@@ -726,24 +730,26 @@ class Model extends FileView {
 
 
 		materials = selectedObj.getMaterials();
 		materials = selectedObj.getMaterials();
 
 
-		var shader = new h3d.shader.FixedColor(0xffffff);
-		var shader2 = new h3d.shader.FixedColor(0xff8000);
 		for( m in materials ) {
 		for( m in materials ) {
 			if( m.name != null && StringTools.startsWith(m.name,"$UI.") )
 			if( m.name != null && StringTools.startsWith(m.name,"$UI.") )
 				continue;
 				continue;
-			var p = m.allocPass("highlight");
-			p.culling = None;
-			p.depthWrite = false;
-			p.depthTest = LessEqual;
-			p.addShader(shader);
-			var p = m.allocPass("highlightBack");
-			p.culling = None;
-			p.depthWrite = false;
-			p.depthTest = Always;
-			p.addShader(shader2);
+			highlightMaterial(m);
 		}
 		}
 	}
 	}
 
 
+	function highlightMaterial(m : h3d.mat.Material) {
+		var p = m.allocPass("highlight");
+		p.culling = None;
+		p.depthWrite = false;
+		p.depthTest = LessEqual;
+		p.addShader(shader);
+		var p = m.allocPass("highlightBack");
+		p.culling = None;
+		p.depthWrite = false;
+		p.depthTest = Always;
+		p.addShader(shader2);
+	}
+
 	function getNamedObjects( ?exclude : h3d.scene.Object ) {
 	function getNamedObjects( ?exclude : h3d.scene.Object ) {
 		var out = [];
 		var out = [];