Editor get actor names

This commit is contained in:
MegaMech
2025-03-07 20:23:33 -07:00
parent 087b1b613c
commit 882f14e91a
13 changed files with 98 additions and 21 deletions
+5 -5
View File
@@ -128,11 +128,11 @@ struct Actor* World::AddBaseActor() {
return reinterpret_cast<struct Actor*>(reinterpret_cast<char*>(Actors.back()) + sizeof(void*));
}
void World::AddEditorObject(Actor* actor) {
void World::AddEditorObject(Actor* actor, const char* name) {
if (actor->model != NULL) {
gEditor.AddObject((FVector*) &actor->pos, (Gfx*)LOAD_ASSET_RAW(actor->model), 1.0f, CollisionType::VTX_INTERSECT, 0.0f, (int32_t*)&actor->type, 0);
gEditor.AddObject(name, (FVector*) &actor->pos, (Gfx*)LOAD_ASSET_RAW(actor->model), 1.0f, CollisionType::VTX_INTERSECT, 0.0f, (int32_t*)&actor->type, 0);
} else {
gEditor.AddObject((FVector*) &actor->pos, NULL, 1.0f, CollisionType::VTX_INTERSECT, 0.0f, (int32_t*)&actor->type, 0);
gEditor.AddObject(name, (FVector*) &actor->pos, NULL, 1.0f, CollisionType::VTX_INTERSECT, 0.0f, (int32_t*)&actor->type, 0);
}
}
@@ -175,9 +175,9 @@ OObject* World::AddObject(OObject* object) {
Object* cObj = &gObjectList[object->_objectIndex];
if (cObj->model != NULL) {
gEditor.AddObject((FVector*) &cObj->origin_pos[0], (Gfx*)LOAD_ASSET_RAW(cObj->model), 1.0f, CollisionType::VTX_INTERSECT, 0.0f, &object->_objectIndex, -1);
gEditor.AddObject("", (FVector*) &cObj->origin_pos[0], (Gfx*)LOAD_ASSET_RAW(cObj->model), 1.0f, CollisionType::VTX_INTERSECT, 0.0f, &object->_objectIndex, -1);
} else {
gEditor.AddObject((FVector*) &cObj->origin_pos[0], NULL, 1.0f, CollisionType::VTX_INTERSECT, 0.0f, &object->_objectIndex, -1);
gEditor.AddObject("", (FVector*) &cObj->origin_pos[0], NULL, 1.0f, CollisionType::VTX_INTERSECT, 0.0f, &object->_objectIndex, -1);
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ public:
AActor* AddActor(AActor* actor);
struct Actor* AddBaseActor();
void AddEditorObject(Actor* actor);
void AddEditorObject(Actor* actor, const char* name);
AActor* GetActor(size_t index);
void TickActors();
+4 -4
View File
@@ -91,12 +91,12 @@ void Editor::Draw() {
eObjectPicker.Draw();
}
void Editor::AddObject(FVector* pos, Gfx* model, float scale, CollisionType collision, float boundingBoxSize, int32_t* despawnFlag, int32_t despawnValue) {
void Editor::AddObject(const char* name, FVector* pos, Gfx* model, float scale, CollisionType collision, float boundingBoxSize, int32_t* despawnFlag, int32_t despawnValue) {
if (model != NULL) {
eGameObjects.push_back({pos, model, {}, collision, boundingBoxSize, despawnFlag, despawnValue});
eGameObjects.push_back({name, pos, model, {}, collision, boundingBoxSize, despawnFlag, despawnValue});
GenerateCollisionMesh(eGameObjects.back(), model, scale);
} else { // to bounding box or sphere collision
eGameObjects.push_back({pos, model, {}, CollisionType::BOUNDING_BOX, 22.0f, despawnFlag, despawnValue});
eGameObjects.push_back({name, pos, model, {}, CollisionType::BOUNDING_BOX, 22.0f, despawnFlag, despawnValue});
}
}
@@ -107,5 +107,5 @@ void Editor::ClearObjects() {
void Editor::SelectObjectFromSceneExplorer(GameObject* object) {
eObjectPicker._selected = object;
eObjectPicker.eGizmo.Enabled = true;
eObjectPicker.eGizmo.EnableNoCursor(object);
eObjectPicker.eGizmo.SetGizmoNoCursor(object);
}
+1 -1
View File
@@ -19,7 +19,7 @@ public:
void Draw();
void MouseClick();
void Load();
void AddObject(FVector* pos, Gfx* model, float scale, CollisionType collision, float boundingBoxSize, int32_t* despawnFlag, int32_t despawnValue);
void AddObject(const char* name, FVector* pos, Gfx* model, float scale, CollisionType collision, float boundingBoxSize, int32_t* despawnFlag, int32_t despawnValue);
void ClearObjects();
void RemoveObject();
void SelectObjectFromSceneExplorer(GameObject* object);
+1
View File
@@ -23,6 +23,7 @@ struct Triangle {
};
struct GameObject {
const char* Name;
FVector* Pos;
Gfx* Model;
std::vector<Triangle> Triangles;
+2 -2
View File
@@ -49,7 +49,7 @@ void Gizmo::Tick() {
}
// Makes the gizmo visible
void Gizmo::Enable(GameObject* object, Ray ray) {
void Gizmo::SetGizmo(GameObject* object, Ray ray) {
_selected = object;
_ray = ray.Direction;
Pos = FVector(
@@ -59,7 +59,7 @@ void Gizmo::Enable(GameObject* object, Ray ray) {
);
}
void Gizmo::EnableNoCursor(GameObject* object) {
void Gizmo::SetGizmoNoCursor(GameObject* object) {
_selected = object;
Pos = FVector(
object->Pos->x,
+2 -2
View File
@@ -22,8 +22,8 @@ public:
void Draw();
void Load();
void Enable(GameObject* object, Ray ray);
void EnableNoCursor(GameObject* object); // Used for scene explorer selection
void SetGizmo(GameObject* object, Ray ray);
void SetGizmoNoCursor(GameObject* object); // Used for scene explorer selection
void Translate();
void DrawHandles();
f32 SnapToSurface(FVector* pos);
+1 -1
View File
@@ -49,7 +49,7 @@ void ObjectPicker::SelectObject(std::vector<GameObject>& objects) {
ObjectPicker::FindObject(ray, objects);
if (_selected != nullptr) {
eGizmo.Enable(_selected, ray);
eGizmo.SetGizmo(_selected, ray);
eGizmo.Enabled = true;
} else {
//eGizmo.Disable();
+2 -2
View File
@@ -673,8 +673,8 @@ struct Actor* CM_AddBaseActor() {
return (struct Actor*) gWorldInstance.AddBaseActor();
}
void CM_AddEditorObject(struct Actor* actor) {
gWorldInstance.AddEditorObject(actor);
void CM_AddEditorObject(struct Actor* actor, const char* name) {
gWorldInstance.AddEditorObject(actor, name);
}
size_t CM_GetActorSize() {
+1 -1
View File
@@ -140,7 +140,7 @@ void SetCourseByClass(void* course);
struct Actor* CM_GetActor(size_t index);
void CM_DeleteActor(size_t index);
struct Actor* CM_AddBaseActor();
void CM_AddEditorObject(struct Actor* actor);
void CM_AddEditorObject(struct Actor* actor, const char* name);
size_t CM_GetActorSize();
size_t CM_FindActorIndex(struct Actor* actor);
void CM_ActorCollision(Player* player, struct Actor* actor);
+1 -1
View File
@@ -26,7 +26,7 @@ namespace EditorNamespace {
int id = 0; // id for now because we don't have unique names atm
for (auto& object : gEditor.eGameObjects) {
std::string label = fmt::format("Object {}", id++);
if (ImGui::Button(label.c_str())) {
if (ImGui::Button(object.Name)) {
gEditor.SelectObjectFromSceneExplorer(&object);
}
}
+76 -1
View File
@@ -1415,7 +1415,7 @@ s16 add_actor_to_empty_slot(Vec3f pos, Vec3s rot, Vec3f velocity, s16 actorType)
gNumActors++;
struct Actor* actor = CM_AddBaseActor();
actor_init(actor, pos, rot, velocity, actorType);
CM_AddEditorObject(actor);
CM_AddEditorObject(actor, get_actor_name(actor->type));
return (s16) CM_GetActorSize() - 1; // Return current index;
}
@@ -2651,3 +2651,78 @@ void update_course_actors(void) {
evaluate_collision_for_destructible_actors();
check_player_use_item();
}
const char* get_actor_name(s32 id) {
switch(id) {
case ACTOR_FALLING_ROCK:
return "Falling Rock";
case ACTOR_GREEN_SHELL:
return "Green Shell";
case ACTOR_RED_SHELL:
return "Red Shell";
case ACTOR_BLUE_SPINY_SHELL:
return "Blue Spiny Shell";
case ACTOR_KIWANO_FRUIT:
return "Kiwano Fruit";
case ACTOR_BANANA:
return "Banana";
case ACTOR_PADDLE_BOAT:
return "Paddle Boat";
case ACTOR_TRAIN_ENGINE:
return "Train Engine";
case ACTOR_TRAIN_TENDER:
return "Train Tender";
case ACTOR_TRAIN_PASSENGER_CAR:
return "Train Passenger Car";
case ACTOR_ITEM_BOX:
return "Item Box";
case ACTOR_HOT_AIR_BALLOON_ITEM_BOX:
return "Hot Air Balloon Item Box";
case ACTOR_FAKE_ITEM_BOX:
return "Fake Item Box";
case ACTOR_PIRANHA_PLANT:
return "Piranha Plant";
case ACTOR_BANANA_BUNCH:
return "Banana Bunch";
case ACTOR_TRIPLE_GREEN_SHELL:
return "Triple Green Shell";
case ACTOR_TRIPLE_RED_SHELL:
return "Triple Red Shell";
case ACTOR_MARIO_SIGN:
return "Mario Sign";
case ACTOR_WARIO_SIGN:
return "Wario Sign";
case ACTOR_RAILROAD_CROSSING:
return "Railroad Crossing";
case ACTOR_TREE_MARIO_RACEWAY:
return "Tree (Mario Raceway)";
case ACTOR_TREE_YOSHI_VALLEY:
return "Tree (Yoshi Valley)";
case ACTOR_TREE_ROYAL_RACEWAY:
return "Tree (Royal Raceway)";
case ACTOR_TREE_MOO_MOO_FARM:
return "Tree (Moo Moo Farm)";
case ACTOR_PALM_TREE:
return "Palm Tree";
case ACTOR_UNKNOWN_0x1A:
return "Unknown Plant (0x1A)";
case ACTOR_UNKNOWN_0x1B:
return "Unknown (0x1B)";
case ACTOR_TREE_BOWSERS_CASTLE:
return "Tree (Bowser's Castle)";
case ACTOR_TREE_FRAPPE_SNOWLAND:
return "Tree (Frappe Snowland)";
case ACTOR_CACTUS1_KALAMARI_DESERT:
return "Cactus 1 (Kalamari Desert)";
case ACTOR_CACTUS2_KALAMARI_DESERT:
return "Cactus 2 (Kalamari Desert)";
case ACTOR_CACTUS3_KALAMARI_DESERT:
return "Cactus 3 (Kalamari Desert)";
case ACTOR_BUSH_BOWSERS_CASTLE:
return "Bush (Bowser's Castle)";
case ACTOR_YOSHI_EGG:
return "Yoshi Egg";
default:
return "Obj";
}
}
+1
View File
@@ -111,6 +111,7 @@ void render_actor_palm_tree(Camera*, Mat4, struct PalmTree*);
void render_item_boxes(struct UnkStruct_800DC5EC*);
void render_course_actors(struct UnkStruct_800DC5EC*);
void update_course_actors(void);
const char* get_actor_name(s32);
// audio/external.c
extern void func_800C98B8(Vec3f, Vec3f, u32);