Browse Source

Add optional filter in loadModel for world

ShiroSmith 6 years ago
parent
commit
ba5ef7ed75
1 changed files with 8 additions and 2 deletions
  1. 8 2
      h3d/scene/World.hx

+ 8 - 2
h3d/scene/World.hx

@@ -293,7 +293,7 @@ class World extends Object {
 	}
 
 	@:noDebug
-	public function loadModel( r : hxd.res.Model ) : WorldModel {
+	public function loadModel( r : hxd.res.Model, ?filter : hxd.fmt.hmd.Data.Model -> Bool) : WorldModel {
 		var lib = r.toHmd();
 		var models = lib.header.models;
 		var format = buildFormat();
@@ -305,6 +305,12 @@ class World extends Object {
 
 		var startVertex = 0, startIndex = 0;
 		for( m in models ) {
+
+			// Name filtering
+			if( filter != null && !filter(m) ) {
+				continue;
+			}
+
 			var geom = lib.header.geometries[m.geometry];
 			if( geom == null ) continue;
 			var pos = m.position.toMatrix();
@@ -515,7 +521,7 @@ class World extends Object {
 	}
 
 	/**
-		Dispose the World instance.  
+		Dispose the World instance.
 		Note: Only chunked world objects will be disposed. Any objects added to World object will be disposed when World is removed from scene or scene is disposed.
 	**/
 	public function dispose() {