浏览代码

add storagebuffer node to the new global cache (#28607)

Renaud Rohlinger 1 年之前
父节点
当前提交
5c7ccda4ac
共有 1 个文件被更改,包括 27 次插入0 次删除
  1. 27 0
      examples/jsm/nodes/accessors/StorageBufferNode.js

+ 27 - 0
examples/jsm/nodes/accessors/StorageBufferNode.js

@@ -14,10 +14,13 @@ class StorageBufferNode extends BufferNode {
 		this.isStorageBufferNode = true;
 
 		this.bufferObject = false;
+		this.bufferCount = bufferCount;
 
 		this._attribute = null;
 		this._varying = null;
 
+		this.global = true;
+
 		if ( value.isStorageBufferAttribute !== true && value.isStorageInstancedBufferAttribute !== true ) {
 
 			// TOOD: Improve it, possibly adding a new property to the BufferAttribute to identify it as a storage buffer read-only attribute in Renderer
@@ -29,6 +32,30 @@ class StorageBufferNode extends BufferNode {
 
 	}
 
+	getHash( builder ) {
+
+		if ( this.bufferCount === 0 ) {
+
+			let bufferData = builder.globalCache.getData( this.value );
+
+			if ( bufferData === undefined ) {
+
+				bufferData = {
+					node: this
+				};
+
+				builder.globalCache.setData( this.value, bufferData );
+
+			}
+
+			return bufferData.node.uuid;
+
+		}
+
+		return this.uuid;
+
+	}
+
 	getInputType( /*builder*/ ) {
 
 		return 'storageBuffer';