mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:30:42 +02:00
give MyAvatar a VoxelShapeManager member
This commit is contained in:
parent
83e04a0e8f
commit
2c1aa31d1e
2 changed files with 119 additions and 100 deletions
|
@ -79,7 +79,8 @@ MyAvatar::MyAvatar() :
|
|||
_lookAtTargetAvatar(),
|
||||
_shouldRender(true),
|
||||
_billboardValid(false),
|
||||
_physicsSimulation()
|
||||
_physicsSimulation(),
|
||||
_voxelShapeManager()
|
||||
{
|
||||
ShapeCollider::initDispatchTable();
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
|
||||
|
@ -90,11 +91,11 @@ MyAvatar::MyAvatar() :
|
|||
_skeletonModel.setEnableShapes(true);
|
||||
Ragdoll* ragdoll = _skeletonModel.buildRagdoll();
|
||||
_physicsSimulation.setRagdoll(ragdoll);
|
||||
_physicsSimulation.addEntity(&_voxelShapeManager);
|
||||
}
|
||||
|
||||
MyAvatar::~MyAvatar() {
|
||||
_physicsSimulation.setRagdoll(NULL);
|
||||
_physicsSimulation.setEntity(NULL);
|
||||
_physicsSimulation.clear();
|
||||
_lookAtTargetAvatar.clear();
|
||||
}
|
||||
|
||||
|
@ -1486,6 +1487,18 @@ void MyAvatar::updateCollisionWithEnvironment(float deltaTime, float radius) {
|
|||
static CollisionList myCollisions(64);
|
||||
|
||||
void MyAvatar::updateCollisionWithVoxels(float deltaTime, float radius) {
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll)) {
|
||||
// compute the bounding cube around avatar
|
||||
float radius = 2.0f * getBoundingRadius();
|
||||
glm::vec3 corner = getPosition() - glm::vec3(radius);
|
||||
AACube boundingCube(corner, 2.0f * radius);
|
||||
|
||||
// query the VoxelTree for cubes that touch avatar's boundingCube
|
||||
CubeList cubes;
|
||||
if (Application::getInstance()->getVoxelTree()->findContentInCube(boundingCube, cubes)) {
|
||||
_voxelShapeManager.updateVoxels(cubes);
|
||||
}
|
||||
} else {
|
||||
const float MAX_VOXEL_COLLISION_SPEED = 100.0f;
|
||||
float speed = glm::length(_velocity);
|
||||
if (speed > MAX_VOXEL_COLLISION_SPEED) {
|
||||
|
@ -1592,6 +1605,7 @@ void MyAvatar::updateCollisionWithVoxels(float deltaTime, float radius) {
|
|||
//updateCollisionSound(myCollisions[0]->_penetration, deltaTime, VOXEL_COLLISION_FREQUENCY);
|
||||
}
|
||||
_trapDuration = isTrapped ? _trapDuration + deltaTime : 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::applyHardCollision(const glm::vec3& penetration, float elasticity, float damping) {
|
||||
|
@ -1952,6 +1966,9 @@ void MyAvatar::updateMotionBehaviorsFromMenu() {
|
|||
} else {
|
||||
_motionBehaviors &= ~AVATAR_MOTION_STAND_ON_NEARBY_FLOORS;
|
||||
}
|
||||
if (!(_collisionGroups | COLLISION_GROUP_VOXELS)) {
|
||||
_voxelShapeManager.clearShapes();
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::renderAttachments(RenderMode renderMode) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <PhysicsSimulation.h>
|
||||
|
||||
#include "Avatar.h"
|
||||
#include "VoxelShapeManager.h"
|
||||
|
||||
class ModelItemID;
|
||||
|
||||
|
@ -214,6 +215,7 @@ private:
|
|||
|
||||
QList<AnimationHandlePointer> _animationHandles;
|
||||
PhysicsSimulation _physicsSimulation;
|
||||
VoxelShapeManager _voxelShapeManager;
|
||||
|
||||
RecorderPointer _recorder;
|
||||
|
||||
|
|
Loading…
Reference in a new issue