Skip to content

Commit f43cf53

Browse files
Can customize lod config, and refresh it from ModelCache.
1 parent c52f63c commit f43cf53

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

h3d/prim/ModelCache.hx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ class ModelCache {
175175
}
176176
}
177177

178+
public function refreshLodConfig() {
179+
for ( model in models )
180+
for ( p in @:privateAccess model.lib.cachedPrimitives ) {
181+
if ( p == null )
182+
continue;
183+
@:privateAccess p.lodConfig = null;
184+
}
185+
}
186+
178187
#if hide
179188

180189
public function loadPrefab( res : hxd.res.Prefab, ?p : hrt.prefab.Prefab, ?parent : h3d.scene.Object ) {
@@ -205,5 +214,4 @@ class ModelCache {
205214
}
206215

207216
#end
208-
209217
}

h3d/prim/ModelDatabase.hx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class ModelDatabase {
2020

2121
static var defaultLodConfigs : Map<String, Array<Float>> = new Map();
2222
static var baseLodConfig = [ 0.5, 0.2, 0.01];
23+
public static dynamic function customizeLodConfig(c : Array<Float>) {
24+
return c;
25+
}
2326

2427
function new() {
2528
}
@@ -74,20 +77,19 @@ class ModelDatabase {
7477

7578
function getDefaultLodConfig( dir : String ) : Array<Float> {
7679
var fs = Std.downcast(hxd.res.Loader.currentInstance.fs, hxd.fs.LocalFileSystem);
77-
if (fs == null)
78-
return baseLodConfig;
79-
80+
var c = baseLodConfig;
8081
#if (sys || nodejs)
81-
var c = @:privateAccess fs.convert.getConfig(defaultLodConfigs, baseLodConfig, dir, function(fullObj) {
82+
if (fs != null) {
83+
c = @:privateAccess fs.convert.getConfig(defaultLodConfigs, baseLodConfig, dir, function(fullObj) {
8284
if (Reflect.hasField(fullObj, "lods.screenRatio"))
8385
return Reflect.field(fullObj, "lods.screenRatio");
8486

8587
return baseLodConfig;
8688
});
87-
return c;
88-
#else
89-
return baseLodConfig;
89+
}
9090
#end
91+
c = customizeLodConfig(c);
92+
return c;
9193
}
9294

9395
// Used to clean previous version of modelDatabase, should be removed after some time

0 commit comments

Comments
 (0)