diff --git a/.gitmodules b/.gitmodules index cdc2552..309fdb7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -24,4 +24,7 @@ url = https://github.com/EinScott/bon.git [submodule "GlitchyEngineHelper/vendor/DirectXTK"] path = GlitchyEngineHelper/vendor/DirectXTK - url = https://github.com/microsoft/DirectXTK.git \ No newline at end of file + url = https://github.com/microsoft/DirectXTK.git +[submodule "GlitchyEngine/vendor/box2D"] + path = GlitchyEngine/vendor/box2D + url = https://github.com/jazzbre/box2d-beef.git diff --git a/BeefSpace.toml b/BeefSpace.toml index 9b79ee0..3bc76be 100644 --- a/BeefSpace.toml +++ b/BeefSpace.toml @@ -1,6 +1,6 @@ FileVersion = 1 -Projects = {Sandbox = {Path = "Sandbox"}, GlitchyEngine = {Path = "GlitchyEngine"}, GlitchLog = {Path = "GlitchLog"}, DirectX = {Path = "GlitchyEngine/vendor/directx/DirectX"}, LodePng = {Path = "vendor/lodepng-beef/lodepng-beef"}, FreeType = {Path = "GlitchyEngine/vendor/freetype"}, cgltf-beef = {Path = "GlitchyEngine/vendor/gltf/cgltf-beef"}, GlitchyEditor = {Path = "GlitchyEditor"}, msdfgen-beef = {Path = "GlitchyEngine/vendor/msdfgen/msdfgen-beef"}, ImGui = {Path = "GlitchyEngine/vendor/imgui/ImGui"}, ImGuiImplDX11 = {Path = "GlitchyEngine/vendor/imgui/ImGuiImplDX11"}, ImGuiImplWin32 = {Path = "GlitchyEngine/vendor/imgui/ImGuiImplWin32"}, ImGuizmo = {Path = "GlitchyEngine/vendor/imgui/ImGuizmo"}, GlitchyEngineHelper = {Path = "GlitchyEngineHelper"}, bon = {Path = "GlitchyEngine/vendor/bon"}} -WorkspaceFolders = {GlitchyEngine = ["GlitchyEngine", "GlitchLog", "GlitchyEngineHelper"], "GlitchyEngine/Dependencies" = ["cgltf-beef", "DirectX", "FreeType", "ImGui", "ImGuiImplDX11", "ImGuiImplWin32", "ImGuizmo", "LodePng", "msdfgen-beef", "bon"]} +Projects = {Sandbox = {Path = "Sandbox"}, GlitchyEngine = {Path = "GlitchyEngine"}, GlitchLog = {Path = "GlitchLog"}, DirectX = {Path = "GlitchyEngine/vendor/directx/DirectX"}, LodePng = {Path = "vendor/lodepng-beef/lodepng-beef"}, FreeType = {Path = "GlitchyEngine/vendor/freetype"}, cgltf-beef = {Path = "GlitchyEngine/vendor/gltf/cgltf-beef"}, GlitchyEditor = {Path = "GlitchyEditor"}, msdfgen-beef = {Path = "GlitchyEngine/vendor/msdfgen/msdfgen-beef"}, ImGui = {Path = "GlitchyEngine/vendor/imgui/ImGui"}, ImGuiImplDX11 = {Path = "GlitchyEngine/vendor/imgui/ImGuiImplDX11"}, ImGuiImplWin32 = {Path = "GlitchyEngine/vendor/imgui/ImGuiImplWin32"}, ImGuizmo = {Path = "GlitchyEngine/vendor/imgui/ImGuizmo"}, GlitchyEngineHelper = {Path = "GlitchyEngineHelper"}, bon = {Path = "GlitchyEngine/vendor/bon"}, box2d-beef = {Path = "GlitchyEngine/vendor/box2D"}} +WorkspaceFolders = {GlitchyEngine = ["GlitchyEngine", "GlitchLog", "GlitchyEngineHelper"], "GlitchyEngine/Dependencies" = ["cgltf-beef", "DirectX", "FreeType", "ImGui", "ImGuiImplDX11", "ImGuiImplWin32", "ImGuizmo", "LodePng", "msdfgen-beef", "bon", "box2d-beef"]} [Workspace] StartupProject = "GlitchyEditor" diff --git a/GlitchyEditor/content/Scenes/physics2D.scene b/GlitchyEditor/content/Scenes/physics2D.scene new file mode 100644 index 0000000..0a75b30 --- /dev/null +++ b/GlitchyEditor/content/Scenes/physics2D.scene @@ -0,0 +1,168 @@ +{ + Name = "Scene name here pls!!!", + Entities = [ + { + Id = 0, + NameComponent = { + Name = "Quad" + }, + SpriterRendererComponent = { + Color = { + R = 0, + G = 0.551178, + B = 0.328787, + A = 1 + }, + UvTransform = { + X = 0, + Y = 0, + Z = 1, + W = 1 + } + }, + TransformComponent = { + Position = { + X = 0, + Y = 2, + Z = 0 + }, + Rotation = { + X = 0, + Y = 0, + Z = 0, + W = 1 + }, + Scale = { + X = 1, + Y = 1, + Z = 1 + }, + EditorEulerRotation = { + X = 0, + Y = 0, + Z = 0 + } + }, + Rigidbody2D = { + BodyType = .Dynamic, + FixedRotation = false + }, + BoxCollider2D = { + Offset = { + X = 0, + Y = 0 + }, + Size = { + X = 0.5, + Y = 0.5 + }, + Density = 1, + Friction = 0.5, + Restitution = 0, + RestitutionThreshold = 0.5 + } + }, + { + Id = 1, + NameComponent = { + Name = "Floor" + }, + SpriterRendererComponent = { + Color = { + R = 1, + G = 0.941886, + B = 0.401485, + A = 1 + }, + UvTransform = { + X = 0, + Y = 0, + Z = 1, + W = 1 + } + }, + TransformComponent = { + Position = { + X = 0, + Y = -0.5, + Z = 0 + }, + Rotation = { + X = 0, + Y = 0, + Z = 0, + W = 1 + }, + Scale = { + X = 10, + Y = 1, + Z = 1 + }, + EditorEulerRotation = { + X = 0, + Y = 0, + Z = 0 + } + }, + Rigidbody2D = { + BodyType = .Static, + FixedRotation = false + }, + BoxCollider2D = { + Offset = { + X = 0, + Y = 0 + }, + Size = { + X = 0.5, + Y = 0.5 + }, + Density = 1, + Friction = 0.5, + Restitution = 0, + RestitutionThreshold = 0.5 + } + }, + { + Id = 2, + NameComponent = { + Name = "Camera" + }, + TransformComponent = { + Position = { + X = 0, + Y = 1, + Z = -5 + }, + Rotation = { + X = 0, + Y = 0, + Z = 0, + W = 1 + }, + Scale = { + X = 1, + Y = 1, + Z = 1 + }, + EditorEulerRotation = { + X = 0, + Y = 0, + Z = 0 + } + }, + CameraComponent = { + Primary = true, + ProjectionType = .InfinitePerspective, + PerspectiveFovY = 1.308997, + PerspectiveNearPlane = 0.1, + PerspectiveFarPlane = 10000, + OrthographicHeight = 10, + OrthographicNearPlane = 0, + OrthographicFarPlane = 10, + AspectRatio = 2.329843, + FixedAspectRatio = false + } + } + ] +} \ No newline at end of file diff --git a/GlitchyEditor/src/EditWindows/ComponentEditWindow.bf b/GlitchyEditor/src/EditWindows/ComponentEditWindow.bf index c604c5a..7abacdd 100644 --- a/GlitchyEditor/src/EditWindows/ComponentEditWindow.bf +++ b/GlitchyEditor/src/EditWindows/ComponentEditWindow.bf @@ -64,6 +64,8 @@ namespace GlitchyEditor.EditWindows ShowComponentEditor("Mesh Renderer", entity, => ShowMeshRendererComponentEditor, => ShowComponentContextMenu); ShowComponentEditor("Light", entity, => ShowLightComponentEditor, => ShowComponentContextMenu); ShowComponentEditor("Mesh", entity, => ShowMeshComponentEditor, => ShowComponentContextMenu); + ShowComponentEditor("Rigidbody 2D", entity, => ShowRigidBody2DComponentEditor, => ShowComponentContextMenu); + ShowComponentEditor("Box collider 2D", entity, => ShowBoxCollider2DComponentEditor, => ShowComponentContextMenu); ShowAddComponentButton(entity); } @@ -410,6 +412,64 @@ namespace GlitchyEditor.EditWindows } } } + + private static void ShowRigidBody2DComponentEditor(Entity entity, Rigidbody2DComponent* rigidBodyComponent) + { + const String[?] bodyTypeStrings = .("Static", "Dynamic", "Kinematic"); + String bodyTypeName = bodyTypeStrings[rigidBodyComponent.BodyType.Underlying]; + + if (ImGui.BeginCombo("Type", bodyTypeName.CStr())) + { + for (int i = 0; i < 3; i++) + { + bool isSelected = (bodyTypeName == bodyTypeStrings[i]); + + if (ImGui.Selectable(bodyTypeStrings[i], isSelected)) + { + rigidBodyComponent.BodyType = (.)i; + } + + if (isSelected) + ImGui.SetItemDefaultFocus(); + } + + ImGui.EndCombo(); + } + + + ImGui.Checkbox("Fixed Rotation", &rigidBodyComponent.FixedRotation); + } + + private static void ShowBoxCollider2DComponentEditor(Entity entity, BoxCollider2DComponent* boxCollider) + { + float textWidth = ImGui.CalcTextSize("Offset".CStr()).x; + textWidth += ImGui.GetStyle().FramePadding.x * 3.0f; + + + Vector2 offset = boxCollider.Offset; + if (ImGui.EditVector2("Offset", ref offset, .Zero, 0.1f, textWidth)) + boxCollider.Offset = offset; + + Vector2 size = boxCollider.Size; + if (ImGui.EditVector2("Size", ref size, .Zero, 0.1f, textWidth)) + boxCollider.Size = size; + + float density = boxCollider.Density; + if (ImGui.DragFloat("Density", &density, 0.0f, 0.1f, textWidth)) + boxCollider.Density = density; + + float friction = boxCollider.Friction; + if (ImGui.DragFloat("Friction", &friction, 0.0f, 0.1f, textWidth)) + boxCollider.Friction = friction; + + float restitution = boxCollider.Restitution; + if (ImGui.DragFloat("Restitution", &restitution, 0.0f, 0.1f, textWidth)) + boxCollider.Restitution = restitution; + + float restitutionThreshold = boxCollider.RestitutionThreshold; + if (ImGui.DragFloat("RestitutionThreshold", &restitutionThreshold, 0.0f, 0.1f, textWidth)) + boxCollider.RestitutionThreshold = restitutionThreshold; + } private static void LabelColumn(StringView label) { @@ -517,6 +577,10 @@ namespace GlitchyEditor.EditWindows void ShowComponentButton(String name) where TComponent : struct, new { + // If the entity already has this component, don't show the option to add it + if (entity.HasComponent()) + return; + float textWidth = ImGui.CalcTextSize(name.CStr()).x; buttonWidth = Math.Max(buttonWidth, textWidth + ImGui.GetStyle().FramePadding.x * 2); @@ -547,6 +611,8 @@ namespace GlitchyEditor.EditWindows ShowComponentButton("Camera"); ShowComponentButton("Sprite Renderer"); ShowComponentButton("Light"); + ShowComponentButton("Rigidbody 2D"); + ShowComponentButton("Box collider 2D"); ImGui.EndCombo(); } diff --git a/GlitchyEditor/src/EditorLayer.bf b/GlitchyEditor/src/EditorLayer.bf index 9064ea1..8384637 100644 --- a/GlitchyEditor/src/EditorLayer.bf +++ b/GlitchyEditor/src/EditorLayer.bf @@ -310,12 +310,16 @@ namespace GlitchyEditor { _sceneState = .Play; _editor.SceneViewportWindow.EditorMode = false; + + _scene.OnRuntimeStart(); } private void OnSceneStop() { - _sceneState = .Edit; + _scene.OnRuntimeStop(); + _editor.SceneViewportWindow.EditorMode = true; + _sceneState = .Edit; } // Just for testing @@ -459,19 +463,26 @@ namespace GlitchyEditor _camera.Position = .(-1.5f, 1.5f, -2.5f); _camera.RotationEuler = .(MathHelper.ToRadians(25), MathHelper.ToRadians(35), 0); + /*// Create default camera + { + let camEntity = _scene.CreateEntity("Camera"); + let transform = camEntity.Transform; + transform.Position = + } + // Create the default light source { - var lightNtt = _scene.CreateEntity("Light"); - let transform = lightNtt.GetComponent(); + let lightNtt = _scene.CreateEntity("Light"); + let transform = lightNtt.Transform; transform.Position = .(0, 0, 0); transform.RotationEuler = .(MathHelper.ToRadians(45), MathHelper.ToRadians(-100), 0); let light = lightNtt.AddComponent(); light.SceneLight.Illuminance = 10.0f; light.SceneLight.Color = .(1.0f, 0.95f, 0.8f); - } + }*/ - TestEntitiesWithModels(); + //TestEntitiesWithModels(); } /// Saves the scene in the file that is was loaded from or saved to last. If there is no such path (i.e. it is a new scene) the save file dialog will open. diff --git a/GlitchyEngine/BeefProj.toml b/GlitchyEngine/BeefProj.toml index ee76dff..35c9304 100644 --- a/GlitchyEngine/BeefProj.toml +++ b/GlitchyEngine/BeefProj.toml @@ -1,5 +1,5 @@ FileVersion = 1 -Dependencies = {GlitchLog = "*", corlib = "*", DirectX = "*", FreeType = "*", cgltf-beef = "*", msdfgen-beef = "*", ImGui = "*", ImGuiImplDX11 = "*", ImGuiImplWin32 = "*", ImGuizmo = "*", Beefy2D = "*", LodePng = "*", GlitchyEngineHelper = "*", bon = "*"} +Dependencies = {GlitchLog = "*", corlib = "*", DirectX = "*", FreeType = "*", cgltf-beef = "*", msdfgen-beef = "*", ImGui = "*", ImGuiImplDX11 = "*", ImGuiImplWin32 = "*", ImGuizmo = "*", Beefy2D = "*", LodePng = "*", GlitchyEngineHelper = "*", bon = "*", box2d-beef = "*"} [Project] Name = "GlitchyEngine" diff --git a/GlitchyEngine/src/Math/ColorRGBA.bf b/GlitchyEngine/src/Math/ColorRGBA.bf index 11ced00..efe6bf4 100644 --- a/GlitchyEngine/src/Math/ColorRGBA.bf +++ b/GlitchyEngine/src/Math/ColorRGBA.bf @@ -1,4 +1,5 @@ using System; +using Bon; using internal GlitchyEngine.Math; @@ -13,6 +14,7 @@ namespace GlitchyEngine.Math /** Represents a four component floating point color */ + [BonTarget] [CRepr] struct ColorRGBA { diff --git a/GlitchyEngine/src/World/Components.bf b/GlitchyEngine/src/World/Components.bf index b9ca5fd..b8451ad 100644 --- a/GlitchyEngine/src/World/Components.bf +++ b/GlitchyEngine/src/World/Components.bf @@ -337,4 +337,29 @@ namespace GlitchyEngine.World { public SceneLight SceneLight; } + + struct Rigidbody2DComponent + { + public enum BodyType { Static = 0, Dynamic = 1, Kinematic = 2 } + + public BodyType BodyType = .Static; + + public bool FixedRotation = false; + + internal int _runtimeBody = 0; + } + + struct BoxCollider2DComponent + { + public Vector2 Offset = .(0.0f, 0.0f); + public Vector2 Size = .(0.5f, 0.5f); + + // TODO: move into 2D physics material + public float Density = 1.0f; + public float Friction = 0.5f; + public float Restitution = 0.0f; + public float RestitutionThreshold = 0.5f; + + internal int _runtimeFixture = 0; + } } \ No newline at end of file diff --git a/GlitchyEngine/src/World/Entity.bf b/GlitchyEngine/src/World/Entity.bf index 43ad148..f4d380d 100644 --- a/GlitchyEngine/src/World/Entity.bf +++ b/GlitchyEngine/src/World/Entity.bf @@ -63,6 +63,8 @@ namespace GlitchyEngine.World } } + public TransformComponent* Transform => GetComponent(); + public T* AddComponent(T value = T()) where T: struct, new { Log.EngineLogger.AssertDebug(!HasComponent(), scope $"Entity already has component."); @@ -85,6 +87,18 @@ namespace GlitchyEngine.World { return _scene._ecsWorld.HasComponent(_entity); } + + public bool TryGetComponent(out T* component) where T: struct, new + { + if (HasComponent()) + { + component = GetComponent(); + return true; + } + + component = null; + return false; + } public void RemoveComponent() where T: struct, new { diff --git a/GlitchyEngine/src/World/Scene.bf b/GlitchyEngine/src/World/Scene.bf index 11beb4a..6fc59ad 100644 --- a/GlitchyEngine/src/World/Scene.bf +++ b/GlitchyEngine/src/World/Scene.bf @@ -2,19 +2,26 @@ using GlitchyEngine.Math; using GlitchyEngine.Renderer; using System; using System.Collections; +using Box2D; namespace GlitchyEngine.World { using internal ScriptableEntity; + using internal GlitchyEngine.World; class Scene { internal EcsWorld _ecsWorld = new .() ~ delete _; - + + internal b2World* _physicsWorld2D; + private Dictionary _onComponentAddedHandlers = new .() ~ delete _; private RenderTargetGroup _compositeTarget ~ _.ReleaseRef(); + // Temporary target for camera. Needs to change as soon as we support multiple cameras + private RenderTargetGroup _cameraTarget ~ _.ReleaseRef(); + private Effect _gammaCorrectEffect ~ _.ReleaseRef(); public Entity ActiveCamera => { @@ -54,21 +61,134 @@ namespace GlitchyEngine.World RenderTargetFormat.D24_UNorm_S8_UInt); _compositeTarget = new RenderTargetGroup(desc); + _cameraTarget = new RenderTargetGroup(.(){ + Width = 100, + Height = 100, + ColorTargetDescriptions = TargetDescription[]( + .(.R16G16B16A16_Float), + .(.R32_UInt) + ), + DepthTargetDescription = .(.D24_UNorm_S8_UInt) + }); + _gammaCorrectEffect = Application.Get().EffectLibrary.Load("content/Shaders/GammaCorrect.hlsl"); } public ~this() { } + + b2Vec2 _gravity2D = .(0.0f, -9.8f); + + static b2BodyType GetBox2DBodyType(Rigidbody2DComponent.BodyType bodyType) + { + switch (bodyType) + { + case .Static: + return .b2_staticBody; + case .Dynamic: + return .b2_dynamicBody; + case .Kinematic: + return .b2_kinematicBody; + default: + Log.EngineLogger.AssertDebug(false, "Unknown body type"); + return .b2_staticBody; + } + } + + public void OnRuntimeStart() + { + _physicsWorld2D = Box2D.World.Create(ref _gravity2D); + + for (var entry in _ecsWorld.Enumerate()) + { + Entity entity = .(entry.Entity, this); + + var transform = entity.Transform; + var rigidBody = entry.Component; + + b2BodyDef def = .(); + def.type = GetBox2DBodyType(rigidBody.BodyType); + + // TODO: breaks with hierarchy + def.position = b2Vec2(transform.Position.X, transform.Position.Y); + def.angle = transform.RotationEuler.Z; + + b2Body* body = Box2D.World.CreateBody(_physicsWorld2D, &def); + Box2D.Body.SetFixedRotation(body, rigidBody.FixedRotation); + + rigidBody._runtimeBody = (int)(void*)body; + + if (entity.TryGetComponent(let boxCollider)) + { + b2Shape* boxShape = Box2D.Shape.CreatePolygon(); + Box2D.Shape.PolygonSetAsBox(boxShape, boxCollider.Size.X * transform.Scale.X, boxCollider.Size.Y * transform.Scale.Y); + + b2FixtureDef fixtureDef = .(); + fixtureDef.shape = boxShape; + fixtureDef.density = boxCollider.Density; + fixtureDef.friction = boxCollider.Friction; + fixtureDef.restitution = boxCollider.Restitution; + fixtureDef.restitutionThreshold = boxCollider.RestitutionThreshold; + + b2Fixture* fixture = Box2D.Body.CreateFixture(body, &fixtureDef); + boxCollider._runtimeFixture = (int)(void*)fixture; + } + } + } + + public void OnRuntimeStop() + { + Box2D.World.Delete(_physicsWorld2D); + _physicsWorld2D = null; + } public void UpdateRuntime(GameTime gameTime, RenderTargetGroup finalTarget) { Debug.Profiler.ProfileRendererFunction!(); finalTarget.AddRef(); - + TransformSystem.Update(_ecsWorld); + // Run scripts + for (var (entity, script) in _ecsWorld.Enumerate()) + { + if (script.Instance == null) + { + script.Instance = script.InstantiateFunction(); + script.Instance._entity = Entity(entity, this); + script.Instance.[Friend]OnCreate(); + } + + script.Instance.[Friend]OnUpdate(gameTime); + } + + // Update 2D physics + { + const int32 velocityIterations = 6; + const int32 positionIterations = 2; + const int32 particleIterations = 2; + + Box2D.World.Step(_physicsWorld2D, gameTime.DeltaTime, velocityIterations, positionIterations, particleIterations); + + // Retrieve transform from Box2D + for (var entry in _ecsWorld.Enumerate()) + { + Entity entity = .(entry.Entity, this); + + var transform = entity.Transform; + var rigidbody = entry.Component; + + b2Body* body = (b2Body*)(void*)rigidbody._runtimeBody; + b2Vec2 position = Box2D.Body.GetPosition(body); + float angle = Box2D.Body.GetAngle(body); + + transform.Position = .(position.x, position.y, transform.Position.Z); + transform.RotationEuler = .(transform.RotationEuler.XY, angle); + } + } + // Find camera Camera* primaryCamera = null; Matrix primaryCameraTransform = default; @@ -80,7 +200,8 @@ namespace GlitchyEngine.World { primaryCamera = &camera.Camera; primaryCameraTransform = transform.WorldTransform; - renderTarget = camera.RenderTarget..AddRef(); + // TODO: bind render targets to cameras + // renderTarget = camera.RenderTarget..AddRef(); } } @@ -392,6 +513,7 @@ namespace GlitchyEngine.World } _compositeTarget.Resize(ViewportWidth, ViewportHeight); + _cameraTarget.Resize(ViewportWidth, ViewportHeight); } private void OnComponentAdded(Entity entity, Type componentType, void* component) diff --git a/GlitchyEngine/src/World/SceneSerializer.bf b/GlitchyEngine/src/World/SceneSerializer.bf index 36099b9..517c44c 100644 --- a/GlitchyEngine/src/World/SceneSerializer.bf +++ b/GlitchyEngine/src/World/SceneSerializer.bf @@ -81,6 +81,7 @@ namespace GlitchyEngine.World // TODO: Texture Serialize.Value(writer, "Color", component.Color); + Serialize.Value(writer, "UvTransform", component.UvTransform); }); SerializeComponent(writer, entity, "TransformComponent", scope (component) => @@ -128,6 +129,24 @@ namespace GlitchyEngine.World Serialize.Value(writer, "Color", light.Color); }); + + SerializeComponent(writer, entity, "Rigidbody2D", scope (component) => + { + Serialize.Value(writer, "BodyType", component.BodyType); + + Serialize.Value(writer, "FixedRotation", component.FixedRotation); + }); + + SerializeComponent(writer, entity, "BoxCollider2D", scope (component) => + { + Serialize.Value(writer, "Offset", component.Offset); + Serialize.Value(writer, "Size", component.Size); + + Serialize.Value(writer, "Density", component.Density); + Serialize.Value(writer, "Friction", component.Friction); + Serialize.Value(writer, "Restitution", component.Restitution); + Serialize.Value(writer, "RestitutionThreshold", component.RestitutionThreshold); + }); } writer.EntryEnd(); @@ -252,6 +271,8 @@ namespace GlitchyEngine.World // TODO: Texture Try!(Deserialize.Value(reader, "Color", out component.Color)); + reader.EntryEnd(); + Try!(Deserialize.Value(reader, "UvTransform", out component.UvTransform)); return .Ok; })); @@ -337,9 +358,38 @@ namespace GlitchyEngine.World Deserialize.Value(reader, "Color", out light.[Friend]_color); return .Ok; })); + case "Rigidbody2D": + Try!(DeserializeComponent(reader, entity, scope (component) => + { + Deserialize.Value(reader, "BodyType", out component.BodyType); + reader.EntryEnd(); + + Deserialize.Value(reader, "FixedRotation", out component.FixedRotation); + + return .Ok; + })); + case "BoxCollider2D": + Try!(DeserializeComponent(reader, entity, scope (component) => + { + Deserialize.Value(reader, "Offset", out component.Offset); + reader.EntryEnd(); + Deserialize.Value(reader, "Size", out component.Size); + reader.EntryEnd(); + + Deserialize.Value(reader, "Density", out component.Density); + reader.EntryEnd(); + Deserialize.Value(reader, "Friction", out component.Friction); + reader.EntryEnd(); + Deserialize.Value(reader, "Restitution", out component.Restitution); + reader.EntryEnd(); + Deserialize.Value(reader, "RestitutionThreshold", out component.RestitutionThreshold); + + return .Ok; + })); default: - return .Err; + Log.EngineLogger.AssertDebug(false, "Unknown component type"); + //return .Err; } } diff --git a/GlitchyEngine/vendor/box2D b/GlitchyEngine/vendor/box2D new file mode 160000 index 0000000..5990578 --- /dev/null +++ b/GlitchyEngine/vendor/box2D @@ -0,0 +1 @@ +Subproject commit 5990578fdcfba275c96f91453d7150203865d2a1