Skip to content

Commit e163f0f

Browse files
committed
Fix naming in Basis::to_euler_inner
Make `Projection` use `f64`s Make `Basis2D` crate-public instead of public
1 parent 1114ae8 commit e163f0f

File tree

4 files changed

+185
-236
lines changed

4 files changed

+185
-236
lines changed

godot-core/src/builtin/basis.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,17 @@ impl Basis {
217217
// return the simplest form (human friendlier in editor and scripts)
218218
Vec3::new(0.0, f32::atan2(self.rows[0].z, self.rows[0].x), 0.0)
219219
}
220-
_ => -Self::to_euler_inner(self.rows[0].z, row_a.yx(), col_c.yz(), col_b.zy())
220+
_ => -Self::to_euler_inner(self.rows[0].z, col_c.yz(), row_a.yx(), col_b.zy())
221221
.yxz(),
222222
}
223223
}
224224
EulerOrder::XZY => {
225-
Self::to_euler_inner(self.rows[0].y, row_a.zx(), col_b.zy(), col_c.yz()).yzx()
225+
Self::to_euler_inner(self.rows[0].y, col_b.zy(), row_a.zx(), col_c.yz()).yzx()
226226
}
227227
EulerOrder::YXZ => {
228228
let major = self.rows[1].z;
229-
let fst = row_b.xy();
230-
let snd = col_c.xz();
229+
let fst = col_c.xz();
230+
let snd = row_b.xy();
231231
let rest = row_a.yx();
232232
match Self::is_between_neg1_1(major) {
233233
// Is it a pure X rotation?
@@ -242,13 +242,13 @@ impl Basis {
242242
}
243243
}
244244
EulerOrder::YZX => {
245-
-Self::to_euler_inner(self.rows[1].x, col_a.zx(), row_b.zy(), row_c.yz()).yzx()
245+
-Self::to_euler_inner(self.rows[1].x, row_b.zy(), col_a.zx(), row_c.yz()).yzx()
246246
}
247247
EulerOrder::ZXY => {
248-
-Self::to_euler_inner(self.rows[2].y, col_b.xy(), row_c.xz(), row_a.zx())
248+
-Self::to_euler_inner(self.rows[2].y, row_c.xz(), col_b.xy(), row_a.zx())
249249
}
250250
EulerOrder::ZYX => {
251-
Self::to_euler_inner(self.rows[2].x, row_c.yz(), col_a.yx(), col_b.xy()).zxy()
251+
Self::to_euler_inner(self.rows[2].x, col_a.yx(), row_c.yz(), col_b.xy()).zxy()
252252
}
253253
}
254254
.to_front()
@@ -275,8 +275,8 @@ impl Basis {
275275
Ordering::Less => glam::Vec3::new(FRAC_PI_2, -f32::atan2(rest.x, rest.y), 0.0),
276276
Ordering::Equal => glam::Vec3::new(
277277
f32::asin(-major),
278-
f32::atan2(snd.x, snd.y),
279278
f32::atan2(fst.x, fst.y),
279+
f32::atan2(snd.x, snd.y),
280280
),
281281
// It's 1
282282
Ordering::Greater => glam::Vec3::new(-FRAC_PI_2, -f32::atan2(rest.x, rest.y), 0.0),

godot-core/src/builtin/projection.rs

Lines changed: 71 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,23 @@ impl Projection {
8383
#[allow(clippy::too_many_arguments)]
8484
pub fn create_for_hmd(
8585
eye: ProjectionEye,
86-
aspect: f32,
87-
intraocular_dist: f32,
88-
display_width: f32,
89-
display_to_lens: f32,
90-
oversample: f32,
91-
near: f32,
92-
far: f32,
86+
aspect: f64,
87+
intraocular_dist: f64,
88+
display_width: f64,
89+
display_to_lens: f64,
90+
oversample: f64,
91+
near: f64,
92+
far: f64,
9393
) -> Self {
9494
InnerProjection::create_for_hmd(
9595
eye as i64,
96-
aspect as f64,
97-
intraocular_dist as f64,
98-
display_width as f64,
99-
display_to_lens as f64,
100-
oversample as f64,
101-
near as f64,
102-
far as f64,
96+
aspect,
97+
intraocular_dist,
98+
display_width,
99+
display_to_lens,
100+
oversample,
101+
near,
102+
far,
103103
)
104104
}
105105

@@ -108,21 +108,14 @@ impl Projection {
108108
///
109109
/// _Godot equivalent: Projection.create_frustum()_
110110
pub fn create_frustum(
111-
left: f32,
112-
right: f32,
113-
bottom: f32,
114-
top: f32,
115-
near: f32,
116-
far: f32,
111+
left: f64,
112+
right: f64,
113+
bottom: f64,
114+
top: f64,
115+
near: f64,
116+
far: f64,
117117
) -> Self {
118-
InnerProjection::create_frustum(
119-
left as f64,
120-
right as f64,
121-
bottom as f64,
122-
top as f64,
123-
near as f64,
124-
far as f64,
125-
)
118+
InnerProjection::create_frustum(left, right, bottom, top, near, far)
126119
}
127120

128121
/// Creates a new Projection that projects positions in a frustum with the
@@ -133,43 +126,29 @@ impl Projection {
133126
///
134127
/// _Godot equivalent: Projection.create_frustum_aspect()_
135128
pub fn create_frustum_aspect(
136-
size: f32,
137-
aspect: f32,
129+
size: f64,
130+
aspect: f64,
138131
offset: Vector2,
139-
near: f32,
140-
far: f32,
132+
near: f64,
133+
far: f64,
141134
flip_fov: bool,
142135
) -> Self {
143-
InnerProjection::create_frustum_aspect(
144-
size as f64,
145-
aspect as f64,
146-
offset,
147-
near as f64,
148-
far as f64,
149-
flip_fov,
150-
)
136+
InnerProjection::create_frustum_aspect(size, aspect, offset, near, far, flip_fov)
151137
}
152138

153139
/// Creates a new Projection that projects positions using an orthogonal
154140
/// projection with the given clipping planes.
155141
///
156142
/// _Godot equivalent: Projection.create_orthogonal()_
157143
pub fn create_orthogonal(
158-
left: f32,
159-
right: f32,
160-
bottom: f32,
161-
top: f32,
162-
near: f32,
163-
far: f32,
144+
left: f64,
145+
right: f64,
146+
bottom: f64,
147+
top: f64,
148+
near: f64,
149+
far: f64,
164150
) -> Self {
165-
InnerProjection::create_orthogonal(
166-
left as f64,
167-
right as f64,
168-
bottom as f64,
169-
top as f64,
170-
near as f64,
171-
far as f64,
172-
)
151+
InnerProjection::create_orthogonal(left, right, bottom, top, near, far)
173152
}
174153

175154
/// Creates a new Projection that projects positions using an orthogonal
@@ -180,19 +159,13 @@ impl Projection {
180159
///
181160
/// _Godot equivalent: Projection.create_orthogonal_aspect()_
182161
pub fn create_orthogonal_aspect(
183-
size: f32,
184-
aspect: f32,
185-
near: f32,
186-
far: f32,
162+
size: f64,
163+
aspect: f64,
164+
near: f64,
165+
far: f64,
187166
flip_fov: bool,
188167
) -> Self {
189-
InnerProjection::create_orthogonal_aspect(
190-
size as f64,
191-
aspect as f64,
192-
near as f64,
193-
far as f64,
194-
flip_fov,
195-
)
168+
InnerProjection::create_orthogonal_aspect(size, aspect, near, far, flip_fov)
196169
}
197170

198171
/// Creates a new Projection that projects positions using a perspective
@@ -204,19 +177,13 @@ impl Projection {
204177
///
205178
/// _Godot equivalent: Projection.create_perspective()_
206179
pub fn create_perspective(
207-
fov_y: f32,
208-
aspect: f32,
209-
near: f32,
210-
far: f32,
180+
fov_y: f64,
181+
aspect: f64,
182+
near: f64,
183+
far: f64,
211184
flip_fov: bool,
212185
) -> Self {
213-
InnerProjection::create_perspective(
214-
fov_y as f64,
215-
aspect as f64,
216-
near as f64,
217-
far as f64,
218-
flip_fov,
219-
)
186+
InnerProjection::create_perspective(fov_y, aspect, near, far, flip_fov)
220187
}
221188

222189
/// Creates a new Projection that projects positions using a perspective
@@ -231,32 +198,32 @@ impl Projection {
231198
/// _Godot equivalent: Projection.create_perspective_hmd()_
232199
#[allow(clippy::too_many_arguments)]
233200
pub fn create_perspective_hmd(
234-
fov_y: f32,
235-
aspect: f32,
236-
near: f32,
237-
far: f32,
201+
fov_y: f64,
202+
aspect: f64,
203+
near: f64,
204+
far: f64,
238205
flip_fov: bool,
239206
eye: ProjectionEye,
240-
intraocular_dist: f32,
241-
convergence_dist: f32,
207+
intraocular_dist: f64,
208+
convergence_dist: f64,
242209
) -> Self {
243210
InnerProjection::create_perspective_hmd(
244-
fov_y as f64,
245-
aspect as f64,
246-
near as f64,
247-
far as f64,
211+
fov_y,
212+
aspect,
213+
near,
214+
far,
248215
flip_fov,
249216
eye as i64,
250-
intraocular_dist as f64,
251-
convergence_dist as f64,
217+
intraocular_dist,
218+
convergence_dist,
252219
)
253220
}
254221

255222
/// Return the determinant of the matrix.
256223
///
257224
/// _Godot equivalent: Projection.determinant()_
258-
pub fn determinant(&self) -> f32 {
259-
self.glam(|mat| mat.determinant())
225+
pub fn determinant(&self) -> f64 {
226+
self.glam(|mat| mat.determinant()) as f64
260227
}
261228

262229
/// Returns a copy of this Projection with the signs of the values of the Y
@@ -271,8 +238,8 @@ impl Projection {
271238
/// Returns the X:Y aspect ratio of this Projection's viewport.
272239
///
273240
/// _Godot equivalent: Projection.get_aspect()_
274-
pub fn aspect(&self) -> f32 {
275-
self.as_inner().get_aspect() as f32
241+
pub fn aspect(&self) -> f64 {
242+
self.as_inner().get_aspect()
276243
}
277244

278245
/// Returns the dimensions of the far clipping plane of the projection,
@@ -286,24 +253,24 @@ impl Projection {
286253
/// Returns the horizontal field of view of the projection (in degrees).
287254
///
288255
/// _Godot equivalent: Projection.get_fov()_
289-
pub fn fov(&self) -> f32 {
290-
self.as_inner().get_fov() as f32
256+
pub fn fov(&self) -> f64 {
257+
self.as_inner().get_fov()
291258
}
292259

293260
/// Returns the vertical field of view of a projection (in degrees) which
294261
/// has the given horizontal field of view (in degrees) and aspect ratio.
295262
///
296263
/// _Godot equivalent: Projection.get_fovy()_
297-
pub fn fovy_of(fov_x: f32, aspect: f32) -> f32 {
298-
InnerProjection::get_fovy(fov_x as f64, aspect as f64) as f32
264+
pub fn fovy_of(fov_x: f64, aspect: f64) -> f64 {
265+
InnerProjection::get_fovy(fov_x, aspect)
299266
}
300267

301268
/// Returns the factor by which the visible level of detail is scaled by
302269
/// this Projection.
303270
///
304271
/// _Godot equivalent: Projection.get_lod_multiplier()_
305-
pub fn lod_multiplier(&self) -> f32 {
306-
self.as_inner().get_lod_multiplier() as f32
272+
pub fn lod_multiplier(&self) -> f64 {
273+
self.as_inner().get_lod_multiplier()
307274
}
308275

309276
/// Returns the number of pixels with the given pixel width displayed per
@@ -334,16 +301,16 @@ impl Projection {
334301
/// clipped.
335302
///
336303
/// _Godot equivalent: Projection.get_z_far()_
337-
pub fn z_far(&self) -> f32 {
338-
self.as_inner().get_z_far() as f32
304+
pub fn z_far(&self) -> f64 {
305+
self.as_inner().get_z_far()
339306
}
340307

341308
/// Returns the distance for this Projection before which positions are
342309
/// clipped.
343310
///
344311
/// _Godot equivalent: Projection.get_z_near()_
345-
pub fn z_near(&self) -> f32 {
346-
self.as_inner().get_z_near() as f32
312+
pub fn z_near(&self) -> f64 {
313+
self.as_inner().get_z_near()
347314
}
348315

349316
/// Returns a Projection that performs the inverse of this Projection's
@@ -376,8 +343,8 @@ impl Projection {
376343
/// Note: The original Projection must be a perspective projection.
377344
///
378345
/// _Godot equivalent: Projection.perspective_znear_adjusted()_
379-
pub fn perspective_znear_adjusted(&self, new_znear: f32) -> Self {
380-
self.as_inner().perspective_znear_adjusted(new_znear as f64)
346+
pub fn perspective_znear_adjusted(&self, new_znear: f64) -> Self {
347+
self.as_inner().perspective_znear_adjusted(new_znear)
381348
}
382349

383350
#[doc(hidden)]

0 commit comments

Comments
 (0)