Skip to content

Commit 1915905

Browse files
authored
fix: make threepp compatiable with windows.h (#293)
1 parent e1ba8d4 commit 1915905

24 files changed

+48
-45
lines changed

include/threepp/cameras/Camera.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ namespace threepp {
2525
public:
2626
float zoom = 1;
2727

28-
float near{};
29-
float far{};
28+
float nearPlane {};
29+
float farPlane {};
3030

3131
std::optional<CameraView> view;
3232

@@ -39,7 +39,7 @@ namespace threepp {
3939
Matrix4 projectionMatrixInverse;
4040

4141
Camera() = default;
42-
Camera(float near, float far);
42+
Camera(float _near, float _far);
4343

4444
// Copies the world space direction in which the camera is looking into target.
4545
// (Note: A camera looks down its local, negative z-axis).

include/threepp/cameras/OrthographicCamera.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace threepp {
2525

2626
explicit OrthographicCamera(float left = -1, float right = 1,
2727
float top = 1, float bottom = -1,
28-
float near = 0.1f, float far = 2000);
28+
float nearPlane = 0.1f, float farPlane = 2000);
2929

3030
// Sets an offset in a larger viewing frustum.
3131
// This is useful for multi-window or multi-monitor/multi-machine setups.

include/threepp/cameras/PerspectiveCamera.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace threepp {
2828
float filmOffset = 0;// horizontal film offset (same unit as gauge)
2929

3030
explicit PerspectiveCamera(float fov = 60, float aspect = 1,
31-
float near = 0.1, float far = 2000);
31+
float nearPlane = 0.1, float farPlane = 2000);
3232

3333
/**
3434
* Sets the FOV by focal length in respect to the current .filmGauge.

include/threepp/core/Raycaster.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace threepp {
3434
class Raycaster {
3535

3636
public:
37-
float near;
38-
float far;
37+
float nearPlane;
38+
float farPlane;
3939

4040
Ray ray;
4141
Camera* camera;
@@ -47,8 +47,7 @@ namespace threepp {
4747
};
4848
Params params;
4949

50-
explicit Raycaster(const Vector3& origin = Vector3(), const Vector3& direction = Vector3(), float near = 0, float far = std::numeric_limits<float>::infinity())
51-
: near(near), far(far), ray(origin, direction), camera(nullptr) {}
50+
explicit Raycaster(const Vector3& origin = Vector3(), const Vector3& direction = Vector3(), float _near = 0, float _far = std::numeric_limits<float>::infinity());
5251

5352
void set(const Vector3& origin, const Vector3& direction);
5453

include/threepp/input/KeyListener.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ namespace threepp {
119119
TAB,
120120
BACKSPACE,
121121
INSERT,
122-
DELETE,
122+
DEL,
123123
RIGHT,
124124
LEFT,
125125
DOWN,

include/threepp/scenes/Fog.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace threepp {
1111

1212
public:
1313
Color color;
14-
float near;
15-
float far;
14+
float nearPlane;
15+
float farPlane;
1616

17-
explicit Fog(const Color& color, float near = 1, float far = 1000);
17+
explicit Fog(const Color& color, float _near = 1, float _far = 1000);
1818

1919
bool operator==(const Fog& f) const;
2020
};

src/threepp/cameras/Camera.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
using namespace threepp;
55

6-
7-
Camera::Camera(float near, float far)
8-
: near(near), far(far) {}
6+
Camera::Camera(float _near, float _far)
7+
: nearPlane(_near), farPlane(_far) {}
98

109
void Camera::getWorldDirection(Vector3& target) {
1110

src/threepp/cameras/OrthographicCamera.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void OrthographicCamera::updateProjectionMatrix() {
6767
bottom = top - scaleH * static_cast<float>(this->view->height);
6868
}
6969

70-
this->projectionMatrix.makeOrthographic(left, right, top, bottom, this->near, this->far);
70+
this->projectionMatrix.makeOrthographic(left, right, top, bottom, this->nearPlane, this->farPlane);
7171

7272
this->projectionMatrixInverse.copy(this->projectionMatrix).invert();
7373
}

src/threepp/cameras/PerspectiveCamera.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void PerspectiveCamera::clearViewOffset() {
8686

8787
void PerspectiveCamera::updateProjectionMatrix() {
8888

89-
float top = near * std::tan(math::DEG2RAD * 0.5f * this->fov) / this->zoom;
89+
float top = nearPlane * std::tan(math::DEG2RAD * 0.5f * this->fov) / this->zoom;
9090
float height = 2.f * top;
9191
float width = this->aspect * height;
9292
float left = -0.5f * width;
@@ -104,10 +104,10 @@ void PerspectiveCamera::updateProjectionMatrix() {
104104

105105
const auto skew = this->filmOffset;
106106
if (skew != 0) {
107-
left += (near * skew / this->getFilmWidth());
107+
left += (nearPlane * skew / this->getFilmWidth());
108108
}
109109

110-
this->projectionMatrix.makePerspective(left, (left + width), top, (top - height), near, far);
110+
this->projectionMatrix.makePerspective(left, (left + width), top, (top - height), nearPlane, farPlane);
111111

112112
this->projectionMatrixInverse.copy(this->projectionMatrix).invert();
113113
}

src/threepp/canvas/Canvas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ namespace {
128128
case GLFW_KEY_TAB: return Key::TAB;
129129
case GLFW_KEY_BACKSPACE: return Key::BACKSPACE;
130130
case GLFW_KEY_INSERT: return Key::INSERT;
131-
case GLFW_KEY_DELETE: return Key::DELETE;
131+
case GLFW_KEY_DELETE: return Key::DEL;
132132

133133
default: return Key::UNKNOWN;
134134

0 commit comments

Comments
 (0)