From 35e446f65d9000de4f2d50360991405f10e195bd Mon Sep 17 00:00:00 2001
From: OusmBlueNinja <89956790+OusmBlueNinja@users.noreply.github.com>
Date: Fri, 18 Apr 2025 20:38:47 -0500
Subject: [PATCH] Remove box2d submodule but keep source

---
 .gitmodules                             |   5 +-
 remake.yaml                             |   8 +-
 remake/build.log                        |  85 ++------------------
 src/src/Components/PhysicsComponent.cpp | 100 ------------------------
 src/src/Components/PhysicsComponent.h   |  36 ---------
 5 files changed, 15 insertions(+), 219 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index af59c89..ab5f728 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
 [submodule "Remake"]
 	path = Remake
-	url = https://dock-it.dev/GigabiteStudios/Remake.git
\ No newline at end of file
+	url = https://dock-it.dev/GigabiteStudios/Remake.git
+[submodule "src/vendor/box2d"]
+	path = src/vendor/box2d
+	url = https://github.com/erincatto/box2d.git
diff --git a/remake.yaml b/remake.yaml
index 485d314..93f25cf 100644
--- a/remake.yaml
+++ b/remake.yaml
@@ -1,13 +1,11 @@
-# 🔧 Remake Build Configuration
+# Remake Build Configuration
 
 # Source folders to recursively find .c/.cpp files
 src_dirs:
   - src/src
   - src/vendor
   - src/include/lua
-  - src/vendor/box2d
-
-
+  - src/vendor/box2d/src  # <- actual Box2D sources if you're compiling them
 
 # Include directories (-I)
 include_dirs:
@@ -15,7 +13,7 @@ include_dirs:
   - src/include/lua
   - src/vendor
   - src/vendor/imgui
-  - src/vendor/box2d/
+  - src/vendor/box2d/include  # ✅ correct Box2D C++ API include path
 
   - C:/msys64/mingw64/include
 
