343 {
344 vector corners[4];
346
347
348 vector avgPosition = vector.Zero;
349 for (int i = 0; i < 4; i++)
350 {
351 avgPosition = avgPosition + corners[i];
352 }
353
354 avgPosition = avgPosition * 0.25;
355
356
357 float depth =
g_Game.GetWaterDepth(avgPosition);
358
359 vector normal = vector.
Up;
360 vector dirUp = GetDirectionUp();
361
362 bool testLand = depth < -1.0;
363
364
365 if (testLand)
366 {
367
369
370
372
373
375
376
378
379 for (i = 0; i < 4; i++)
380 {
382
384
386 }
387
388 vector d0 = vector.Direction(corners[0], corners[1]);
389 vector d1 = vector.Direction(corners[0], corners[2]);
390
393
394
395 normal = d0 * d1;
396 }
397
398 bool isFlipped = vector.Dot(normal, dirUp) < Math.Cos(angleTolerance * Math.DEG2RAD);
399
400#ifdef DIAG_DEVELOPER
401 if (ctx.IsDebug())
402 {
403 int color = 0xFF00FF00;
404 if (isFlipped)
405 color = 0xFFFF0000;
406
411 }
412#endif
413
414 return isFlipped;
415 }
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.