mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
fix(editor): ghost preview survives object rebuilds, clearObjects resets ghost state
- Ghost model state (ID, path, active flag) properly reset when clearObjects() wipes the M2 renderer — prevents stale ghost references causing crashes on subsequent hover - Ghost model ID uses 59999 to avoid collision with placed object IDs - Ghost loadModel failure now handled gracefully (returns early)
This commit is contained in:
parent
34c06ede4e
commit
f6d30fcf9b
1 changed files with 11 additions and 2 deletions
|
|
@ -97,6 +97,12 @@ void EditorViewport::placeWMO(const std::string& path, const glm::vec3& pos,
|
|||
}
|
||||
|
||||
void EditorViewport::clearObjects() {
|
||||
// Clear ghost state since the M2 renderer is about to be wiped
|
||||
ghostActive_ = false;
|
||||
ghostInstanceId_ = 0;
|
||||
ghostModelId_ = 0;
|
||||
ghostModelPath_.clear();
|
||||
|
||||
if (m2Renderer_) {
|
||||
vkCtx_->waitAllUploads();
|
||||
m2Renderer_->clear();
|
||||
|
|
@ -406,8 +412,11 @@ void EditorViewport::setGhostPreview(const std::string& path, const glm::vec3& p
|
|||
if (!model.isValid()) return;
|
||||
if (model.boundRadius < 1.0f) model.boundRadius = 50.0f;
|
||||
|
||||
ghostModelId_ = 60000; // Use a high ID to avoid collision with placed objects
|
||||
m2Renderer_->loadModel(model, ghostModelId_);
|
||||
ghostModelId_ = 59999; // High ID to avoid collision with placed objects
|
||||
if (!m2Renderer_->loadModel(model, ghostModelId_)) {
|
||||
ghostModelId_ = 0;
|
||||
return;
|
||||
}
|
||||
vkCtx_->waitAllUploads();
|
||||
vkCtx_->pollUploadBatches();
|
||||
ghostModelPath_ = path;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue