|
@@ -11,6 +11,7 @@ class WorldChunk {
|
|
public var buffers : Map<Int, h3d.scene.Mesh>;
|
|
public var buffers : Map<Int, h3d.scene.Mesh>;
|
|
public var bounds : h3d.col.Bounds;
|
|
public var bounds : h3d.col.Bounds;
|
|
public var initialized = false;
|
|
public var initialized = false;
|
|
|
|
+ public var lastFrame : Int;
|
|
|
|
|
|
public function new(cx, cy) {
|
|
public function new(cx, cy) {
|
|
this.cx = cx;
|
|
this.cx = cx;
|
|
@@ -122,8 +123,8 @@ class World extends Object {
|
|
return Alpha;
|
|
return Alpha;
|
|
}
|
|
}
|
|
|
|
|
|
- function resolveSpecularTexture( diffuse : hxd.res.Image ) : hxd.res.Image {
|
|
|
|
- var path = diffuse.entry.directory + "spec.jpg";
|
|
|
|
|
|
+ function resolveSpecularTexture( path : String ) : hxd.res.Image {
|
|
|
|
+ path = path.substr(0, path.length - 4) + "spec.jpg";
|
|
try {
|
|
try {
|
|
return hxd.res.Loader.currentInstance.load(path).toImage();
|
|
return hxd.res.Loader.currentInstance.load(path).toImage();
|
|
} catch( e : hxd.res.NotFound ) {
|
|
} catch( e : hxd.res.NotFound ) {
|
|
@@ -132,7 +133,9 @@ class World extends Object {
|
|
}
|
|
}
|
|
|
|
|
|
function loadMaterialTexture( r : hxd.res.Model, mat : hxd.fmt.hmd.Data.Material ) : WorldMaterial {
|
|
function loadMaterialTexture( r : hxd.res.Model, mat : hxd.fmt.hmd.Data.Material ) : WorldMaterial {
|
|
- var texturePath = r.entry.directory + mat.diffuseTexture.split("/").pop();
|
|
|
|
|
|
+ var texturePath = r.entry.directory;
|
|
|
|
+ if( texturePath != "" ) texturePath += "/";
|
|
|
|
+ texturePath += mat.diffuseTexture.split("/").pop();
|
|
|
|
|
|
var m = textures.get(texturePath);
|
|
var m = textures.get(texturePath);
|
|
if( m != null )
|
|
if( m != null )
|
|
@@ -158,7 +161,7 @@ class World extends Object {
|
|
|
|
|
|
var specTex = null;
|
|
var specTex = null;
|
|
if( enableSpecular ) {
|
|
if( enableSpecular ) {
|
|
- var res = resolveSpecularTexture(rt);
|
|
|
|
|
|
+ var res = resolveSpecularTexture(texturePath);
|
|
if( btex.spec == null )
|
|
if( btex.spec == null )
|
|
btex.spec = new h3d.mat.BigTexture(-1, bigTextureSize, bigTextureBG);
|
|
btex.spec = new h3d.mat.BigTexture(-1, bigTextureSize, bigTextureBG);
|
|
if( res != null )
|
|
if( res != null )
|
|
@@ -366,9 +369,12 @@ class World extends Object {
|
|
|
|
|
|
for( c in allChunks ) {
|
|
for( c in allChunks ) {
|
|
c.root.visible = c.bounds.inFrustum(ctx.camera.m);
|
|
c.root.visible = c.bounds.inFrustum(ctx.camera.m);
|
|
- if(c.root.visible && !c.initialized) {
|
|
|
|
- c.initialized = true;
|
|
|
|
- initSoil(c);
|
|
|
|
|
|
+ if( c.root.visible ) {
|
|
|
|
+ if( !c.initialized) {
|
|
|
|
+ c.initialized = true;
|
|
|
|
+ initSoil(c);
|
|
|
|
+ }
|
|
|
|
+ c.lastFrame = ctx.frame;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|