diff --git a/remake/build.log b/remake/build.log
index c340b3f..7dd4292 100644
--- a/remake/build.log
+++ b/remake/build.log
@@ -1,77 +1,8 @@
-[ERROR] g++ -std=c++20 -Wall -g -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d/ -IC:/msys64/mingw64/include -IC:\msys64\mingw64\lib\libyaml-cpp.a -Isrc\vendor\imgui -MMD -MP -c src\src\Components\PhysicsComponent.cpp -o src\build\Components\PhysicsComponent.o
-cc1plus.exe: warning: C:\msys64\mingw64\lib\libyaml-cpp.a: not a directory
-In file included from C:/msys64/mingw64/include/yaml-cpp/parser.h:13,
-                 from C:/msys64/mingw64/include/yaml-cpp/yaml.h:10,
-                 from src\src\Components\Component.h:5,
-                 from src\src\Components\PhysicsComponent.h:2,
-                 from src\src\Components\PhysicsComponent.cpp:1:
-C:/msys64/mingw64/include/yaml-cpp/dll.h:22:65: note: '#pragma message: Defining YAML_CPP_API for DLL import'
-   22 | #        pragma message( "Defining YAML_CPP_API for DLL import" )
-      |                                                                 ^
-src\src\Components\PhysicsComponent.h:13:21: error: 'b2World' has not been declared
-   13 |     void CreateBody(b2World* world, const glm::vec2& position);
-      |                     ^~~~~~~
-src\src\Components\PhysicsComponent.h:29:5: error: 'b2Body' does not name a type; did you mean 'b2BodyId'?
-   29 |     b2Body* body = nullptr;
-      |     ^~~~~~
-      |     b2BodyId
-src\src\Components\PhysicsComponent.h:30:5: error: 'b2World' does not name a type; did you mean 'b2WorldId'?
-   30 |     b2World* world = nullptr;
-      |     ^~~~~~~
-      |     b2WorldId
-src\src\Components\PhysicsComponent.h:26:10: error: 'void PhysicsComponent::OnImGuiInspector()' marked 'override', but does not override
-   26 |     void OnImGuiInspector() override;
-      |          ^~~~~~~~~~~~~~~~
-src\src\Components\PhysicsComponent.cpp:12:6: error: variable or field 'CreateBody' declared void
-   12 | void PhysicsComponent::CreateBody(b2World* world, const glm::vec2& position) {
-      |      ^~~~~~~~~~~~~~~~
-src\src\Components\PhysicsComponent.cpp:12:35: error: 'b2World' was not declared in this scope; did you mean 'b2WorldId'?
-   12 | void PhysicsComponent::CreateBody(b2World* world, const glm::vec2& position) {
-      |                                   ^~~~~~~
-      |                                   b2WorldId
-src\src\Components\PhysicsComponent.cpp:12:44: error: 'world' was not declared in this scope
-   12 | void PhysicsComponent::CreateBody(b2World* world, const glm::vec2& position) {
-      |                                            ^~~~~
-src\src\Components\PhysicsComponent.cpp:12:51: error: expected primary-expression before 'const'
-   12 | void PhysicsComponent::CreateBody(b2World* world, const glm::vec2& position) {
-      |                                                   ^~~~~
-src\src\Components\PhysicsComponent.cpp: In member function 'void PhysicsComponent::DestroyBody()':
-src\src\Components\PhysicsComponent.cpp:39:9: error: 'body' was not declared in this scope
-   39 |     if (body && world) {
-      |         ^~~~
-src\src\Components\PhysicsComponent.cpp:39:17: error: 'world' was not declared in this scope
-   39 |     if (body && world) {
-      |                 ^~~~~
-src\src\Components\PhysicsComponent.cpp: In member function 'void PhysicsComponent::SetVelocity(const glm::vec2&)':
-src\src\Components\PhysicsComponent.cpp:46:9: error: 'body' was not declared in this scope
-   46 |     if (body) body->SetLinearVelocity(b2Vec2(vel.x, vel.y));
-      |         ^~~~
-src\src\Components\PhysicsComponent.cpp: In member function 'glm::vec2 PhysicsComponent::GetVelocity() const':
-src\src\Components\PhysicsComponent.cpp:50:9: error: 'body' was not declared in this scope
-   50 |     if (body) {
-      |         ^~~~
-src\src\Components\PhysicsComponent.cpp: In member function 'void PhysicsComponent::SetFriction(float)':
-src\src\Components\PhysicsComponent.cpp:59:9: error: 'body' was not declared in this scope
-   59 |     if (body && body->GetFixtureList())
-      |         ^~~~
-src\src\Components\PhysicsComponent.cpp: In member function 'void PhysicsComponent::SetFixedRotation(bool)':
-src\src\Components\PhysicsComponent.cpp:70:9: error: 'body' was not declared in this scope
-   70 |     if (body)
-      |         ^~~~
-src\src\Components\PhysicsComponent.cpp: In member function 'void PhysicsComponent::SyncFromPhysics()':
-src\src\Components\PhysicsComponent.cpp:75:9: error: 'body' was not declared in this scope
-   75 |     if (body) {
-      |         ^~~~
-src\src\Components\PhysicsComponent.cpp:77:9: error: 'object' was not declared in this scope; did you mean 'Object'?
-   77 |         object->SetLocalPosition({ pos.x, pos.y });
-      |         ^~~~~~
-      |         Object
-src\src\Components\PhysicsComponent.cpp: In member function 'void PhysicsComponent::SyncToPhysics()':
-src\src\Components\PhysicsComponent.cpp:82:9: error: 'body' was not declared in this scope
-   82 |     if (body) {
-      |         ^~~~
-src\src\Components\PhysicsComponent.cpp:83:25: error: 'object' was not declared in this scope; did you mean 'Object'?
-   83 |         glm::vec2 pos = object->GetLocalPosition();
-      |                         ^~~~~~
-      |                         Object
-
+[COMPILE] g++ -std=c++20 -Wall -g -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d/include -IC:/msys64/mingw64/include -IC:\msys64\mingw64\lib\libyaml-cpp.a -Isrc\vendor\imgui -MMD -MP -c src\src\Components\PhysicsComponent.cpp -o src\build\Components\PhysicsComponent.o
+[ERROR] gcc -std=c99 -Wall -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d/include -IC:/msys64/mingw64/include -IC:\msys64\mingw64\lib\libyaml-cpp.a -Isrc\vendor\imgui -MMD -MP -c src\vendor\box2d\benchmark\main.c -o src\build\box2d\benchmark\main.o
+cc1.exe: warning: C:\msys64\mingw64\lib\libyaml-cpp.a: not a directory
+src\vendor\box2d\benchmark\main.c:8:10: fatal error: TaskScheduler_c.h: No such file or directory
+    8 | #include "TaskScheduler_c.h"
+      |          ^~~~~~~~~~~~~~~~~~~
+compilation terminated.

+
diff --git a/src/src/Components/PhysicsComponent.cpp b/src/src/Components/PhysicsComponent.cpp
index 90a476f..e69de29 100644
--- a/src/src/Components/PhysicsComponent.cpp
+++ b/src/src/Components/PhysicsComponent.cpp
@@ -1,100 +0,0 @@
-#include "PhysicsComponent.h"
-#include "../Entitys/Object.h"
-#include "imgui.h"
-
-PhysicsComponent::PhysicsComponent(Object* owner, BodyType type, float width, float height)
-    : Component(owner), type(type), width(width), height(height) {}
-
-PhysicsComponent::~PhysicsComponent() {
-    DestroyBody();
-}
-
-void PhysicsComponent::CreateBody(b2World* world, const glm::vec2& position) {
-    this->world = world;
-    b2BodyDef def;
-
-    switch (type) {
-        case BodyType::Static:    def.type = b2_staticBody; break;
-        case BodyType::Dynamic:   def.type = b2_dynamicBody; break;
-        case BodyType::Kinematic: def.type = b2_kinematicBody; break;
-    }
-
-    def.position.Set(position.x, position.y);
-    def.fixedRotation = fixedRotation;
-
-    body = world->CreateBody(&def);
-
-    b2PolygonShape box;
-    box.SetAsBox(width * 0.5f, height * 0.5f);
-
-    b2FixtureDef fixtureDef;
-    fixtureDef.shape = &box;
-    fixtureDef.density = density;
-    fixtureDef.friction = friction;
-
-    body->CreateFixture(&fixtureDef);
-}
-
-void PhysicsComponent::DestroyBody() {
-    if (body && world) {
-        world->DestroyBody(body);
-        body = nullptr;
-    }
-}
-
-void PhysicsComponent::SetVelocity(const glm::vec2& vel) {
-    if (body) body->SetLinearVelocity(b2Vec2(vel.x, vel.y));
-}
-
-glm::vec2 PhysicsComponent::GetVelocity() const {
-    if (body) {
-        b2Vec2 v = body->GetLinearVelocity();
-        return { v.x, v.y };
-    }
-    return {};
-}
-
-void PhysicsComponent::SetFriction(float f) {
-    friction = f;
-    if (body && body->GetFixtureList())
-        body->GetFixtureList()->SetFriction(f);
-}
-
-void PhysicsComponent::SetDensity(float d) {
-    density = d;
-    // Requires refixture to apply
-}
-
-void PhysicsComponent::SetFixedRotation(bool fixed) {
-    fixedRotation = fixed;
-    if (body)
-        body->SetFixedRotation(fixed);
-}
-
-void PhysicsComponent::SyncFromPhysics() {
-    if (body) {
-        b2Vec2 pos = body->GetPosition();
-        object->SetLocalPosition({ pos.x, pos.y });
-    }
-}
-
-void PhysicsComponent::SyncToPhysics() {
-    if (body) {
-        glm::vec2 pos = object->GetLocalPosition();
-        body->SetTransform({ pos.x, pos.y }, body->GetAngle());
-    }
-}
-
-void PhysicsComponent::OnImGuiInspector() {
-    ImGui::Text("Physics Component");
-
-    glm::vec2 vel = GetVelocity();
-    if (ImGui::DragFloat2("Velocity", &vel.x))
-        SetVelocity(vel);
-
-    if (ImGui::DragFloat("Friction", &friction, 0.01f, 0.0f, 1.0f))
-        SetFriction(friction);
-
-    if (ImGui::Checkbox("Fixed Rotation", &fixedRotation))
-        SetFixedRotation(fixedRotation);
-}
diff --git a/src/src/Components/PhysicsComponent.h b/src/src/Components/PhysicsComponent.h
index 59a5d43..e69de29 100644
--- a/src/src/Components/PhysicsComponent.h
+++ b/src/src/Components/PhysicsComponent.h
@@ -1,36 +0,0 @@
-#pragma once
-#include "Component.h"
-#include <box2d.h>
-#include <glm/glm.hpp>
-
-class PhysicsComponent : public Component {
-public:
-    enum class BodyType { Static, Dynamic, Kinematic };
-
-    PhysicsComponent(Object* owner, BodyType type = BodyType::Dynamic, float width = 1.0f, float height = 1.0f);
-    ~PhysicsComponent();
-
-    void CreateBody(b2World* world, const glm::vec2& position);
-    void DestroyBody();
-
-    void SetVelocity(const glm::vec2& vel);
-    glm::vec2 GetVelocity() const;
-
-    void SetFriction(float friction);
-    void SetDensity(float density);
-    void SetFixedRotation(bool fixed);
-
-    void SyncFromPhysics();
-    void SyncToPhysics();
-
-    void OnImGuiInspector() override;
-
-private:
-    b2Body* body = nullptr;
-    b2World* world = nullptr;
-    BodyType type;
-    float width, height;
-    float friction = 0.3f;
-    float density = 1.0f;
-    bool fixedRotation = false;
-};