Closed smlpt closed 4 months ago
the setActiveNode()
(even in the new proposed position) will not follow the activePublish
flag.. no? it would always trigger the publishing event (yes, a different one, but still some)
for me, the purpose of the activePublish
flag was that I could temporarily suspend publishing when adding a burst of nodes, and trigger the publishing only with the last node added
just thinking now aloud
I changed it so that setActiveNode
is only called if activePublish
is true:
fun <N: Node?> addNode(n: N, activePublish: Boolean = true, block: N.() -> Unit = {}, parent: Node = scene): N {
n?.let {
it.block()
// Ensure name is unique
n.name = generateUniqueName(n.name)
parent.addChild(it)
objectService.addObject(n)
if (blockOnNewNodes) {
Utils.blockWhile({ this.find(n.name) == null }, 20)
//System.out.println("find(name) " + find(n.getName()) );
}
if (activePublish) {
eventService.publish(NodeAddedEvent(n))
setActiveNode(n)
// Set new node as centered
if (centerOnNewNodes) {
centerOnNode(n)
}
}
}
return n
}
LGTM, than you @smlpt
This fixes an issue where adding new objects to the scene would be slowed down by the fact that each new node would always be set as the active node. This would also cause excessive log outputs about each active node like:
With this fix, new nodes are only considered active when
centerOnNewNodes
is set totrue
.