Skip to content

Commit

Permalink
Remove unneccessary functions and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshball committed Feb 11, 2024
1 parent eaf5a3e commit e52406a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 49 deletions.
18 changes: 9 additions & 9 deletions Source/TestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FrustumTest : public juce::UnitTest {
Vec3(0.5, 0.5, 0), Vec3(0.5, 0.5, 0),
};

testFrustumClippedEqualsExpected(vecs, camera, frustum, 6);
testFrustumClippedEqualsExpected(vecs, camera, 6);

beginTest("Focal Plane Frustum Out-Of-Bounds");

Expand All @@ -47,11 +47,11 @@ class FrustumTest : public juce::UnitTest {
Vec3(-10, 10, 0), Vec3(-1, 1, 0),
};

testFrustumClippedEqualsExpected(vecs2, camera, frustum, 12);
testFrustumClippedEqualsExpected(vecs2, camera, 12);

beginTest("Behind Camera Out-Of-Bounds");

double minZWorldCoords = -focalLength + frustum.nearDistance;
double minZWorldCoords = -focalLength + camera.getFrustum().nearDistance;

Vec3 vecs3[] = {
Vec3(0, 0, -focalLength), Vec3(0, 0, minZWorldCoords),
Expand All @@ -62,7 +62,7 @@ class FrustumTest : public juce::UnitTest {
Vec3(-10, 10, -100), Vec3(-0.1, 0.1, minZWorldCoords),
};

testFrustumClippedEqualsExpected(vecs3, camera, frustum, 6);
testFrustumClippedEqualsExpected(vecs3, camera, 6);

beginTest("3D Point Out-Of-Bounds");

Expand All @@ -74,7 +74,7 @@ class FrustumTest : public juce::UnitTest {
Vec3(0.5, 0.5, minZWorldCoords),
};

testFrustumClipOccurs(vecs4, camera, frustum, 5);
testFrustumClipOccurs(vecs4, camera, 5);
}

Vec3 project(Vec3& p, double focalLength) {
Expand All @@ -93,21 +93,21 @@ class FrustumTest : public juce::UnitTest {
return "Expected: " + vec3ToString(expected) + ", Actual: " + vec3ToString(actual);
}

void testFrustumClippedEqualsExpected(Vec3 vecs[], Camera& camera, Frustum& frustum, int length) {
void testFrustumClippedEqualsExpected(Vec3 vecs[], Camera& camera, int length) {
for (int i = 0; i < length; i++) {
Vec3 p = vecs[2 * i];
p = camera.toCameraSpace(p);
frustum.clipToFrustum(p);
camera.getFrustum().clipToFrustum(p);
p = camera.toWorldSpace(p);
expect(mathter::AlmostEqual(p, vecs[2 * i + 1]), errorMessage(p, vecs[2 * i + 1]));
}
}

void testFrustumClipOccurs(Vec3 vecs[], Camera& camera, Frustum& frustum, int length) {
void testFrustumClipOccurs(Vec3 vecs[], Camera& camera, int length) {
for (int i = 0; i < length; i++) {
Vec3 p = vecs[i];
p = camera.toCameraSpace(p);
frustum.clipToFrustum(p);
camera.getFrustum().clipToFrustum(p);
p = camera.toWorldSpace(p);
expect(!mathter::AlmostEqual(p, vecs[i]), errorMessage(p, vecs[i]));
}
Expand Down
18 changes: 0 additions & 18 deletions Source/obj/Camera.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "Camera.h"
#include "../shape/Line.h"
#include <numbers>

Camera::Camera() : frustum(1, 1, 0.1, 100) {
viewMatrix = mathter::Identity();
Expand All @@ -12,22 +10,6 @@ void Camera::setPosition(Vec3& position) {
viewMatrix(2, 3) = -position.z;
}

void Camera::findZPos(std::vector<float>& vertices) {
float x = 0.0;
float y = 0.0;
float z = -1.0;

//for (int i = 0; i < MAX_NUM_STEPS; i++) {
// z += CAMERA_MOVE_INCREMENT;
// for (size_t j = 0; j < std::min(VERTEX_SAMPLES, (int) vertices.size()); j++) {
// Vec3 vertex{vertices[j * 3], vertices[j * 3 + 1], vertices[j * 3 + 2]};
// // check whether it's in the camera frustum
// }
//}

viewMatrix = mathter::Translation(x, y, z);
}

Vec3 Camera::toCameraSpace(Vec3& point) {
return viewMatrix * point;
}
Expand Down
5 changes: 1 addition & 4 deletions Source/obj/Camera.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once
#include <vector>
#include <memory>
#include <JuceHeader.h>

#include "../mathter/Matrix.hpp"
#include "Frustum.h"

Expand All @@ -12,7 +10,6 @@ class Camera {
Camera();

void setPosition(Vec3& position);
void findZPos(std::vector<float>& vertices);
Vec3 toCameraSpace(Vec3& point);
Vec3 toWorldSpace(Vec3& point);
void setFocalLength(double focalLength);
Expand Down
18 changes: 0 additions & 18 deletions osci-render-test.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,6 @@
<FILE id="V3Q6n2" name="Frustum.cpp" compile="1" resource="0" file="Source/obj/Frustum.cpp"/>
<FILE id="m9wauB" name="Frustum.h" compile="0" resource="0" file="Source/obj/Frustum.h"/>
</GROUP>
<GROUP id="{2FFB1E70-C58F-FC28-4D59-AF861B331B54}" name="shape">
<FILE id="J5Nnzj" name="CircleArc.cpp" compile="1" resource="0" file="Source/shape/CircleArc.cpp"/>
<FILE id="oNmrlE" name="CircleArc.h" compile="0" resource="0" file="Source/shape/CircleArc.h"/>
<FILE id="u8e3mP" name="CubicBezierCurve.cpp" compile="1" resource="0"
file="Source/shape/CubicBezierCurve.cpp"/>
<FILE id="aJoApp" name="CubicBezierCurve.h" compile="0" resource="0"
file="Source/shape/CubicBezierCurve.h"/>
<FILE id="bbtKzH" name="Line.cpp" compile="1" resource="0" file="Source/shape/Line.cpp"/>
<FILE id="Q4bPoy" name="Line.h" compile="0" resource="0" file="Source/shape/Line.h"/>
<FILE id="tZJGSA" name="Point.cpp" compile="1" resource="0" file="Source/shape/Point.cpp"/>
<FILE id="LaJfn7" name="Point.h" compile="0" resource="0" file="Source/shape/Point.h"/>
<FILE id="sRz2K2" name="QuadraticBezierCurve.cpp" compile="1" resource="0"
file="Source/shape/QuadraticBezierCurve.cpp"/>
<FILE id="DB78dq" name="QuadraticBezierCurve.h" compile="0" resource="0"
file="Source/shape/QuadraticBezierCurve.h"/>
<FILE id="NrZ4bk" name="Shape.cpp" compile="1" resource="0" file="Source/shape/Shape.cpp"/>
<FILE id="QmxyPg" name="Shape.h" compile="0" resource="0" file="Source/shape/Shape.h"/>
</GROUP>
<FILE id="bQ1rDR" name="TestMain.cpp" compile="1" resource="0" file="Source/TestMain.cpp"/>
</GROUP>
</MAINGROUP>
Expand Down

0 comments on commit e52406a

Please sign in to comment.