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

Update to glam 0.28 & replace macaw with fork re_math #6867

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 16 additions & 17 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2272,9 +2272,9 @@ dependencies = [

[[package]]
name = "glam"
version = "0.22.0"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12f597d56c1bd55a811a1be189459e8fad2bbc272616375602443bdfb37fa774"
checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94"
dependencies = [
"bytemuck",
"serde",
Expand Down Expand Up @@ -2958,17 +2958,6 @@ dependencies = [
"twox-hash",
]

[[package]]
name = "macaw"
version = "0.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92e4daa18df16fd196b955e4bb16574641f39141fb3ea81b493a84b9439d17e6"
dependencies = [
"glam",
"num-traits",
"serde",
]

[[package]]
name = "malloc_buf"
version = "0.0.6"
Expand Down Expand Up @@ -4635,6 +4624,16 @@ dependencies = [
"web-time",
]

[[package]]
name = "re_math"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "999db5029a2879efeddb538f2e486aabf33adf7a0b3708c6df5c1cae13b3af49"
dependencies = [
"glam",
"serde",
]

[[package]]
name = "re_memory"
version = "0.18.0-alpha.1+dev"
Expand Down Expand Up @@ -4709,7 +4708,6 @@ dependencies = [
"gltf",
"half 2.3.1",
"itertools 0.13.0",
"macaw",
"never",
"notify",
"ordered-float",
Expand All @@ -4720,6 +4718,7 @@ dependencies = [
"re_build_tools",
"re_error",
"re_log",
"re_math",
"re_tracing",
"serde",
"slotmap",
Expand Down Expand Up @@ -4747,10 +4746,10 @@ dependencies = [
"glam",
"image",
"itertools 0.13.0",
"macaw",
"pollster",
"rand",
"re_log",
"re_math",
"re_renderer",
"wasm-bindgen-futures",
"web-sys",
Expand Down Expand Up @@ -4920,7 +4919,6 @@ dependencies = [
"egui",
"glam",
"itertools 0.13.0",
"macaw",
"mimalloc",
"nohash-hasher",
"once_cell",
Expand All @@ -4931,6 +4929,7 @@ dependencies = [
"re_format",
"re_log",
"re_log_types",
"re_math",
"re_query",
"re_renderer",
"re_space_view",
Expand Down Expand Up @@ -5300,7 +5299,6 @@ dependencies = [
"indexmap 2.1.0",
"itertools 0.13.0",
"linked-hash-map",
"macaw",
"ndarray",
"nohash-hasher",
"once_cell",
Expand All @@ -5313,6 +5311,7 @@ dependencies = [
"re_format",
"re_log",
"re_log_types",
"re_math",
"re_query",
"re_renderer",
"re_smart_channel",
Expand Down
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ re_viewport = { path = "crates/viewer/re_viewport", version = "=0.18.0-alpha.1",
re_viewport_blueprint = { path = "crates/viewer/re_viewport_blueprint", version = "=0.18.0-alpha.1", default-features = false }
re_web_viewer_server = { path = "crates/viewer/re_web_viewer_server", version = "=0.18.0-alpha.1", default-features = false }

# Rerun crates in other repos:
ewebsock = "0.6.0"
re_math = "0.20.0"

# egui-crates:
ecolor = "0.28.1"
eframe = { version = "0.28.1", default-features = false, features = [
Expand Down Expand Up @@ -159,13 +163,12 @@ document-features = "0.2.8"
ehttp = "0.5.0"
enumset = "1.0.12"
env_logger = { version = "0.10", default-features = false }
ewebsock = "0.6.0"
fixed = { version = "1.17", default-features = false }
flatbuffers = "23.0"
futures-channel = "0.3"
futures-util = { version = "0.3", default-features = false }
getrandom = "0.2"
glam = "0.22" # glam update blocked by macaw
glam = "0.28"
glob = "0.3"
gltf = "1.1"
half = "2.3.1"
Expand All @@ -182,7 +185,6 @@ linked-hash-map = { version = "0.5", default-features = false }
log = "0.4"
log-once = "0.4"
lz4_flex = "0.11"
macaw = "0.18"
memory-stats = "1.1"
mimalloc = "=0.1.37" # TODO(#5875): `mimalloc` starts leaking OS pages starting with `0.1.38`.
mime = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ serde = ["dep:serde"]
[dependencies]
re_error.workspace = true
re_log.workspace = true
re_math.workspace = true
re_tracing.workspace = true

ahash.workspace = true
Expand All @@ -64,7 +65,6 @@ enumset.workspace = true
glam = { workspace = true, features = ["bytemuck"] }
half = { workspace = true, features = ["bytemuck"] }
itertools = { workspace = true }
macaw.workspace = true
never.workspace = true
ordered-float.workspace = true
parking_lot.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_renderer/src/importer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod gltf;
#[cfg(feature = "import-stl")]
pub mod stl;

use macaw::Vec3Ext as _;
use re_math::Vec3Ext as _;

use crate::renderer::MeshInstance;

Expand All @@ -21,8 +21,8 @@ pub fn to_uniform_scale(scale: glam::Vec3) -> f32 {
}
}

pub fn calculate_bounding_box(instances: &[MeshInstance]) -> macaw::BoundingBox {
macaw::BoundingBox::from_points(
pub fn calculate_bounding_box(instances: &[MeshInstance]) -> re_math::BoundingBox {
re_math::BoundingBox::from_points(
instances
.iter()
.filter_map(|mesh_instance| {
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer/src/line_drawable_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl<'a, 'ctx> LineBatchBuilder<'a, 'ctx> {
#[inline]
pub fn add_box_outline(
&mut self,
bbox: &macaw::BoundingBox,
bbox: &re_math::BoundingBox,
) -> Option<LineStripBuilder<'_, 'ctx>> {
if !bbox.is_something() || !bbox.is_finite() {
return None;
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_renderer/src/renderer/depth_cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub struct DepthCloud {

impl DepthCloud {
/// World-space bounding-box.
pub fn world_space_bbox(&self) -> macaw::BoundingBox {
pub fn world_space_bbox(&self) -> re_math::BoundingBox {
let max_depth = self.max_depth_in_world;
let w = self.depth_dimensions.x as f32;
let h = self.depth_dimensions.y as f32;
Expand All @@ -184,7 +184,7 @@ impl DepthCloud {
let focal_length = glam::vec2(intrinsics.col(0).x, intrinsics.col(1).y);
let offset = intrinsics.col(2).truncate();

let mut bbox = macaw::BoundingBox::nothing();
let mut bbox = re_math::BoundingBox::NOTHING;

for corner in corners {
let depth = corner.z;
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_renderer/src/renderer/mesh_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub struct MeshInstance {
pub mesh: Option<Arc<Mesh>>,

/// Where this instance is placed in world space and how its oriented & scaled.
pub world_from_mesh: macaw::Affine3A,
pub world_from_mesh: glam::Affine3A,

/// Per-instance (as opposed to per-material/mesh!) tint color that is added to the albedo texture.
/// Alpha channel is currently unused.
Expand All @@ -137,7 +137,7 @@ impl Default for MeshInstance {
Self {
gpu_mesh: GpuMeshHandle::Invalid,
mesh: None,
world_from_mesh: macaw::Affine3A::IDENTITY,
world_from_mesh: glam::Affine3A::IDENTITY,
additive_tint: Color32::TRANSPARENT,
outline_mask_ids: OutlineMaskPreference::NONE,
picking_layer_id: PickingLayerId::default(),
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer/src/view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub struct TargetConfiguration {

/// The viewport resolution in physical pixels.
pub resolution_in_pixel: [u32; 2],
pub view_from_world: macaw::IsoTransform,
pub view_from_world: re_math::IsoTransform,
pub projection_from_view: Projection,

/// Defines a viewport transformation from the projected space to the final image space.
Expand Down
4 changes: 2 additions & 2 deletions crates/viewer/re_renderer_examples/2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl framework::Example for Render2D {
TargetConfiguration {
name: "2D".into(),
resolution_in_pixel: splits[0].resolution_in_pixel,
view_from_world: macaw::IsoTransform::IDENTITY,
view_from_world: re_math::IsoTransform::IDENTITY,
projection_from_view: Projection::Orthographic {
camera_mode:
view_builder::OrthographicCameraMode::TopLeftCornerAndExtendZ,
Expand Down Expand Up @@ -336,7 +336,7 @@ impl framework::Example for Render2D {
view_builder::TargetConfiguration {
name: "3D".into(),
resolution_in_pixel: splits[1].resolution_in_pixel,
view_from_world: macaw::IsoTransform::look_at_rh(
view_from_world: re_math::IsoTransform::look_at_rh(
camera_position,
camera_rotation_center,
glam::Vec3::Y,
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer_examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ path = "picking.rs"

[dependencies]
re_log = { workspace = true, features = ["setup"] }
re_math.workspace = true
re_renderer = { workspace = true, features = ["import-obj", "import-gltf"] }

ahash.workspace = true
Expand All @@ -47,7 +48,6 @@ bytemuck.workspace = true
glam.workspace = true
image = { workspace = true, default-features = false, features = ["png"] }
itertools.workspace = true
macaw.workspace = true
pollster.workspace = true
rand = { workspace = true, features = ["std", "std_rng"] }
web-time.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer_examples/depth_cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::f32::consts::TAU;

use glam::Vec3;
use itertools::Itertools;
use macaw::IsoTransform;
use re_math::IsoTransform;
use re_renderer::{
renderer::{
ColormappedTexture, DepthCloud, DepthCloudDrawData, DepthClouds, DrawData,
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer_examples/depth_offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl framework::Example for Render2D {
view_builder::TargetConfiguration {
name: "3D".into(),
resolution_in_pixel: resolution,
view_from_world: macaw::IsoTransform::look_at_rh(
view_from_world: re_math::IsoTransform::look_at_rh(
glam::Vec3::Z * 2.0 * self.distance_scale,
glam::Vec3::ZERO,
glam::Vec3::Y,
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer_examples/multiview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::f32::consts::TAU;
use framework::Example;
use glam::Vec3;
use itertools::Itertools;
use macaw::IsoTransform;
use rand::Rng;
use re_math::IsoTransform;

use re_renderer::{
renderer::{
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer_examples/outlines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl framework::Example for Outlines {
TargetConfiguration {
name: "OutlinesDemo".into(),
resolution_in_pixel: resolution,
view_from_world: macaw::IsoTransform::look_at_rh(
view_from_world: re_math::IsoTransform::look_at_rh(
camera_position,
glam::Vec3::ZERO,
glam::Vec3::Y,
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_renderer_examples/picking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl framework::Example for Picking {
TargetConfiguration {
name: "OutlinesDemo".into(),
resolution_in_pixel: resolution,
view_from_world: macaw::IsoTransform::look_at_rh(
view_from_world: re_math::IsoTransform::look_at_rh(
camera_position,
glam::Vec3::ZERO,
glam::Vec3::Y,
Expand Down
2 changes: 1 addition & 1 deletion crates/viewer/re_space_view_spatial/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ re_error.workspace = true
re_format.workspace = true
re_log_types.workspace = true
re_log.workspace = true
re_math = { workspace = true, features = ["serde"] }
re_query.workspace = true
re_renderer = { workspace = true, features = [
"import-gltf",
Expand All @@ -46,7 +47,6 @@ bytemuck.workspace = true
egui = { workspace = true, features = ["serde"] }
glam.workspace = true
itertools.workspace = true
macaw = { workspace = true, features = ["with_serde"] }
nohash-hasher.workspace = true
once_cell.workspace = true
serde.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl ViewContextSystem for TransformContext {
}
Ok(None) => {}
Ok(Some(parent_from_child)) => {
reference_from_ancestor = reference_from_ancestor * parent_from_child.inverse();
reference_from_ancestor *= parent_from_child.inverse();
}
}

Expand Down
10 changes: 6 additions & 4 deletions crates/viewer/re_space_view_spatial/src/eye.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use egui::{lerp, NumExt as _, Rect};
use macaw::{vec3, IsoTransform, Mat4, Quat, Vec3};
use glam::{vec3, Mat4, Quat, Vec3};

use re_math::IsoTransform;

use re_space_view::controls::{
RuntimeModifiers, DRAG_PAN3D_BUTTON, ROLL_MOUSE, ROLL_MOUSE_ALT, ROLL_MOUSE_MODIFIER,
Expand Down Expand Up @@ -85,7 +87,7 @@ impl Eye {

/// Picking ray for a given pointer in the parent space
/// (i.e. prior to camera transform, "world" space)
pub fn picking_ray(&self, screen_rect: Rect, pointer: glam::Vec2) -> macaw::Ray3 {
pub fn picking_ray(&self, screen_rect: Rect, pointer: glam::Vec2) -> re_math::Ray3 {
if let Some(fov_y) = self.fov_y {
let (w, h) = (screen_rect.width(), screen_rect.height());
let aspect_ratio = w / h;
Expand All @@ -95,7 +97,7 @@ impl Eye {
let ray_dir = self
.world_from_rub_view
.transform_vector3(glam::vec3(px, py, -1.0));
macaw::Ray3::from_origin_dir(self.pos_in_world(), ray_dir.normalize_or_zero())
re_math::Ray3::from_origin_dir(self.pos_in_world(), ray_dir.normalize_or_zero())
} else {
// The ray originates on the camera plane, not from the camera position
let ray_dir = self.world_from_rub_view.rotation().mul_vec3(glam::Vec3::Z);
Expand All @@ -104,7 +106,7 @@ impl Eye {
+ self.world_from_rub_view.rotation().mul_vec3(glam::Vec3::Y) * pointer.y
+ ray_dir * self.near();

macaw::Ray3::from_origin_dir(origin, ray_dir)
re_math::Ray3::from_origin_dir(origin, ray_dir)
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_space_view_spatial/src/mesh_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct LoadedMesh {
// Can't do that right now because it's too hard to pass the render context through.
pub mesh_instances: Vec<re_renderer::renderer::MeshInstance>,

bbox: macaw::BoundingBox,
bbox: re_math::BoundingBox,
}

impl LoadedMesh {
Expand Down Expand Up @@ -149,7 +149,7 @@ impl LoadedMesh {

let bbox = {
re_tracing::profile_scope!("bbox");
macaw::BoundingBox::from_points(vertex_positions.iter().copied())
re_math::BoundingBox::from_points(vertex_positions.iter().copied())
};

let albedo = if let Some(albedo_texture) = &albedo_texture {
Expand Down Expand Up @@ -197,7 +197,7 @@ impl LoadedMesh {
&self.name
}

pub fn bbox(&self) -> macaw::BoundingBox {
pub fn bbox(&self) -> re_math::BoundingBox {
self.bbox
}
}
Expand Down
Loading
Loading