浏览代码

added last display frame tracking

bstouls 9 年之前
父节点
当前提交
6f7c14b68a
共有 1 个文件被更改,包括 13 次插入7 次删除
  1. 13 7
      h3d/scene/World.hx

+ 13 - 7
h3d/scene/World.hx

@@ -11,6 +11,7 @@ class WorldChunk {
 	public var buffers : Map<Int, h3d.scene.Mesh>;
 	public var bounds : h3d.col.Bounds;
 	public var initialized = false;
+	public var lastFrame : Int;
 
 	public function new(cx, cy) {
 		this.cx = cx;
@@ -122,8 +123,8 @@ class World extends Object {
 		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 {
 			return hxd.res.Loader.currentInstance.load(path).toImage();
 		} 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 {
-		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);
 		if( m != null )
@@ -158,7 +161,7 @@ class World extends Object {
 
 		var specTex = null;
 		if( enableSpecular ) {
-			var res = resolveSpecularTexture(rt);
+			var res = resolveSpecularTexture(texturePath);
 			if( btex.spec == null )
 				btex.spec = new h3d.mat.BigTexture(-1, bigTextureSize, bigTextureBG);
 			if( res != null )
@@ -366,9 +369,12 @@ class World extends Object {
 
 		for( c in allChunks ) {
 			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;
 			}
 		}
 	}