diff options
| author | coco875 <59367621+coco875@users.noreply.github.com> | 2025-12-22 22:48:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-22 14:48:07 -0700 |
| commit | ce92773a602cca246c44dbec9fb87656fedfa323 (patch) | |
| tree | 19bee63b1ae4ad566eaeb66d83f90257d6407fea /src/engine/editor/Editor.cpp | |
| parent | 31c2063a61feddb340a48beb7c0376b885c8ce00 (diff) | |
Clean ptr and fix (#610)
* use more unique ptr and fix a shell crash
* remove useless mods folder
* add even more unique_ptr
* Update KoopaTroopaBeach.cpp
* restore a throw
* Update Game.cpp
* automatically create mods folder
* fix oob in external by assuming that all 8 player can make sound
* better texture loading
* add destructor for gameobject
* avoid out of bound in audio sample
* Update FrameInterpolation.cpp
* Update torch
Diffstat (limited to 'src/engine/editor/Editor.cpp')
| -rw-r--r-- | src/engine/editor/Editor.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/engine/editor/Editor.cpp b/src/engine/editor/Editor.cpp index 87bca2a82..d8eeecda9 100644 --- a/src/engine/editor/Editor.cpp +++ b/src/engine/editor/Editor.cpp @@ -40,7 +40,7 @@ namespace TrackEditor { printf("Editor: Loading Editor...\n"); eObjectPicker.Load(); for (auto& object : eGameObjects) { - GenerateCollisionMesh(object, (Gfx*)object->Model, 1.0f); + GenerateCollisionMesh(object.get(), (Gfx*)object->Model, 1.0f); object->Load(); } @@ -150,7 +150,11 @@ namespace TrackEditor { eObjectPicker.eGizmo.SelectedHandle = Gizmo::GizmoHandle::None; eObjectPicker.eGizmo.ManipulationStart = true; if (!isDragging) { - eObjectPicker.SelectObject(eGameObjects); + std::vector<GameObject*> objects; + for (auto& object : eGameObjects) { + objects.push_back(object.get()); + } + eObjectPicker.SelectObject(objects); } } @@ -178,25 +182,22 @@ namespace TrackEditor { // pos->x, pos->y, pos->z, name, model); if (nullptr != model && model[0] != '\0') { - eGameObjects.push_back(new GameObject(pos, rot, scale, model, {}, collision, boundingBoxSize)); - GenerateCollisionMesh(eGameObjects.back(), (Gfx*)LOAD_ASSET_RAW(model), collScale); + eGameObjects.push_back(std::make_unique<GameObject>(pos, rot, scale, model, std::vector<Triangle>(), collision, boundingBoxSize)); + GenerateCollisionMesh(eGameObjects.back().get(), (Gfx*)LOAD_ASSET_RAW(model), collScale); } else { // to bounding box or sphere collision - eGameObjects.push_back(new GameObject(pos, rot, scale, model, {}, GameObject::CollisionType::BOUNDING_BOX, + eGameObjects.push_back(std::make_unique<GameObject>(pos, rot, scale, model, std::vector<Triangle>(), GameObject::CollisionType::BOUNDING_BOX, 10.0f)); } - return eGameObjects.back(); + return eGameObjects.back().get(); } void Editor::AddLight(const char* name, FVector* pos, s8* rot) { - eGameObjects.push_back(new LightObject(name, pos, rot)); + eGameObjects.push_back(std::make_unique<LightObject>(name, pos, rot)); } void Editor::ClearObjects() { ResetGizmo(); - for (auto& obj : eGameObjects) { - delete obj; - } eGameObjects.clear(); } |
