Get transforms into the right order

This commit is contained in:
hodasemi 2023-01-16 03:56:10 +01:00
parent 0f16adaa2d
commit 7a8476e7f7
2 changed files with 7 additions and 11 deletions

View file

@ -22,5 +22,5 @@ I just started doing it. That means it isn't very usable right now. I'm working
* [rFactor 2 Modding Resources](https://www.studio-397.com/modding-resources/)
* [rF2SharedMemoryMapPlugin](https://github.com/TheIronWolfModding/rF2SharedMemoryMapPlugin)
* [rF2SharedMemoryMapPlugin_Wine](https://github.com/schlegp/rF2SharedMemoryMapPlugin_Wine)
* [CrewChief](https://github.com/mrbelowski/CrewChiefV4)
* [CrewChief](https://gitlab.com/mr_belowski/CrewChiefV4/-/tree/master/CrewChiefV4)
* [OpenSimHud](https://github.com/schlegp/OpenSimHud)

View file

@ -250,7 +250,8 @@ impl RFactorData {
buffered_car.update(
self.ortho,
offset,
other_position.rotation - player_position.rotation,
player_position.rotation,
other_position.rotation,
self.radar_center,
self.car_width,
self.car_height,
@ -335,8 +336,10 @@ impl RadarObject {
pub fn update(
&self,
ortho: Matrix4<f32>,
offset: Vector2<f32>,
player_rotation: impl Into<Deg<f32>>,
rotation: impl Into<Deg<f32>>,
radar_center: Vector2<f32>,
car_width: f32,
@ -347,6 +350,7 @@ impl RadarObject {
.fill(&RFactorData::create_car_vertices(
ortho
* Matrix4::from_translation(radar_center.extend(0.0))
* Matrix4::from_angle_z(-player_rotation.into())
* Matrix4::from_translation(offset.extend(0.0))
* Matrix4::from_angle_z(rotation.into()),
car_width,
@ -368,7 +372,6 @@ impl RenderObject for RadarObject {
struct CarPosition {
pub position: Vector3<f32>,
pub orientation: [Vector3<f32>; 3],
pub rotation: Rad<f32>,
}
@ -376,13 +379,7 @@ impl CarPosition {
fn new(position: Vector3<f32>, orientation: [Vector3<f32>; 3]) -> Self {
Self {
position,
rotation: {
const DEGREES_IN_RADIAN: f32 = 57.2957795;
let xz_val = orientation[2].xz();
Rad(xz_val.x.atan2(xz_val.y) * DEGREES_IN_RADIAN)
},
orientation,
rotation: Rad(orientation[2].x.atan2(orientation[2].y)),
}
}
}
@ -391,7 +388,6 @@ impl Default for CarPosition {
fn default() -> Self {
Self {
position: vec3(0.0, 0.0, 0.0),
orientation: [vec3(0.0, 0.0, 0.0); 3],
rotation: Rad(0.0),
}
}