Skip to content

Commit 924c056

Browse files
committed
Add LengthAngle physics param mode
1 parent 9f59113 commit 924c056

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

inox2d/src/formats/payload.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ fn deserialize_simple_physics(obj: JsonObject) -> InoxParseResult<SimplePhysics>
156156
},
157157
map_mode: match obj.get_str("map_mode")? {
158158
"AngleLength" => PhysicsParamMapMode::AngleLength,
159+
"LengthAngle" => PhysicsParamMapMode::LengthAngle,
159160
"XY" => PhysicsParamMapMode::XY,
160161
"YX" => PhysicsParamMapMode::YX,
161162
unknown => return Err(InoxParseError::UnknownParamMapMode(unknown.to_owned())),

inox2d/src/node/components.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ pub enum PhysicsModel {
129129
#[derive(Clone)]
130130
pub enum PhysicsParamMapMode {
131131
AngleLength,
132+
LengthAngle,
132133
XY,
133134
YX,
134135
}

inox2d/src/physics/pendulum.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ impl<T: Pendulum> SimplePhysicsCtx for T {
7474
let a = f32::atan2(-local_angle.x, local_angle.y) / PI;
7575
Vec2::new(a, relative_length)
7676
}
77+
PhysicsParamMapMode::LengthAngle => {
78+
let a = f32::atan2(-local_angle.x, local_angle.y) / PI;
79+
Vec2::new(relative_length, a)
80+
},
7781
};
7882

7983
param_value * oscale

0 commit comments

Comments
 (0)