284 {
285 vector corners[4];
287
288
289 vector avgPosition = vector.Zero;
290 for (int i = 0; i < 4; i++)
291 {
292 avgPosition = avgPosition + corners[i];
293 }
294
295 avgPosition = avgPosition * 0.25;
296
297
299
300 vector normal = vector.Up;
301 vector dirUp = GetDirectionUp();
302
303 bool testLand = depth < -1.0;
304
305
306 if (testLand)
307 {
308
310
311
313
314
316
317
319
320 for (i = 0; i < 4; i++)
321 {
323
325
327 }
328
329 vector d0 = vector.Direction(corners[0], corners[1]);
330 vector d1 = vector.Direction(corners[0], corners[2]);
331
334
335
336 normal = d0 * d1;
337 }
338
339 bool isFlipped = vector.Dot(normal, dirUp) < Math.Cos(angleTolerance * Math.DEG2RAD);
340
341#ifdef DIAG_DEVELOPER
342 if (ctx.IsDebug())
343 {
344 int color = 0xFF00FF00;
345 if (isFlipped)
346 color = 0xFFFF0000;
347
352 }
353#endif
354
355 return isFlipped;
356 }
proto native float GetWaterDepth(vector posWS)
proto native bool GetSurface(SurfaceDetectionParameters params, SurfaceDetectionResult result)
API for surface detection.
bool includeWater
Include water in the surface detection, will return the water if it is higher than the surface.
SurfaceDetectionType type
Type of surface to detect.
RoadSurfaceDetection rsd
See RoadSurfaceDetection, SurfaceTraceType.Roadway only.
Object ignore
Object to ignore tracing against, SurfaceTraceType.Roadway only.
vector position
3D position to trace the surface from
float height
Height position.
ref SurfaceDetectionParameters m_SurfaceParams
ref SurfaceDetectionResult m_SurfaceResult
proto float Normalize()
Normalizes vector. Returns length.
proto native CGame GetGame()