Fix horizontal offset not being respected
This commit is contained in:
@@ -228,13 +228,13 @@ impl KinematicCharacterController {
|
|||||||
&(Translation::from(result.translation) * character_pos),
|
&(Translation::from(result.translation) * character_pos),
|
||||||
&translation_dir,
|
&translation_dir,
|
||||||
character_shape,
|
character_shape,
|
||||||
translation_dist - offset,
|
translation_dist,
|
||||||
false,
|
false,
|
||||||
filter,
|
filter,
|
||||||
) {
|
) {
|
||||||
// We hit something, compute the allowed self.
|
// We hit something, compute the allowed self.
|
||||||
let allowed_dist =
|
let allowed_dist =
|
||||||
(toi.toi - (-toi.normal1.dot(&translation_dir)) * offset).max(0.0);
|
toi.toi - (toi.normal1.dot(&translation_dir)).abs() * offset;
|
||||||
let allowed_translation = *translation_dir * allowed_dist;
|
let allowed_translation = *translation_dir * allowed_dist;
|
||||||
result.translation += allowed_translation;
|
result.translation += allowed_translation;
|
||||||
translation_remaining -= allowed_translation;
|
translation_remaining -= allowed_translation;
|
||||||
@@ -337,7 +337,7 @@ impl KinematicCharacterController {
|
|||||||
&-self.up,
|
&-self.up,
|
||||||
character_shape,
|
character_shape,
|
||||||
snap_distance,
|
snap_distance,
|
||||||
true,
|
false,
|
||||||
filter,
|
filter,
|
||||||
) {
|
) {
|
||||||
// Apply the snap.
|
// Apply the snap.
|
||||||
@@ -738,6 +738,7 @@ impl KinematicCharacterController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn subtract_hit(translation: Vector<Real>, hit: &TOI, offset: Real) -> Vector<Real> {
|
fn subtract_hit(translation: Vector<Real>, hit: &TOI, offset: Real) -> Vector<Real> {
|
||||||
let surface_correction = translation.dot(&hit.normal1) * (1.0 + offset);
|
let surface_correction = translation.dot(&hit.normal1).abs();
|
||||||
translation - *hit.normal1 * surface_correction
|
let surface_correction = surface_correction + offset;
|
||||||
|
translation + *hit.normal1 * surface_correction
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user