Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/target
/examples/target/
/serialize_test/
.vscode
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ exclude = [
[dependencies]
bitflags = "2.2.1"
serde = {version = "1.0.163", features = ["derive"], optional = true}
strum = {version = "0.24.1", optional = true}
strum_macros = {version ="0.24.3", optional = true}
strum = {version = "0.27.2", optional = true}
strum_macros = {version ="0.27.2", optional = true}

[features]
serde_support = ["serde", "strum", "strum_macros"]
Expand Down
36 changes: 18 additions & 18 deletions examples/testbed/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct System {
pub imgui: Context,
pub platform: WinitPlatform,
pub renderer: Renderer,
pub font_size: f32,
// pub font_size: f32,
pub(crate) s_settings: Settings,
}

Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn init(title: &str) -> System {
imgui,
platform,
renderer,
font_size,
// font_size,
s_settings,
}
}
Expand Down Expand Up @@ -174,16 +174,16 @@ impl System {
target.clear_color(0.2, 0.2, 0.2, 1.0);
platform.prepare_render(&ui, gl_window.window());

if g_debug_draw.borrow().m_show_ui
{
if g_debug_draw.borrow().m_show_ui
{
s_test.borrow().get_base().borrow_mut().draw_title(
&ui,
&format!(
"{0} : {1}",
g_test_entries[s_settings.m_test_index as usize].category,
g_test_entries[s_settings.m_test_index as usize].name
),
);
);
}

s_test.borrow_mut().step(
Expand Down Expand Up @@ -245,7 +245,7 @@ impl System {
device_id: _,
is_synthetic: _,
} => {
if input.state == ElementState::Pressed
if input.state == ElementState::Pressed
{
match input.virtual_keycode {
Some(VirtualKeyCode::Escape) => {
Expand Down Expand Up @@ -329,8 +329,8 @@ impl System {
Some(VirtualKeyCode::P) => {
s_settings.m_pause = !s_settings.m_pause;
},
Some(VirtualKeyCode::LBracket) => {
// Switch to previous test
Some(VirtualKeyCode::LBracket) => {
// Switch to previous test
if s_settings.m_test_index==0 {
s_settings.m_test_index = g_test_entries.len()-1;
}else{
Expand Down Expand Up @@ -359,9 +359,9 @@ impl System {
d.m_show_ui = !d.m_show_ui;
},
_ => {},
}
}
s_test.borrow_mut().keyboard(input);
}
}
s_test.borrow_mut().keyboard(input);
}
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
_ => (),
Expand Down Expand Up @@ -394,7 +394,7 @@ impl System {
s_test: TestPtr<D, F>,
cursor_position: PhysicalPosition<f64>,
g_camera: &mut Camera,
button: &MouseButton,
button: &MouseButton,
action: &ElementState,
mods: &ModifiersState,
s_right_mouse_down: &mut bool,
Expand All @@ -419,7 +419,7 @@ impl System {
s_test.borrow_mut().mouse_down(pw);
}
}

if *action == ElementState::Released
{
s_test.borrow_mut().mouse_up(pw);
Expand All @@ -428,7 +428,7 @@ impl System {
else if *button == MouseButton::Right
{
if *action == ElementState::Pressed
{
{
*s_click_point_ws = g_camera.convert_screen_to_world(ps);
*s_right_mouse_down = true;
}
Expand All @@ -440,7 +440,7 @@ impl System {
}
}

fn mouse_motion_callback<'a, D: UserDataType, F: Facade>(s_test: TestPtr<D, F>,
fn mouse_motion_callback<'a, D: UserDataType, F: Facade>(s_test: TestPtr<D, F>,
g_camera: &mut Camera, position: &PhysicalPosition<f64>,
s_right_mouse_down: &mut bool,
s_click_point_ws: &mut B2vec2)
Expand All @@ -449,7 +449,7 @@ impl System {

let pw: B2vec2 = g_camera.convert_screen_to_world(ps);
s_test.borrow_mut().mouse_move(pw);

if *s_right_mouse_down
{
let diff: B2vec2 = pw - *s_click_point_ws;
Expand Down Expand Up @@ -501,7 +501,7 @@ impl System {
ui.slider_config("Vel Iters", 0, 50)
.display_format("%d")
.build(&mut s_settings.m_velocity_iterations);

ui.slider_config("Pos Iter", 0, 50)
.display_format("%d")
.build(&mut s_settings.m_position_iterations);
Expand All @@ -516,7 +516,7 @@ impl System {
ui.checkbox("Warm Starting", &mut s_settings.m_enable_warm_starting);
ui.checkbox("Time of Impact", &mut s_settings.m_enable_continuous);
ui.checkbox("Sub-Stepping", &mut s_settings.m_enable_sub_stepping);

ui.separator();

ui.checkbox("Shapes", &mut s_settings.m_draw_shapes);
Expand Down
13 changes: 9 additions & 4 deletions examples/testbed/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(crate) fn random_float_range(lo: f32, hi: f32) -> f32 {
// This is called when a joint in the world is implicitly destroyed
// because an attached body is destroyed. This gives us a chance to
// nullify the mouse joint.
pub(crate)struct B2testDestructionListenerDefault<D: UserDataType>
pub(crate)struct B2testDestructionListenerDefault<D: UserDataType>
{
pub(crate) base: TestBasePtrWeak<D>,
}
Expand Down Expand Up @@ -80,10 +80,10 @@ pub(crate) struct ContactPoint<D: UserDataType> {
pub(crate) state: B2pointState,
pub(crate) normal_impulse: f32,
pub(crate) tangent_impulse: f32,
pub(crate) separation: f32,
// pub(crate) separation: f32,
}

pub(crate)struct B2testContactListenerDefault<D: UserDataType>
pub(crate)struct B2testContactListenerDefault<D: UserDataType>
{
pub(crate) base: TestBasePtrWeak<D>,
}
Expand All @@ -108,7 +108,7 @@ pub(crate) type TestPtr<D,F> = Rc<RefCell<dyn TestDyn<D,F>>>;
pub(crate) trait TestDyn<D: UserDataType, F:Facade>
{
fn get_base(&self) -> TestBasePtr<D>;

fn step(&mut self, ui: &imgui::Ui, display: &F, target: &mut glium::Frame, settings: &mut Settings, camera: &mut Camera);
fn update_ui(&mut self, _ui: &imgui::Ui) {}
fn keyboard(&mut self, key: &KeyboardInput) {
Expand All @@ -129,17 +129,22 @@ pub(crate) trait TestDyn<D: UserDataType, F:Facade>
fn launch_bomb_rand(&mut self) {
private::launch_bomb_rand(&mut self.get_base().borrow_mut());
}

#[allow(dead_code)]
fn launch_bomb(&mut self, position: B2vec2, velocity: B2vec2) {
private::launch_bomb(&mut self.get_base().borrow_mut(), position, velocity);
}
#[allow(dead_code)]
fn spawn_bomb(&mut self, world_pt: B2vec2) {
private::spawn_bomb(&mut self.get_base().borrow_mut(), world_pt);
}
#[allow(dead_code)]
fn complete_bomb_spawn(&mut self, p: B2vec2) {
private::complete_bomb_spawn(&mut self.get_base().borrow_mut(), p);
}

// Let derived tests know that a joint was destroyed.
#[allow(dead_code)]
fn joint_destroyed(&mut self, joint: B2jointPtr<D>) {
b2_not_used(joint);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/testbed/test_private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub(crate) fn pre_solve<D: UserDataType>(
state: state2[i],
normal_impulse: manifold.points[i].normal_impulse,
tangent_impulse: manifold.points[i].tangent_impulse,
separation: world_manifold.separations[i],
// separation: world_manifold.separations[i],
});
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ pub(crate) fn mouse_down<D: UserDataType>(self_: &mut Test<D>, p: B2vec2) {
{
let frequency_hz: f32 = 5.0;
let damping_ratio: f32 = 0.7;

jd = B2mouseJointDef {
base: B2jointDef {
jtype: B2jointType::EMouseJoint,
Expand Down
18 changes: 9 additions & 9 deletions examples/testbed/tests/rope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<D: UserDataType, F: Facade> TestDyn<D, F> for Rope<D> {
.build(|| {
ui.separator();
//TODO_humman sys::igGetWindowWidth()
let width_token = ui.push_item_width(200.0 * 0.5);
let _width_token = ui.push_item_width(200.0 * 0.5);

let bend_models = ["Spring", "PBD Ang", "XPBD Ang", "PBD Dist", "PBD Height", "PBD Triangle"];
let stretch_models = ["PBD", "XPBD"];
Expand Down Expand Up @@ -171,7 +171,7 @@ impl<D: UserDataType, F: Facade> TestDyn<D, F> for Rope<D> {
}
_ => {}
}
}
}
}

ui.slider_config("Damping##B1", 0.0, 4.0)
Expand Down Expand Up @@ -255,7 +255,7 @@ impl<D: UserDataType, F: Facade> TestDyn<D, F> for Rope<D> {
*bend_model2 = B2bendingModel::B2PbdHeightBendingModel;
}
_ => {}
}
}
}
}
ui.slider_config("Damping##B2", 0.0, 4.0)
Expand All @@ -268,7 +268,7 @@ impl<D: UserDataType, F: Facade> TestDyn<D, F> for Rope<D> {

ui.slider_config("Stiffness##B2", 0.0, 1.0)
.display_format("%.1f")
.build(&mut self.m_tuning2.bend_stiffness);
.build(&mut self.m_tuning2.bend_stiffness);

ui.checkbox(
"Isometric##2",
Expand All @@ -287,7 +287,7 @@ impl<D: UserDataType, F: Facade> TestDyn<D, F> for Rope<D> {
let stretch_model2 = &mut self.m_tuning2.stretching_model;
let mut stretch_model2_selected: usize = *stretch_model2 as usize;
if ui.combo_simple_string("Stretch Model##2", &mut stretch_model2_selected, &stretch_models) {

match stretch_model2_selected {
0 => {
*stretch_model2 = B2stretchingModel::B2PbdStretchingModel;
Expand All @@ -297,7 +297,7 @@ impl<D: UserDataType, F: Facade> TestDyn<D, F> for Rope<D> {
}
_ => {}
}


}
}
Expand Down Expand Up @@ -330,11 +330,11 @@ impl<D: UserDataType, F: Facade> TestDyn<D, F> for Rope<D> {
self.m_rope1.reset(self.m_position1);
self.m_rope2.reset(self.m_position2);
}

//TODO_humman fix
//width_token.pop(ui);
});
});

}
fn keyboard(&mut self, key: &KeyboardInput) {
match key.virtual_keycode {
Expand Down
Loading