From 5c613a10364f30bd6add25f7950433f0c482c3ca Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 31 Oct 2021 13:54:11 -0400 Subject: (mkosarek) Working undamped spring motion --- 2d/_collisions/rectangle_line/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to '2d/_collisions/rectangle_line') diff --git a/2d/_collisions/rectangle_line/main.cpp b/2d/_collisions/rectangle_line/main.cpp index 25e124c..49ce7d7 100644 --- a/2d/_collisions/rectangle_line/main.cpp +++ b/2d/_collisions/rectangle_line/main.cpp @@ -1,4 +1,4 @@ -#include "../../../shared_cpp/OrthographicRenderer.h" +#include "../../../shared_cpp/Renderer2d.h" #include "../../../shared_cpp/types.h" #include "../../../shared_cpp/WebglContext.h" #include "../../../shared_cpp/mathlib.h" @@ -60,13 +60,13 @@ struct IntersectionResult { }; struct Rectangle { - OrthographicShape shape; + Mesh2d shape; Rigidbody body; Vector4 color; float32 width = 0.f; float32 height = 0.f; - void load(OrthographicRenderer* renderer, Vector4 inColor, float32 inWidth, float32 inHeight) { + void load(Renderer2d* renderer, Vector4 inColor, float32 inWidth, float32 inHeight) { color = inColor.toNormalizedColor(); width = inWidth;; height = inHeight; @@ -74,7 +74,7 @@ struct Rectangle { float32 halfWidth = width / 2.f; float32 halfHeight = height / 2.f; - OrthographicVertex vertices[6]; + Vertex2d vertices[6]; vertices[0].position = Vector2 { -halfWidth, -halfHeight }; vertices[1].position = Vector2 { -halfWidth, halfHeight }; vertices[2].position = Vector2 { halfWidth, halfHeight }; @@ -96,7 +96,7 @@ struct Rectangle { shape.model = Mat4x4().translateByVec2(body.position).rotate2D(body.rotation); } - void render(OrthographicRenderer* renderer) { + void render(Renderer2d* renderer) { shape.render(renderer); } @@ -106,15 +106,15 @@ struct Rectangle { }; struct LineSegment { - OrthographicShape shape; + Mesh2d shape; Rigidbody body; Vector2 start; Vector2 end; float32 length; Vector2 normal; - OrthographicVertex vertices[2]; + Vertex2d vertices[2]; - void load(OrthographicRenderer* renderer, Vector4 color, Vector2 inStart, Vector2 inEnd) { + void load(Renderer2d* renderer, Vector4 color, Vector2 inStart, Vector2 inEnd) { start = inStart; end = inEnd; length = (start - end).length(); @@ -133,7 +133,7 @@ struct LineSegment { body.momentOfInertia = body.mass * (length / 2.f); } - void render(OrthographicRenderer* renderer) { + void render(Renderer2d* renderer) { shape.render(renderer, GL_LINES); } @@ -161,7 +161,7 @@ void update(float32 time, void* userData); void unload(); WebglContext context; -OrthographicRenderer renderer; +Renderer2d renderer; MainLoop mainLoop; LineSegment segmentList[4]; Rectangle rectangle; -- cgit v1.2.1