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

types for hyperbolic space #420

Merged
merged 32 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1376848
added MVector in math.rs generally for points and directions in
haiitsstrawberry Jul 9, 2024
eba688b
Merge branch 'master' of https://github.com/Ralith/hypermine
haiitsstrawberry Jul 13, 2024
8f3c12d
reconcile merge
haiitsstrawberry Jul 16, 2024
5e4c4dd
cleanup
haiitsstrawberry Jul 21, 2024
f4a88bc
added back lorentz_normalize() fixing the test
haiitsstrawberry Jul 21, 2024
4d4b090
decreased verbosity of some into() calls by using less verbose variat…
haiitsstrawberry Jul 23, 2024
9c0680e
removed obsolete commented out code
haiitsstrawberry Jul 24, 2024
f22b047
readd accidentally removed comment
haiitsstrawberry Jul 24, 2024
f322538
changed the definition of MVector::origin() for brevity
haiitsstrawberry Jul 24, 2024
679f3be
used dual_to_node_f64() and BOUNDING_SPHERE_RADIUS_F64 for better pre…
haiitsstrawberry Jul 24, 2024
7d048e6
formatting
haiitsstrawberry Jul 24, 2024
2d8b016
remove redundant <_>
haiitsstrawberry Jul 24, 2024
1834ae1
made wrapped definitions of used MulAssign and AddAssign more concise
haiitsstrawberry Jul 24, 2024
dc29b03
removed unused imports
haiitsstrawberry Jul 24, 2024
b9ad604
concision
haiitsstrawberry Jul 24, 2024
43f7603
check pass stuff(?)
haiitsstrawberry Jul 24, 2024
4c0d61c
simplification by deref
haiitsstrawberry Jul 27, 2024
d99b08e
simplify multiplication step
haiitsstrawberry Jul 27, 2024
9bb5b43
add inline to function
haiitsstrawberry Jul 27, 2024
1917462
group test related code together
haiitsstrawberry Jul 27, 2024
1d3b6d2
removed verbose paths having math::
haiitsstrawberry Jul 27, 2024
3de15b6
Update common/src/character_controller/collision.rs
strawberrycinnabar Jul 27, 2024
886b335
Update common/src/collision_math.rs
strawberrycinnabar Jul 27, 2024
2667a8b
Update common/src/collision_math.rs
strawberrycinnabar Jul 27, 2024
becd604
Update common/src/collision_math.rs
strawberrycinnabar Jul 27, 2024
061428c
Update common/src/plane.rs
strawberrycinnabar Jul 27, 2024
926db6e
Update common/src/plane.rs
strawberrycinnabar Jul 27, 2024
cea4366
Update common/src/traversal.rs
strawberrycinnabar Jul 27, 2024
7dbf512
Update common/src/traversal.rs
strawberrycinnabar Jul 27, 2024
4d080da
guh
haiitsstrawberry Jul 27, 2024
fe19fec
guh
haiitsstrawberry Jul 27, 2024
7012673
ok
haiitsstrawberry Jul 28, 2024
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
6 changes: 3 additions & 3 deletions client/src/graphics/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl Draw {
let draw_started = Instant::now();
let view = sim.as_ref().map_or_else(Position::origin, |sim| sim.view());
let projection = frustum.projection(1.0e-4);
let view_projection = projection.matrix() * <math::MIsometry<_> as Into<na::Matrix4<_>>>::into(view.local.mtranspose());
let view_projection = projection.matrix() * na::Matrix4::<_>::from(view.local.mtranspose());
Ralith marked this conversation as resolved.
Show resolved Hide resolved
self.loader.drive();

let device = &*self.gfx.device;
Expand Down Expand Up @@ -482,8 +482,8 @@ impl Draw {
.expect("positionless entity in graph");
if let Some(character_model) = self.loader.get(self.character_model) {
if let Ok(ch) = sim.world.get::<&Character>(entity) {
let transform = <math::MIsometry<_> as Into<na::Matrix4<_>>>::into(transform)
* <math::MIsometry<_> as Into<na::Matrix4<_>>>::into(pos.local)
let transform = na::Matrix4::<_>::from(transform)
* na::Matrix4::<_>::from(pos.local)
* na::Matrix4::new_scaling(sim.cfg().meters_to_absolute)
* ch.state.orientation.to_homogeneous();
for mesh in &character_model.0 {
Expand Down
2 changes: 1 addition & 1 deletion client/src/graphics/voxels/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl Voxels {
frame.drawn.push(slot);
// Transfer transform
frame.surface.transforms_mut()[slot.0 as usize] =
<math::MIsometry<_> as Into<na::Matrix4<_>>>::into(*node_transform) * vertex.chunk_to_node();
na::Matrix4::<_>::from(*node_transform) * vertex.chunk_to_node();
}
if let (None, &VoxelData::Dense(ref data)) = (&surface, voxels) {
// Extract a surface so it can be drawn in future frames
Expand Down
10 changes: 5 additions & 5 deletions common/src/dodeca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Side {
#[inline]
pub fn is_facing(self, p: &MVector<f32>) -> bool {
let r = na::convert::<_, na::RowVector4<f32>>(self.reflection().row(3).clone_owned());
(r * <MVector<f32> as Into<na::Vector4<f32>>>::into(*p)).x < p.w
(r * na::Vector4::<_>::from(*p)).x < p.w
}
}

Expand Down Expand Up @@ -178,22 +178,22 @@ impl Vertex {

/// Transform from euclidean chunk coordinates to hyperbolic node space
pub fn chunk_to_node(self) -> na::Matrix4<f32> {
<MIsometry<f32> as Into<na::Matrix4<f32>>>::into(*self.dual_to_node()) * na::Matrix4::new_scaling(1.0 / Self::dual_to_chunk_factor())
na::Matrix4::<_>::from(*self.dual_to_node()) * na::Matrix4::new_scaling(1.0 / Self::dual_to_chunk_factor())
}

/// Transform from euclidean chunk coordinates to hyperbolic node space
pub fn chunk_to_node_f64(self) -> na::Matrix4<f64> {
<MIsometry<f64> as Into<na::Matrix4<f64>>>::into(*self.dual_to_node_f64()) * na::Matrix4::new_scaling(1.0 / Self::dual_to_chunk_factor_f64())
na::Matrix4::<_>::from(*self.dual_to_node_f64()) * na::Matrix4::new_scaling(1.0 / Self::dual_to_chunk_factor_f64())
}

/// Transform from hyperbolic node space to euclidean chunk coordinates
pub fn node_to_chunk(self) -> na::Matrix4<f32> {
na::Matrix4::new_scaling(Self::dual_to_chunk_factor()) * <MIsometry<f32> as Into<na::Matrix4<f32>>>::into(*self.node_to_dual())
na::Matrix4::new_scaling(Self::dual_to_chunk_factor()) * na::Matrix4::<_>::from(*self.node_to_dual())
}

/// Transform from hyperbolic node space to euclidean chunk coordinates
pub fn node_to_chunk_f64(self) -> na::Matrix4<f64> {
na::Matrix4::new_scaling(Self::dual_to_chunk_factor_f64()) * <MIsometry<f64> as Into<na::Matrix4<f64>>>::into(*self.node_to_dual_f64())
na::Matrix4::new_scaling(Self::dual_to_chunk_factor_f64()) * na::Matrix4::<_>::from(*self.node_to_dual_f64())
}

/// Transform from cube-centric coordinates to dodeca-centric coordinates
Expand Down
12 changes: 6 additions & 6 deletions common/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ impl<N: Scalar> Deref for MIsometry<N> {
}
}

impl<N: Scalar> Into<na::Matrix4<N>> for MIsometry<N>
impl<N: Scalar> From<MIsometry<N>> for na::Matrix4<N>
{
fn into(self) -> na::Matrix4<N>
fn from(value: MIsometry<N>) -> na::Matrix4<N>
{
self.0
value.0
}
}

impl<N: Scalar> Into<na::Vector4<N>> for MVector<N>
impl<N: Scalar> From<MVector<N>> for na::Vector4<N>
{
fn into(self) -> na::Vector4<N>
fn from(value: MVector<N>) -> na::Vector4<N>
{
self.0
value.0
}
}

Expand Down