Better Physics a little, New UI! And not only that, More simple scripting, Yey!!!!

This commit is contained in:
Anemunt
2026-01-01 00:35:51 -05:00
parent ac1fab021c
commit b5bbbc2937
18 changed files with 2528 additions and 373 deletions

View File

@@ -3,13 +3,11 @@
#include "ThirdParty/imgui/imgui.h"
namespace {
// Script state (persisted by AutoSetting binder)
bool autoRotate = false;
glm::vec3 spinSpeed = glm::vec3(0.0f, 45.0f, 0.0f); // deg/sec
glm::vec3 offset = glm::vec3(0.0f, 1.0f, 0.0f);
char targetName[128] = "MyTarget";
// Runtime behavior
static void ApplyAutoRotate(ScriptContext& ctx, float deltaTime) {
if (!autoRotate || !ctx.object) return;
ctx.SetRotation(ctx.object->rotation + spinSpeed * deltaTime);
@@ -17,7 +15,6 @@ namespace {
}
extern "C" void Script_OnInspector(ScriptContext& ctx) {
// Auto settings (loaded once, saved only when changed)
ctx.AutoSetting("autoRotate", autoRotate);
ctx.AutoSetting("spinSpeed", spinSpeed);
ctx.AutoSetting("offset", offset);
@@ -26,15 +23,10 @@ extern "C" void Script_OnInspector(ScriptContext& ctx) {
ImGui::TextUnformatted("SampleInspector");
ImGui::Separator();
bool changed = false;
changed |= ImGui::Checkbox("Auto Rotate", &autoRotate);
changed |= ImGui::DragFloat3("Spin Speed (deg/s)", &spinSpeed.x, 1.0f, -360.0f, 360.0f);
changed |= ImGui::DragFloat3("Offset", &offset.x, 0.1f);
changed |= ImGui::InputText("Target Name", targetName, sizeof(targetName));
if (changed) {
ctx.SaveAutoSettings();
}
ImGui::Checkbox("Auto Rotate", &autoRotate);
ImGui::DragFloat3("Spin Speed (deg/s)", &spinSpeed.x, 1.0f, -360.0f, 360.0f);
ImGui::DragFloat3("Offset", &offset.x, 0.1f);
ImGui::InputText("Target Name", targetName, sizeof(targetName));
if (ctx.object) {
ImGui::TextDisabled("Attached to: %s (id=%d)", ctx.object->name.c_str(), ctx.object->id);
@@ -44,15 +36,12 @@ extern "C" void Script_OnInspector(ScriptContext& ctx) {
}
}
if (ImGui::Button("Nudge Target")) {
if (SceneObject* target = ctx.FindObjectByName(targetName)) {
if (SceneObject* target = ctx.ResolveObjectRef(targetName)) {
target->position += offset;
}
}
}
void Begin(ScriptContext& ctx, float /*deltaTime*/) {
}
void Spec(ScriptContext& ctx, float deltaTime) {
ApplyAutoRotate(ctx, deltaTime);
}