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/pill_line/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to '2d/_collisions/pill_line') diff --git a/2d/_collisions/pill_line/main.cpp b/2d/_collisions/pill_line/main.cpp index b9315a8..65687ba 100644 --- a/2d/_collisions/pill_line/main.cpp +++ b/2d/_collisions/pill_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" @@ -54,7 +54,7 @@ struct Rigidbody { }; struct Pill { - OrthographicShape shape; + Mesh2d shape; Rigidbody body; float32 a = 0; float32 b = 0; @@ -68,7 +68,7 @@ struct Pill { return retval; } - void load(OrthographicRenderer* renderer, float32 numSegments, float32 width, float32 height) { + void load(Renderer2d* renderer, float32 numSegments, float32 width, float32 height) { // Note that a so-called "pill" is simply an ellipse. // Equation of an ellipse is: // @@ -80,7 +80,7 @@ struct Pill { // float32 angleIncrements = (2.f * PI) / numSegments; uint32 numVertices = static_cast(numSegments * 3.f); - OrthographicVertex* vertices = new OrthographicVertex[numVertices]; + Vertex2d* vertices = new Vertex2d[numVertices]; a = width / 2.f; b = height / 2.f; @@ -119,7 +119,7 @@ struct Pill { shape.model = Mat4x4().translateByVec2(body.position).rotate2D(body.rotation); } - void render(OrthographicRenderer* renderer) { + void render(Renderer2d* renderer) { shape.render(renderer); } @@ -129,15 +129,15 @@ struct Pill { }; 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(); @@ -156,7 +156,7 @@ struct LineSegment { body.momentOfInertia = body.mass * (length / 2.f); } - void render(OrthographicRenderer* renderer) { + void render(Renderer2d* renderer) { shape.render(renderer, GL_LINES); } @@ -195,7 +195,7 @@ void resolveCollision(Rigidbody* first, Rigidbody* second, IntersectionResult* i // Global Variables WebglContext context; -OrthographicRenderer renderer; +Renderer2d renderer; Pill pill; MainLoop mainLoop; LineSegment segmentList[4]; -- cgit v1.2.1