Physics/Geom: CompoundGeom can now include other CompounedGeom pieces
Former-commit-id: 8e421be85985bfb86ee7f6fd24569e36afdb34b4
This commit is contained in:
parent
1642536a0e
commit
f7d6107ec7
|
|
@ -118,9 +118,13 @@ class NAZARA_API NzCompoundGeom : public NzPhysGeom
|
|||
public:
|
||||
NzCompoundGeom(NzPhysWorld* physWorld, NzPhysGeom** geoms, unsigned int geomCount);
|
||||
|
||||
const std::vector<NzPhysGeomRef>& GetGeoms() const;
|
||||
nzGeomType GetType() const override;
|
||||
|
||||
template<typename... Args> static NzCompoundGeomRef New(Args&&... args);
|
||||
|
||||
private:
|
||||
std::vector<NzPhysGeomRef> m_geoms;
|
||||
};
|
||||
|
||||
class NzConeGeom;
|
||||
|
|
|
|||
|
|
@ -178,17 +178,29 @@ NzPhysGeom(physWorld)
|
|||
m_collision = NewtonCreateCompoundCollision(physWorld->GetHandle(), 0);
|
||||
NewtonCompoundCollisionBeginAddRemove(m_collision);
|
||||
|
||||
m_geoms.reserve(geomCount);
|
||||
for (unsigned int i = 0; i < geomCount; ++i)
|
||||
{
|
||||
if (geoms[i]->GetType() == nzGeomType_Compound)
|
||||
NazaraError("Cannot add compound geoms to other compound geoms");
|
||||
{
|
||||
NzCompoundGeom* compoundGeom = static_cast<NzCompoundGeom*>(geoms[i]);
|
||||
for (const NzPhysGeomRef& geom : compoundGeom->GetGeoms())
|
||||
NewtonCompoundCollisionAddSubCollision(m_collision, geom->GetHandle());
|
||||
}
|
||||
else
|
||||
NewtonCompoundCollisionAddSubCollision(m_collision, geoms[i]->GetHandle());
|
||||
|
||||
m_geoms.emplace_back(geoms[i]);
|
||||
}
|
||||
|
||||
NewtonCompoundCollisionEndAddRemove(m_collision);
|
||||
}
|
||||
|
||||
const std::vector<NzPhysGeomRef>& NzCompoundGeom::GetGeoms() const
|
||||
{
|
||||
return m_geoms;
|
||||
}
|
||||
|
||||
nzGeomType NzCompoundGeom::GetType() const
|
||||
{
|
||||
return nzGeomType_Compound;
|
||||
|
|
|
|||
Loading…
Reference in New Issue