mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
Using pre-computed Model shapes for collisions
...instead of generating collision shapes on the fly
This commit is contained in:
parent
50a5924574
commit
b8c1bab4ae
3 changed files with 11 additions and 0 deletions
|
@ -525,6 +525,10 @@ bool Model::findSphereCollisions(const glm::vec3& sphereCenter, float sphereRadi
|
|||
}
|
||||
}
|
||||
if (ShapeCollider::shapeShape(&sphere, _shapes[i], collisions)) {
|
||||
CollisionInfo* collision = collisions.getLastCollision();
|
||||
collision->_type = MODEL_COLLISION;
|
||||
collision->_data = (void*)(this);
|
||||
collision->_flags = i;
|
||||
collided = true;
|
||||
}
|
||||
outerContinue: ;
|
||||
|
|
|
@ -24,6 +24,10 @@ CollisionInfo* CollisionList::getCollision(int index) {
|
|||
return (index > -1 && index < _size) ? &(_collisions[index]) : NULL;
|
||||
}
|
||||
|
||||
CollisionInfo* CollisionList::getLastCollision() {
|
||||
return (_size > 0) ? &(_collisions[_size - 1]) : NULL;
|
||||
}
|
||||
|
||||
void CollisionList::clear() {
|
||||
for (int i = 0; i < _size; ++i) {
|
||||
// we only clear the important stuff
|
||||
|
|
|
@ -80,6 +80,9 @@ public:
|
|||
/// \return pointer to collision by index. NULL if index out of bounds.
|
||||
CollisionInfo* getCollision(int index);
|
||||
|
||||
/// \return pointer to last collision on the list. NULL if list is empty
|
||||
CollisionInfo* getLastCollision();
|
||||
|
||||
/// \return true if list is full
|
||||
bool isFull() const { return _size == _maxSize; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue