mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03:52 +00:00
fix(editor): move rebuildObjects AFTER beginFrame (instance SSBO fix)
ROOT CAUSE of NPCs not rendering: rebuildObjects() called createInstance() BEFORE beginFrame(), causing instance SSBO writes to use the wrong frame index. The M2 renderer writes instance transforms to a per-frame buffer indexed by getCurrentFrame(), but the frame index isn't valid until after beginFrame() returns. This is the same bug documented in the project memory: "M2 models not rendering (draws=0): update() was called before beginFrame(), causing frame index mismatch in instance SSBO" Models loaded correctly (log confirmed 2192v 7926i 8b) but instances were invisible because their transform data was written to the wrong frame buffer. Fix: move the rebuild block after beginFrame(), alongside update().
This commit is contained in:
parent
f1133cdfa7
commit
09e867eb07
1 changed files with 11 additions and 11 deletions
|
|
@ -125,17 +125,6 @@ void EditorApp::run() {
|
|||
lastNpcCount_ = npcCount;
|
||||
}
|
||||
|
||||
if (objChanged || objectsDirty_) {
|
||||
// Full M2 rebuild only when placed objects change
|
||||
objectsDirty_ = false;
|
||||
lastObjCount_ = objCount;
|
||||
if (objCount > 0 || npcCount > 0) {
|
||||
vkDeviceWaitIdle(vkCtx->getDevice());
|
||||
viewport_.rebuildObjects(objectPlacer_.getObjects(), npcSpawner_.getSpawns());
|
||||
}
|
||||
lastNpcCount_ = npcCount; // sync after rebuild
|
||||
}
|
||||
|
||||
// Show gizmo arrows on selected object
|
||||
auto& gizmo = viewport_.getGizmo();
|
||||
if (auto* sel = objectPlacer_.getSelected()) {
|
||||
|
|
@ -148,6 +137,17 @@ void EditorApp::run() {
|
|||
VkCommandBuffer cmd = vkCtx->beginFrame(imageIndex);
|
||||
if (cmd == VK_NULL_HANDLE) continue;
|
||||
|
||||
// Rebuild objects AFTER beginFrame so instance SSBO uses correct frame index
|
||||
if (objChanged || objectsDirty_) {
|
||||
objectsDirty_ = false;
|
||||
lastObjCount_ = objCount;
|
||||
if (objCount > 0 || npcCount > 0) {
|
||||
vkDeviceWaitIdle(vkCtx->getDevice());
|
||||
viewport_.rebuildObjects(objectPlacer_.getObjects(), npcSpawner_.getSpawns());
|
||||
}
|
||||
lastNpcCount_ = npcCount;
|
||||
}
|
||||
|
||||
// Update M2 animations AFTER beginFrame (so getCurrentFrame is correct)
|
||||
viewport_.update(dt);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue