MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / GetVehicleWaterHeight

Function GetVehicleWaterHeight

TombEngine/Objects/Utils/VehicleHelpers.cpp:186–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184 }
185
186 int GetVehicleWaterHeight(ItemInfo* vehicleItem, int forward, int right, bool clamp, Vector3i* pos)
187 {
188 auto rotMatrix = vehicleItem->Pose.Orientation.ToRotationMatrix();
189 auto tMatrix = Matrix::CreateTranslation(vehicleItem->Pose.Position.ToVector3());
190 auto world = rotMatrix * tMatrix;
191
192 auto point = Vector3(right, 0, forward);
193 point = Vector3::Transform(point, world);
194 *pos = Vector3i(point);
195
196 auto pointColl = GetPointCollision(*pos, vehicleItem->RoomNumber);
197 int height = GetPointCollision(Vector3i(pos->x, pos->y, pos->z), pointColl.GetRoomNumber()).GetWaterTopHeight();
198
199 if (height == NO_HEIGHT)
200 {
201 height = pointColl.GetFloorHeight();
202 if (height == NO_HEIGHT)
203 return height;
204 }
205
206 height -= 5;
207
208 if (pos->y > height && clamp)
209 pos->y = height;
210
211 return height;
212 }
213
214 void DoVehicleCollision(ItemInfo* vehicleItem, int radius)
215 {

Callers 6

SpeedboatDynamicsFunction · 0.85
SpeedboatControlFunction · 0.85
RubberBoatDynamicsFunction · 0.85
RubberBoatControlFunction · 0.85
KayakCanGetOutFunction · 0.85
KayakToBackgroundFunction · 0.85

Calls 8

GetPointCollisionFunction · 0.85
GetWaterTopHeightMethod · 0.80
Vector3Function · 0.50
Vector3iClass · 0.50
ToRotationMatrixMethod · 0.45
ToVector3Method · 0.45
GetRoomNumberMethod · 0.45
GetFloorHeightMethod · 0.45

Tested by

no test coverage detected