ソースを参照

Fix GPUMeshBatch doesn't work properly with ForceGPUUpdate.

borisrp 2 ヶ月 前
コミット
eedefb6b2d
2 ファイル変更14 行追加10 行削除
  1. 2 3
      h3d/scene/GPUMeshBatch.hx
  2. 12 7
      h3d/scene/MeshBatch.hx

+ 2 - 3
h3d/scene/GPUMeshBatch.hx

@@ -125,9 +125,8 @@ class GPUMeshBatch extends MeshBatch {
 				instanceOffsetsGpu = alloc.allocBuffer( vertex, INSTANCE_OFFSETS_FMT, UniformReadWrite );
 				upload = true;
 			}
-			if ( upload && !gpuUpdateForced())
+			if ( upload )
 				instanceOffsetsGpu.uploadBytes( instanceOffsetsCpu, 0, vertex );
-
 			if ( matInfos == null ) {
 				materialCount = 0;
 				var tmpSubPartInfos = alloc.allocFloats( 2 * emittedSubParts.length );
@@ -253,7 +252,7 @@ class GPUMeshBatch extends MeshBatch {
 		if ( instanceCount == 0 || (cullingCollider != null && !cullingCollider.inFrustum(ctx.camera.frustum)) )
 			return;
 		super.emit(ctx);
-		if ( commandBuffer != null && instanceCount > 0) {
+		if ( commandBuffer != null ) {
 			var computeShader = computePass.getShader(h3d.shader.InstanceIndirect.InstanceIndirectBase);
 			if ( gpuCullingEnabled )
 				computeShader.frustum = ctx.getCameraFrustumBuffer();

+ 12 - 7
h3d/scene/MeshBatch.hx

@@ -264,17 +264,22 @@ class MeshBatch extends MultiMaterial {
 	}
 
 	public function emitInstance() {
-		if( worldPosition == null ) syncPos();
 		if( primitiveSubParts != null )
 			emitPrimitiveSubParts();
-		else if (calcBounds)
-			instanced.addInstanceBounds(worldPosition == null ? absPos : worldPosition);
 
-		var p = dataPasses;
-		while( p != null ) {
-			syncData(p);
-			p = p.next;
+		if(!gpuUpdateForced()){
+			if( worldPosition == null ) syncPos();
+
+			if (primitiveSubParts == null && calcBounds)
+				instanced.addInstanceBounds(worldPosition == null ? absPos : worldPosition);
+
+			var p = dataPasses;
+			while( p != null ) {
+				syncData(p);
+				p = p.next;
+			}
 		}
+
 		instanceCount++;
 	}