@@ -30,7 +30,7 @@ func vectorITransform(in1 mgl32.Vec3, in2 mgl32.Mat3x4) (out mgl32.Vec3) {
30
30
return out
31
31
}
32
32
33
- func transformPhyVertex (bone * mdl.Bone , vertex mgl32.Vec3 ) (out mgl32.Vec3 ) {
33
+ func transformPhyVertex (bone * mdl.Bone , vertex mgl32.Vec3 , orientation mgl32. Quat ) (out mgl32.Vec3 ) {
34
34
out [0 ] = 1 / 0.0254 * vertex [0 ]
35
35
out [1 ] = 1 / 0.0254 * vertex [2 ]
36
36
out [2 ] = 1 / 0.0254 * - vertex [1 ]
@@ -42,32 +42,24 @@ func transformPhyVertex(bone *mdl.Bone, vertex mgl32.Vec3) (out mgl32.Vec3) {
42
42
out [1 ] = 1 / 0.0254 * - vertex [0 ]
43
43
out [2 ] = 1 / 0.0254 * - vertex [1 ]
44
44
}
45
- return out
45
+
46
+ return orientation .Rotate (out )
46
47
}
47
48
48
49
func triangles (prop game.IStaticPropDataLump , phy * phy.Phy ) [][3 ]mgl32.Vec3 {
49
50
if phy == nil {
50
51
return nil
51
52
}
52
53
53
- angleMatrices := []mgl32.Mat4 {
54
- mgl32 .Rotate3DX (prop .GetAngles ()[0 ]).Mat4 (),
55
- mgl32 .Rotate3DY (prop .GetAngles ()[1 ]).Mat4 (),
56
- mgl32 .Rotate3DZ (prop .GetAngles ()[2 ]).Mat4 (),
57
- }
54
+ angles := prop .GetAngles ()
55
+ orientation := mgl32 .AnglesToQuat (mgl32 .DegToRad (angles [0 ]), mgl32 .DegToRad (angles [1 ]), mgl32 .DegToRad (angles [2 ]), mgl32 .YZX )
58
56
59
57
out := make ([][3 ]mgl32.Vec3 , len (phy .TriangleFaces ))
60
58
61
59
for i , t := range phy .TriangleFaces {
62
- a := prop .GetOrigin ().Add (transformPhyVertex (nil , phy .Vertices [t .V1 ].Vec3 ()))
63
- b := prop .GetOrigin ().Add (transformPhyVertex (nil , phy .Vertices [t .V2 ].Vec3 ()))
64
- c := prop .GetOrigin ().Add (transformPhyVertex (nil , phy .Vertices [t .V3 ].Vec3 ()))
65
-
66
- for _ , mat := range angleMatrices {
67
- a = mgl32 .TransformCoordinate (a , mat )
68
- b = mgl32 .TransformCoordinate (b , mat )
69
- c = mgl32 .TransformCoordinate (c , mat )
70
- }
60
+ a := prop .GetOrigin ().Add (transformPhyVertex (nil , phy .Vertices [t .V1 ].Vec3 (), orientation ))
61
+ b := prop .GetOrigin ().Add (transformPhyVertex (nil , phy .Vertices [t .V2 ].Vec3 (), orientation ))
62
+ c := prop .GetOrigin ().Add (transformPhyVertex (nil , phy .Vertices [t .V3 ].Vec3 (), orientation ))
71
63
72
64
out [i ] = [3 ]mgl32.Vec3 {a , b , c }
73
65
}
0 commit comments