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

Torque impulses #67

Merged
merged 2 commits into from
Dec 17, 2023
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
2 changes: 1 addition & 1 deletion blade-render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exr = { version = "1.6", optional = true }
gltf = { workspace = true, features = ["names", "utils"], optional = true }
glam = { workspace = true }
log = { workspace = true }
mikktspace = { package = "bevy_mikktspace", version = "0.10", optional = true }
mikktspace = { package = "bevy_mikktspace", version = "0.12", optional = true }
mint = { workspace = true }
profiling = { workspace = true }
slab = { workspace = true, optional = true }
Expand Down
9 changes: 2 additions & 7 deletions blade-render/src/model/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
borrow::Cow,
collections::hash_map::{Entry, HashMap},

Check warning on line 3 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused imports: `Entry`, `HashMap`

Check warning on line 3 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused imports: `Entry`, `HashMap`

Check warning on line 3 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused imports: `Entry`, `HashMap`
fmt, hash, mem,
ops::Range,
ptr, str,
Expand All @@ -27,9 +27,7 @@
}

fn encode_normal(v: [f32; 3]) -> u32 {
let raw = pack4x8snorm([v[0], v[1], v[2], 0.0]);
assert_ne!(raw, 0, "Zero normal detected");
raw
pack4x8snorm([v[0], v[1], v[2], 0.0])
}

pub struct Geometry {
Expand Down Expand Up @@ -258,6 +256,7 @@
);
for (v, normal) in pre_vertices.iter_mut().zip(iter) {
v.normal = normal;
assert_ne!(encode_normal(normal), 0);
}
} else {
log::warn!("No normals in {name}");
Expand Down Expand Up @@ -486,11 +485,11 @@

fn cook(
&self,
source: &[u8],

Check warning on line 488 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused variable: `source`

Check warning on line 488 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused variable: `source`

Check warning on line 488 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused variable: `source`
extension: &str,
meta: Meta,

Check warning on line 490 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused variable: `meta`

Check warning on line 490 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused variable: `meta`

Check warning on line 490 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused variable: `meta`
cooker: Arc<blade_asset::Cooker<Self>>,

Check warning on line 491 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused variable: `cooker`

Check warning on line 491 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused variable: `cooker`

Check warning on line 491 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused variable: `cooker`
exe_context: &choir::ExecutionContext,

Check warning on line 492 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Linux, ubuntu-latest, x86_64-unknown-linux-gnu)

unused variable: `exe_context`

Check warning on line 492 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (Windows, windows-latest, x86_64-pc-windows-msvc)

unused variable: `exe_context`

Check warning on line 492 in blade-render/src/model/mod.rs

View workflow job for this annotation

GitHub Actions / build (MacOS, macos-latest, x86_64-apple-darwin)

unused variable: `exe_context`
) {
match extension {
#[cfg(feature = "asset")]
Expand Down Expand Up @@ -589,10 +588,6 @@
if meta.generate_tangents {
let ok = mikktspace::generate_tangents(&mut fg);
assert!(ok, "MikkTSpace failed");
} else {
for v in fg.0.iter_mut() {
v.tangent = [1.0, 0.0, 0.0, 0.0];
}
}
let (indices, vertices) = fg.reconstruct_indices();
let mut model = model_clone.lock().unwrap();
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,12 @@ impl Engine {
body.apply_impulse(impulse, false)
}

pub fn apply_torque_impulse(&mut self, handle: ObjectHandle, impulse: nalgebra::Vector3<f32>) {
let object = &self.objects[handle.0];
let body = &mut self.physics.rigid_bodies[object.rigid_body];
body.apply_torque_impulse(impulse, false)
}

pub fn teleport_object(&mut self, handle: ObjectHandle, isometry: nalgebra::Isometry3<f32>) {
let object = &self.objects[handle.0];
let body = &mut self.physics.rigid_bodies[object.rigid_body];
Expand Down
Loading