MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getDamageLocation

Method getDamageLocation

Engine/source/T3D/player.cpp:2365–2445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2363}
2364
2365void Player::getDamageLocation(const Point3F& in_rPos, const char *&out_rpVert, const char *&out_rpQuad)
2366{
2367 // TODO: This will be WRONG when player is prone or swimming!
2368
2369 Point3F newPoint;
2370 mWorldToObj.mulP(in_rPos, &newPoint);
2371
2372 Point3F boxSize = mObjBox.getExtents();
2373 F32 zHeight = boxSize.z;
2374 F32 zTorso = mDataBlock->boxTorsoPercentage;
2375 F32 zHead = mDataBlock->boxHeadPercentage;
2376
2377 zTorso *= zHeight;
2378 zHead *= zHeight;
2379
2380 if (newPoint.z <= zTorso)
2381 out_rpVert = "legs";
2382 else if (newPoint.z <= zHead)
2383 out_rpVert = "torso";
2384 else
2385 out_rpVert = "head";
2386
2387 if(String::compare(out_rpVert, "head") != 0)
2388 {
2389 if (newPoint.y >= 0.0f)
2390 {
2391 if (newPoint.x <= 0.0f)
2392 out_rpQuad = "front_left";
2393 else
2394 out_rpQuad = "front_right";
2395 }
2396 else
2397 {
2398 if (newPoint.x <= 0.0f)
2399 out_rpQuad = "back_left";
2400 else
2401 out_rpQuad = "back_right";
2402 }
2403 }
2404 else
2405 {
2406 F32 backToFront = boxSize.x;
2407 F32 leftToRight = boxSize.y;
2408
2409 F32 backPoint = backToFront * mDataBlock->boxHeadBackPercentage;
2410 F32 frontPoint = backToFront * mDataBlock->boxHeadFrontPercentage;
2411 F32 leftPoint = leftToRight * mDataBlock->boxHeadLeftPercentage;
2412 F32 rightPoint = leftToRight * mDataBlock->boxHeadRightPercentage;
2413
2414 S32 index = 0;
2415 if (newPoint.y < backPoint)
2416 index += 0;
2417 else if (newPoint.y >= frontPoint)
2418 index += 3;
2419 else
2420 index += 6;
2421
2422 if (newPoint.x < leftPoint)

Callers 1

player.cppFile · 0.80

Calls 3

compareFunction · 0.85
mulPMethod · 0.80
getExtentsMethod · 0.80

Tested by

no test coverage detected