Skip to content

Commit

Permalink
Added a check to make sure entire instance sets are considered for hw…
Browse files Browse the repository at this point in the history
… instancing, and also a check for each instance transform (#2026)
  • Loading branch information
AlexandruPopovici authored Feb 8, 2024
1 parent 963e80a commit 549da15
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/viewer-sandbox/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,12 @@ const getStream = () => {
// 'https://latest.speckle.dev/streams/ee5346d3e1/commits/489d42ca8c'
// 'https://latest.speckle.dev/streams/97750296c2/objects/11a7752e40b4ef0620affc55ce9fdf5a'

// 'https://latest.speckle.dev/streams/92b620fb17/objects/7118603b197c00944f53be650ce721ec'
// Blender Mega Test Stream
'https://latest.speckle.dev/streams/c1faab5c62/commits/2ecb757577'
// 'https://latest.speckle.dev/streams/c1faab5c62/commits/3deaea94af'
// Text and Dimensions
'https://latest.speckle.dev/streams/3f895e614f/commits/fbc78286c9'
// 'https://latest.speckle.dev/streams/3f895e614f/commits/fbc78286c9'
// 'https://latest.speckle.dev/streams/55cc1cbf0a/commits/aa72674507'
// 'https://latest.speckle.dev/streams/55cc1cbf0a/commits/a7f74b6524'
)
Expand Down
13 changes: 11 additions & 2 deletions packages/viewer/src/modules/batching/Batcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ export default class Batcher {
for (const v in instancedBatches) {
for (let k = 0; k < instancedBatches[v].length; k++) {
const nodes = worldTree.findId(instancedBatches[v][k])
/** Make sure entire instance set is instanced */
let instanced = true
nodes.every((node: TreeNode) => (instanced &&= node.model.instanced))

const rvs = nodes
.map((node: TreeNode) => node.model.renderView)
/** This disconsiders orphaned nodes caused by incorrect id duplication in the stream */
.filter((rv) => rv)

if (Number.parseInt(v) < this.minInstancedBatchVertices) {
if (Number.parseInt(v) < this.minInstancedBatchVertices || !instanced) {
const t0 = performance.now()
rvs.forEach((nodeRv) => {
const geometry = nodeRv.renderData.geometry
Expand All @@ -103,7 +107,12 @@ export default class Batcher {
COLOR: attribs.COLOR.slice()
})
}
Geometry.transformGeometryData(geometry, geometry.transform)
/** - I don't particularly like this branch -
* All instances should have a transform. But it's the easiest thing we can do
* until we figure out the viewer <-> connector object duplication inconsistency
*/
if (geometry.transform)
Geometry.transformGeometryData(geometry, geometry.transform)
nodeRv.computeAABB()
})
deInstancing += performance.now() - t0
Expand Down

0 comments on commit 549da15

Please sign in to comment.