Skip to content

Commit

Permalink
Fixed code to avoid arbitrary negative signs. Mode7 now uses an ACW a…
Browse files Browse the repository at this point in the history
…ngle.
  • Loading branch information
ThePythonator committed Aug 27, 2022
1 parent 3b74f0f commit 42e471b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions 32blit/graphics/mode7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace blit {
Vec2 v(w - pos);
v.normalize();
Vec2 f(0, -1);
f *= Mat3::rotation(-angle);
f *= Mat3::rotation(angle);

float wd = (w - pos).length();
float dot = f.dot(v);
Expand Down Expand Up @@ -72,7 +72,7 @@ namespace blit {
*/
Vec2 screen_to_world(Vec2 s, float fov, float angle, Vec2 pos, float near, float far, Rect viewport) {
Vec2 forward(0, -1);
forward *= Mat3::rotation(-angle);
forward *= Mat3::rotation(angle);

Vec2 left = forward;
left *= Mat3::rotation(-(fov / 2.0f));
Expand Down
6 changes: 3 additions & 3 deletions examples/flight/flight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ std::vector<DrawObject> drawObjects (std::vector<object> objects) {
Vec2 vo = (o.pos - pos);
vo.normalize();
Vec2 forward(0, -1);
forward *= Mat3::rotation(-angle);
forward *= Mat3::rotation(angle);

// TODO: provide a "is_point_in_frustrum" check
if(forward.dot(vo) > 0) { // check if object is in front of us
Expand Down Expand Up @@ -223,7 +223,7 @@ void render(uint32_t time_ms) {
screen.pixel(mtpos);

Vec2 forward(0, -10);
forward *= Mat3::rotation(-angle);
forward *= Mat3::rotation(angle);
screen.pen = Pen(255, 255, 255, 100);
screen.line(mmpos, mmpos + forward);

Expand Down Expand Up @@ -282,7 +282,7 @@ void update(uint32_t time) {
}

angle += deg2rad(angle_delta);
Mat3 r = Mat3::rotation(-angle);
Mat3 r = Mat3::rotation(angle);
pos = pos - (vel * r);

if (pressed(Button::A) || (joystick.y > 0.0f)) {
Expand Down

0 comments on commit 42e471b

Please sign in to comment.