Npcs and mobs climb in stairs too

feature/colissions-stairs
Nuno 3 years ago
parent 8ea4ff53cb
commit f0b74071ad

@ -1676,7 +1676,7 @@ void CMoveContainer::reaction (const CCollisionOTInfo& first)
CVectorD first_pos = dynInfo->getFirstPrimitive()->getFinalPosition(dynInfo->getFirstWorldImage()); CVectorD first_pos = dynInfo->getFirstPrimitive()->getFinalPosition(dynInfo->getFirstWorldImage());
CVectorD second_pos = dynInfo->getSecondPrimitive()->getFinalPosition(dynInfo->getSecondWorldImage()); CVectorD second_pos = dynInfo->getSecondPrimitive()->getFinalPosition(dynInfo->getSecondWorldImage());
nlinfo("P = %f, C = %f, H = %f, D = %f", first_pos.z, second_pos.z, dynInfo->getSecondPrimitive()->getHeight(), second_pos.z-first_pos.z); nlinfo("P = %f, C = %f, H = %f, D = %f", first_pos.z, second_pos.z, dynInfo->getSecondPrimitive()->getHeight(), second_pos.z-first_pos.z);
dynInfo->getFirstPrimitive()->setZOffset(second_pos.z+dynInfo->getSecondPrimitive()->getHeight()-1.0f); dynInfo->getFirstPrimitive()->setZOffset(second_pos.z+dynInfo->getSecondPrimitive()->getHeight()-10.0f);
} }
} }
if (dynInfo->isExit()) if (dynInfo->isExit())

@ -426,7 +426,7 @@ void CCharacterCL::computePrimitive()
// Initialize the primitive. // Initialize the primitive.
if (_Sheet) if (_Sheet)
{ {
initPrimitive(_Sheet->ColRadius*getScale(), _Sheet->ColHeight*getScale(), _Sheet->ColLength, _Sheet->ColWidth, UMovePrimitive::DoNothing, UMovePrimitive::NotATrigger, MaskColNpc, MaskColNone, _Sheet->ClipRadius, _Sheet->ClipHeight); initPrimitive(_Sheet->ColRadius*getScale(), _Sheet->ColHeight*getScale(), _Sheet->ColLength, _Sheet->ColWidth, UMovePrimitive::DoNothing, (UMovePrimitive::TTrigger)(UMovePrimitive::OverlapTrigger | UMovePrimitive::EnterTrigger), MaskColNpc, MaskColDoor, _Sheet->ClipRadius, _Sheet->ClipHeight);
} }
else else
{ {
@ -976,7 +976,7 @@ bool CCharacterCL::build(const CEntitySheet *sheet) // virtual
_CustomScalePos *= getScale(); _CustomScalePos *= getScale();
// Create PACS Primitive. // Create PACS Primitive.
initPrimitive(_Sheet->ColRadius*getScale(), _Sheet->ColHeight*getScale(), _Sheet->ColLength, _Sheet->ColWidth, UMovePrimitive::DoNothing, UMovePrimitive::NotATrigger, MaskColNpc, MaskColNone, _Sheet->ClipRadius, _Sheet->ClipHeight); initPrimitive(_Sheet->ColRadius*getScale(), _Sheet->ColHeight*getScale(), _Sheet->ColLength, _Sheet->ColWidth, UMovePrimitive::DoNothing, (UMovePrimitive::TTrigger)(UMovePrimitive::OverlapTrigger | UMovePrimitive::EnterTrigger), MaskColNpc, MaskColDoor, _Sheet->ClipRadius, _Sheet->ClipHeight);
// Compute the element to be able to snap the entity to the ground. // Compute the element to be able to snap the entity to the ground.
computeCollisionEntity(); computeCollisionEntity();

@ -945,6 +945,8 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
float height = primitive->getHeight(); float height = primitive->getHeight();
CVector size = CVector(width, depth, height); CVector size = CVector(width, depth, height);
if (primitive->getTriggerType() == UMovePrimitive::OverlapStairsTrigger)
size.z -= 10.0f;
float v; float v;
if (getRelativeFloatFromString(values[i], v)) if (getRelativeFloatFromString(values[i], v))
{ {
@ -954,6 +956,8 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
{ {
updateVector(param, size, v, false); updateVector(param, size, v, false);
} }
if (primitive->getTriggerType() == UMovePrimitive::OverlapStairsTrigger)
size.z += 10.0f;
primitive->setSize(size.x, size.y); primitive->setSize(size.x, size.y);
primitive->setHeight(size.z); primitive->setHeight(size.z);
} }
@ -1028,12 +1032,12 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
{ {
bool active; bool active;
fromString(values[i], active); fromString(values[i], active);
primitive->setObstacle(active); primitive->setObstacle(!active);
if (active) if (active)
{ {
primitive->setReactionType(UMovePrimitive::DoNothing); primitive->setReactionType(UMovePrimitive::DoNothing);
primitive->setTriggerType(UMovePrimitive::OverlapStairsTrigger); primitive->setTriggerType(UMovePrimitive::OverlapStairsTrigger);
primitive->setGlobalPosition(instance.getPos()+CVector(0, 0, 0.5f), dynamicWI); primitive->setGlobalPosition(instance.getPos(), dynamicWI);
} }
else else
{ {

@ -3080,9 +3080,9 @@ void displayPACSPrimitive()
// Static collision // Static collision
if (prim->getTriggerType() == UMovePrimitive::OverlapStairsTrigger) if (prim->getTriggerType() == UMovePrimitive::OverlapStairsTrigger)
{ {
line.Color0 = CRGBA::Blue; line.Color0 = CRGBA::Green;
isStairs = true; isStairs = true;
position.z -= 1.0f; position.z -= 10.0f;
} }
else if (prim->getReactionType() == UMovePrimitive::DoNothing) else if (prim->getReactionType() == UMovePrimitive::DoNothing)
{ {

Loading…
Cancel
Save