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

Function IsInLowSpace

TombEngine/Game/Lara/PlayerContext.cpp:425–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423 }
424
425 bool IsInLowSpace(const ItemInfo& item, const CollisionInfo& coll)
426 {
427 // HACK: coll.Setup.Radius is only set to LARA_RADIUS_CRAWL in lara_col functions, then reset by LaraAboveWater(),
428 // meaning that for tests called in lara_as functions it will store the wrong radius. -- Sezz 2021.11.05
429 float radius = TestState(item.Animation.ActiveState, CROUCH_STATES) ? LARA_RADIUS_CRAWL : LARA_RADIUS;
430
431 // Get center point collision.
432 auto pointCollCenter = GetPointCollision(item, 0, 0.0f, -LARA_HEIGHT / 2);
433 int floorToCeilHeightCenter = abs(pointCollCenter.GetCeilingHeight() - pointCollCenter.GetFloorHeight());
434
435 // Assess center point collision.
436 if (floorToCeilHeightCenter < LARA_HEIGHT || // Floor-to-ceiling height isn't too wide.
437 abs(coll.Middle.Ceiling - LARA_HEIGHT_CRAWL) < LARA_HEIGHT) // Consider statics overhead detected by GetCollisionInfo().
438 {
439 return true;
440 }
441
442 // TODO: Check whether < or <= and > or >=.
443
444 // Get front point collision.
445 auto pointCollFront = GetPointCollision(item, item.Pose.Orientation.y, radius, -coll.Setup.Height);
446 int floorToCeilHeightFront = abs(pointCollFront.GetCeilingHeight() - pointCollFront.GetFloorHeight());
447 int relFloorHeightFront = abs(pointCollFront.GetFloorHeight() - pointCollCenter.GetFloorHeight());
448
449 // Assess front point collision.
450 if (relFloorHeightFront <= CRAWL_STEPUP_HEIGHT && // Floor is within upper/lower floor bounds.
451 floorToCeilHeightFront < LARA_HEIGHT && // Floor-to-ceiling height isn't too wide.
452 floorToCeilHeightFront > LARA_HEIGHT_CRAWL) // Floor-to-ceiling height isn't too narrow.
453 {
454 return true;
455 }
456
457 // Get back point collision.
458 auto pointCollBack = GetPointCollision(item, item.Pose.Orientation.y, -radius, -coll.Setup.Height);
459 int floorToCeilHeightBack = abs(pointCollBack.GetCeilingHeight() - pointCollBack.GetFloorHeight());
460 int relFloorHeightBack = abs(pointCollBack.GetFloorHeight() - pointCollCenter.GetFloorHeight());
461
462 // Assess back point collision.
463 if (relFloorHeightBack <= CRAWL_STEPUP_HEIGHT && // Floor is within upper/lower floor bounds.
464 floorToCeilHeightBack < LARA_HEIGHT && // Floor-to-ceiling height isn't too wide.
465 floorToCeilHeightBack > LARA_HEIGHT_CRAWL) // Floor-to-ceiling height isn't too narrow.
466 {
467 return true;
468 }
469
470 return false;
471 }
472
473 bool CanCrouch(const ItemInfo& item, const CollisionInfo& coll)
474 {

Callers 7

lara_col_sprint_slideFunction · 0.85
lara_col_crouch_idleFunction · 0.85
lara_col_crouch_rollFunction · 0.85
lara_col_crawl_idleFunction · 0.85
lara_col_crawl_forwardFunction · 0.85
lara_col_crawl_backFunction · 0.85
CanCrawlspaceDiveFunction · 0.85

Calls 4

TestStateFunction · 0.85
GetPointCollisionFunction · 0.85
GetCeilingHeightMethod · 0.45
GetFloorHeightMethod · 0.45

Tested by

no test coverage detected