Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed definition inconsistencies and rotation matrix generation. Technically a breaking change! #779

Merged
merged 3 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 32blit/graphics/mode7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ namespace blit {
forward *= Mat3::rotation(angle);

Vec2 left = forward;
left *= Mat3::rotation((fov / 2.0f));
left *= Mat3::rotation(-(fov / 2.0f));

Vec2 right = forward;
right *= Mat3::rotation(-(fov / 2.0f));
right *= Mat3::rotation((fov / 2.0f));

float distance = ((far - near) / float(s.y - viewport.y)) + near;

Expand Down
10 changes: 5 additions & 5 deletions 32blit/types/mat3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace blit {

Mat3::Mat3() {
v00 = 0.0f; v10 = 0.0f; v20 = 0.0f;
v01 = 0.0f; v11 = 0.0f; v21 = 0.0f;
v02 = 0.0f; v12 = 0.0f; v22 = 0.0f;
v00 = 0.0f; v01 = 0.0f; v02 = 0.0f;
v10 = 0.0f; v11 = 0.0f; v12 = 0.0f;
v20 = 0.0f; v21 = 0.0f; v22 = 0.0f;
}

Mat3 Mat3::identity() {
Expand All @@ -26,8 +26,8 @@ namespace blit {
Mat3 r = Mat3::identity();

r.v00 = c;
r.v01 = s;
r.v10 = -s;
r.v01 = -s;
r.v10 = s;
r.v11 = c;

return r;
Expand Down
6 changes: 3 additions & 3 deletions 32blit/types/mat3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace blit {
struct Vec2;

struct Mat3 {
float v00, v10, v20;
float v01, v11, v21;
float v02, v12, v22;
float v00, v01, v02;
float v10, v11, v12;
float v20, v21, v22;

Mat3();

Expand Down
8 changes: 4 additions & 4 deletions 32blit/types/mat4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
namespace blit {

Mat4::Mat4() {
v00 = 0.0f; v10 = 0.0f; v20 = 0.0f; v30 = 0.0f;
v01 = 0.0f; v11 = 0.0f; v21 = 0.0f; v31 = 0.0f;
v02 = 0.0f; v12 = 0.0f; v22 = 0.0f; v32 = 0.0f;
v03 = 0.0f; v13 = 0.0f; v23 = 0.0f; v33 = 0.0f;
v00 = 0.0f; v01 = 0.0f; v02 = 0.0f; v03 = 0.0f;
v10 = 0.0f; v11 = 0.0f; v12 = 0.0f; v13 = 0.0f;
v20 = 0.0f; v21 = 0.0f; v22 = 0.0f; v23 = 0.0f;
v30 = 0.0f; v31 = 0.0f; v32 = 0.0f; v33 = 0.0f;
}

Mat4 Mat4::identity() {
Expand Down
8 changes: 4 additions & 4 deletions 32blit/types/mat4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace blit {
struct Vec3;

struct Mat4 {
float v00, v10, v20, v30;
float v01, v11, v21, v31;
float v02, v12, v22, v32;
float v03, v13, v23, v33;
float v00, v01, v02, v03;
float v10, v11, v12, v13;
float v20, v21, v22, v23;
float v30, v31, v32, v33;

Mat4();

Expand Down
6 changes: 3 additions & 3 deletions examples/flight/flight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ void update(uint32_t time) {
float target_speed;
float lerp_value = 0.002f;

if (pressed(Button::DPAD_LEFT)) { angle_delta += 0.05f; }
if (pressed(Button::DPAD_RIGHT)) { angle_delta -= 0.05f; }
if (pressed(Button::DPAD_LEFT)) { angle_delta -= 0.05f; }
if (pressed(Button::DPAD_RIGHT)) { angle_delta += 0.05f; }

angle_delta -= joystick.x / 80.0f ;
angle_delta += joystick.x / 80.0f ;

if (pressed(Button::Y)) {
// boost button
Expand Down
2 changes: 1 addition & 1 deletion examples/geometry/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ std::vector<Vec2> random_convex_polygon(Vec2 origin, float radius) {
void rotate_polygon(std::vector<Vec2> &points, float angle, Vec2 origin) {
Mat3 t = Mat3::identity();
t *= Mat3::translation(origin);
t *= Mat3::rotation(angle);
t *= Mat3::rotation(-angle);
t *= Mat3::translation(-origin);
for (auto &p : points) {
p *= t;
Expand Down