summaryrefslogtreecommitdiff
path: root/2d/_collisions/rectangle_line/main.cpp
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-10-31 13:54:11 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-10-31 13:54:11 -0400
commit5c613a10364f30bd6add25f7950433f0c482c3ca (patch)
treeaf8f6e481b6400329eca12bd8cdb35e0237d63af /2d/_collisions/rectangle_line/main.cpp
parenta214b4f8977a4b115710b5c9d152b392ac8e24f7 (diff)
(mkosarek) Working undamped spring motion
Diffstat (limited to '2d/_collisions/rectangle_line/main.cpp')
-rw-r--r--2d/_collisions/rectangle_line/main.cpp20
1 files changed, 10 insertions, 10 deletions
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;