mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
More fixes
This commit is contained in:
parent
7a0f3ea7ef
commit
df4be641eb
8 changed files with 48 additions and 69 deletions
|
@ -636,17 +636,17 @@ AvatarSharedPointer AvatarManager::getAvatarBySessionID(const QUuid& sessionID)
|
||||||
RayToAvatarIntersectionResult AvatarManager::findRayIntersection(const PickRay& ray,
|
RayToAvatarIntersectionResult AvatarManager::findRayIntersection(const PickRay& ray,
|
||||||
const QScriptValue& avatarIdsToInclude,
|
const QScriptValue& avatarIdsToInclude,
|
||||||
const QScriptValue& avatarIdsToDiscard,
|
const QScriptValue& avatarIdsToDiscard,
|
||||||
const QStringList& jointIndicesToFilter,
|
const QStringList& jointNamesToFilter,
|
||||||
bool pickAgainstMesh) {
|
bool pickAgainstMesh) {
|
||||||
QVector<EntityItemID> avatarsToInclude = qVectorEntityItemIDFromScriptValue(avatarIdsToInclude);
|
QVector<EntityItemID> avatarsToInclude = qVectorEntityItemIDFromScriptValue(avatarIdsToInclude);
|
||||||
QVector<EntityItemID> avatarsToDiscard = qVectorEntityItemIDFromScriptValue(avatarIdsToDiscard);
|
QVector<EntityItemID> avatarsToDiscard = qVectorEntityItemIDFromScriptValue(avatarIdsToDiscard);
|
||||||
return findRayIntersectionVector(ray, avatarsToInclude, avatarsToDiscard, jointIndicesToFilter, pickAgainstMesh);
|
return findRayIntersectionVector(ray, avatarsToInclude, avatarsToDiscard, jointNamesToFilter, pickAgainstMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
RayToAvatarIntersectionResult AvatarManager::findRayIntersectionVector(const PickRay& ray,
|
RayToAvatarIntersectionResult AvatarManager::findRayIntersectionVector(const PickRay& ray,
|
||||||
const QVector<EntityItemID>& avatarsToInclude,
|
const QVector<EntityItemID>& avatarsToInclude,
|
||||||
const QVector<EntityItemID>& avatarsToDiscard,
|
const QVector<EntityItemID>& avatarsToDiscard,
|
||||||
const QStringList& jointIndicesToFilter,
|
const QStringList& jointNamesToFilter,
|
||||||
bool pickAgainstMesh) {
|
bool pickAgainstMesh) {
|
||||||
RayToAvatarIntersectionResult result;
|
RayToAvatarIntersectionResult result;
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
|
@ -655,35 +655,37 @@ RayToAvatarIntersectionResult AvatarManager::findRayIntersectionVector(const Pic
|
||||||
Q_ARG(const PickRay&, ray),
|
Q_ARG(const PickRay&, ray),
|
||||||
Q_ARG(const QVector<EntityItemID>&, avatarsToInclude),
|
Q_ARG(const QVector<EntityItemID>&, avatarsToInclude),
|
||||||
Q_ARG(const QVector<EntityItemID>&, avatarsToDiscard),
|
Q_ARG(const QVector<EntityItemID>&, avatarsToDiscard),
|
||||||
Q_ARG(const QStringList&, jointIndicesToFilter),
|
Q_ARG(const QStringList&, jointNamesToFilter),
|
||||||
Q_ARG(bool, pickAgainstMesh));
|
Q_ARG(bool, pickAgainstMesh));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
PROFILE_RANGE(simulation_physics, __FUNCTION__);
|
||||||
|
|
||||||
float distance = (float)INT_MAX; // with FLT_MAX bullet rayTest does not return results
|
float distance = (float)INT_MAX; // with FLT_MAX bullet rayTest does not return results
|
||||||
BoxFace face = BoxFace::UNKNOWN_FACE;
|
|
||||||
glm::vec3 surfaceNormal;
|
|
||||||
QVariantMap extraInfo;
|
|
||||||
std::vector<MyCharacterController::RayAvatarResult> physicsResults = _myAvatar->getCharacterController()->rayTest(glmToBullet(ray.origin), glmToBullet(ray.direction), distance, QVector<uint>());
|
std::vector<MyCharacterController::RayAvatarResult> physicsResults = _myAvatar->getCharacterController()->rayTest(glmToBullet(ray.origin), glmToBullet(ray.direction), distance, QVector<uint>());
|
||||||
glm::vec3 transformedRayPoint;
|
|
||||||
glm::vec3 transformedRayDirection;
|
|
||||||
|
|
||||||
if (physicsResults.size() > 0) {
|
if (physicsResults.size() > 0) {
|
||||||
glm::vec3 rayDirectionInv = { ray.direction.x != 0 ? 1.0f / ray.direction.x : INFINITY,
|
glm::vec3 rayDirectionInv = { ray.direction.x != 0 ? 1.0f / ray.direction.x : INFINITY,
|
||||||
ray.direction.y != 0.0f ? 1.0f / ray.direction.y : INFINITY,
|
ray.direction.y != 0.0f ? 1.0f / ray.direction.y : INFINITY,
|
||||||
ray.direction.z != 0.0f ? 1.0f / ray.direction.z : INFINITY };
|
ray.direction.z != 0.0f ? 1.0f / ray.direction.z : INFINITY };
|
||||||
|
|
||||||
MyCharacterController::RayAvatarResult rayAvatarResult;
|
MyCharacterController::RayAvatarResult rayAvatarResult;
|
||||||
AvatarPointer avatar = nullptr;
|
AvatarPointer avatar = nullptr;
|
||||||
|
|
||||||
|
BoxFace face = BoxFace::UNKNOWN_FACE;
|
||||||
|
glm::vec3 surfaceNormal;
|
||||||
|
QVariantMap extraInfo;
|
||||||
|
|
||||||
for (auto &hit : physicsResults) {
|
for (auto &hit : physicsResults) {
|
||||||
auto avatarID = hit._intersectWithAvatar;
|
auto avatarID = hit._intersectWithAvatar;
|
||||||
bool avatarIsIncluded = avatarsToInclude.contains(avatarID);
|
bool avatarIsIncluded = avatarsToInclude.contains(avatarID);
|
||||||
bool avatarIsDiscarded = avatarsToDiscard.contains(avatarID);
|
bool avatarIsDiscarded = avatarsToDiscard.contains(avatarID);
|
||||||
if (jointIndicesToFilter.size() == 0 && ((avatarsToInclude.size() > 0 && !avatarIsIncluded) ||
|
if (avatarIsDiscarded || (jointNamesToFilter.size() == 0 && avatarsToInclude.size() > 0 && !avatarIsIncluded)) {
|
||||||
(avatarsToDiscard.size() > 0 && avatarIsDiscarded))) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(_myAvatar->getSessionUUID() == avatarID)) {
|
|
||||||
|
if (_myAvatar->getSessionUUID() != avatarID) {
|
||||||
auto avatarMap = getHashCopy();
|
auto avatarMap = getHashCopy();
|
||||||
AvatarHash::iterator itr = avatarMap.find(avatarID);
|
AvatarHash::iterator itr = avatarMap.find(avatarID);
|
||||||
if (itr != avatarMap.end()) {
|
if (itr != avatarMap.end()) {
|
||||||
|
@ -692,25 +694,17 @@ RayToAvatarIntersectionResult AvatarManager::findRayIntersectionVector(const Pic
|
||||||
} else {
|
} else {
|
||||||
avatar = _myAvatar;
|
avatar = _myAvatar;
|
||||||
}
|
}
|
||||||
QVector<int> jointsToDiscard;
|
QVector<int> jointIndicesToDiscard;
|
||||||
if (avatar && jointIndicesToFilter.size() > 0) {
|
if (avatar && jointNamesToFilter.size() > 0 && avatarIsIncluded) {
|
||||||
auto names = avatar->getJointNames();
|
auto names = avatar->getJointNames();
|
||||||
if (avatarIsIncluded) {
|
for (int i = 0; i < names.size(); i++) {
|
||||||
for (int i = 0; i < names.size(); i++) {
|
if (!jointNamesToFilter.contains(names[i])) {
|
||||||
if (!jointIndicesToFilter.contains(names[i])) {
|
jointIndicesToDiscard.push_back(i);
|
||||||
jointsToDiscard.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (avatarIsDiscarded) {
|
|
||||||
for (int i = 0; i < names.size(); i++) {
|
|
||||||
if (jointIndicesToFilter.contains(names[i])) {
|
|
||||||
jointsToDiscard.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hit._isBound) {
|
if (!hit._isBound) {
|
||||||
if (!jointsToDiscard.contains(hit._intersectWithJoint)) {
|
if (!jointIndicesToDiscard.contains(hit._intersectWithJoint)) {
|
||||||
rayAvatarResult = hit;
|
rayAvatarResult = hit;
|
||||||
}
|
}
|
||||||
} else if (avatar) {
|
} else if (avatar) {
|
||||||
|
@ -720,7 +714,7 @@ RayToAvatarIntersectionResult AvatarManager::findRayIntersectionVector(const Pic
|
||||||
for (size_t i = 0; i < hit._boundJoints.size(); i++) {
|
for (size_t i = 0; i < hit._boundJoints.size(); i++) {
|
||||||
assert(hit._boundJoints[i] < multiSpheres.size());
|
assert(hit._boundJoints[i] < multiSpheres.size());
|
||||||
auto &mSphere = multiSpheres[hit._boundJoints[i]];
|
auto &mSphere = multiSpheres[hit._boundJoints[i]];
|
||||||
if (mSphere.isValid() && !jointsToDiscard.contains(hit._boundJoints[i])) {
|
if (mSphere.isValid() && jointIndicesToDiscard.contains(hit._boundJoints[i])) {
|
||||||
float boundDistance = FLT_MAX;
|
float boundDistance = FLT_MAX;
|
||||||
BoxFace face;
|
BoxFace face;
|
||||||
glm::vec3 surfaceNormal;
|
glm::vec3 surfaceNormal;
|
||||||
|
@ -770,7 +764,7 @@ RayToAvatarIntersectionResult AvatarManager::findRayIntersectionVector(const Pic
|
||||||
extraInfo["worldIntersectionPoint"] = vec3toVariant(rayAvatarResult._intersectionPoint);
|
extraInfo["worldIntersectionPoint"] = vec3toVariant(rayAvatarResult._intersectionPoint);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (rayAvatarResult._intersect){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,26 +138,26 @@ public:
|
||||||
* @param {PickRay} ray
|
* @param {PickRay} ray
|
||||||
* @param {Uuid[]} [avatarsToInclude=[]]
|
* @param {Uuid[]} [avatarsToInclude=[]]
|
||||||
* @param {Uuid[]} [avatarsToDiscard=[]]
|
* @param {Uuid[]} [avatarsToDiscard=[]]
|
||||||
* @param {string[]} [jointIndicesToFilter=[] - If included/discarded avatars are provided only this joints corresponding to those avatars would be included/discarded. ]
|
* @param {string[]} [jointNamesToFilter=[] - If included avatars are provided only this joints corresponding to those avatars would be included ]
|
||||||
* @returns {RayToAvatarIntersectionResult}
|
* @returns {RayToAvatarIntersectionResult}
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE RayToAvatarIntersectionResult findRayIntersection(const PickRay& ray,
|
Q_INVOKABLE RayToAvatarIntersectionResult findRayIntersection(const PickRay& ray,
|
||||||
const QScriptValue& avatarIdsToInclude = QScriptValue(),
|
const QScriptValue& avatarIdsToInclude = QScriptValue(),
|
||||||
const QScriptValue& avatarIdsToDiscard = QScriptValue(),
|
const QScriptValue& avatarIdsToDiscard = QScriptValue(),
|
||||||
const QStringList& jointIndicesToFilter = QStringList(),
|
const QStringList& jointNamesToFilter = QStringList(),
|
||||||
bool pickAgainstMesh = true);
|
bool pickAgainstMesh = true);
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @function AvatarManager.findRayIntersectionVector
|
* @function AvatarManager.findRayIntersectionVector
|
||||||
* @param {PickRay} ray
|
* @param {PickRay} ray
|
||||||
* @param {Uuid[]} avatarsToInclude
|
* @param {Uuid[]} avatarsToInclude
|
||||||
* @param {Uuid[]} avatarsToDiscard
|
* @param {Uuid[]} avatarsToDiscard
|
||||||
* @param {string[]} [jointIndicesToFilter=[] - If included/discarded avatars are provided only this joints corresponding to those avatars would be included/discarded. ]
|
* @param {string[]} [jointNamesToFilter=[] - If included avatars are provided only this joints corresponding to those avatars would be included ]
|
||||||
* @returns {RayToAvatarIntersectionResult}
|
* @returns {RayToAvatarIntersectionResult}
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE RayToAvatarIntersectionResult findRayIntersectionVector(const PickRay& ray,
|
Q_INVOKABLE RayToAvatarIntersectionResult findRayIntersectionVector(const PickRay& ray,
|
||||||
const QVector<EntityItemID>& avatarsToInclude,
|
const QVector<EntityItemID>& avatarsToInclude,
|
||||||
const QVector<EntityItemID>& avatarsToDiscard,
|
const QVector<EntityItemID>& avatarsToDiscard,
|
||||||
const QStringList& jointIndicesToFilter,
|
const QStringList& jointNamesToFilter,
|
||||||
bool pickAgainstMesh);
|
bool pickAgainstMesh);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
|
|
@ -103,7 +103,7 @@ MyAvatar::MyAvatar(QThread* thread) :
|
||||||
_scriptedMotorFrame(SCRIPTED_MOTOR_CAMERA_FRAME),
|
_scriptedMotorFrame(SCRIPTED_MOTOR_CAMERA_FRAME),
|
||||||
_scriptedMotorMode(SCRIPTED_MOTOR_SIMPLE_MODE),
|
_scriptedMotorMode(SCRIPTED_MOTOR_SIMPLE_MODE),
|
||||||
_motionBehaviors(AVATAR_MOTION_DEFAULTS),
|
_motionBehaviors(AVATAR_MOTION_DEFAULTS),
|
||||||
_characterController(this),
|
_characterController(std::shared_ptr<MyAvatar>(this)),
|
||||||
_eyeContactTarget(LEFT_EYE),
|
_eyeContactTarget(LEFT_EYE),
|
||||||
_realWorldFieldOfView("realWorldFieldOfView",
|
_realWorldFieldOfView("realWorldFieldOfView",
|
||||||
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
||||||
|
@ -2994,14 +2994,13 @@ void MyAvatar::postUpdate(float deltaTime, const render::ScenePointer& scene) {
|
||||||
const Rig& rig = _skeletonModel->getRig();
|
const Rig& rig = _skeletonModel->getRig();
|
||||||
int jointCount = rig.getJointStateCount();
|
int jointCount = rig.getJointStateCount();
|
||||||
if (jointCount == (int)_multiSphereShapes.size()) {
|
if (jointCount == (int)_multiSphereShapes.size()) {
|
||||||
int count = 0;
|
|
||||||
for (int i = 0; i < jointCount; i++) {
|
for (int i = 0; i < jointCount; i++) {
|
||||||
AnimPose jointPose;
|
AnimPose jointPose;
|
||||||
rig.getAbsoluteJointPoseInRigFrame(i, jointPose);
|
rig.getAbsoluteJointPoseInRigFrame(i, jointPose);
|
||||||
const AnimPose pose = rigToWorldPose * jointPose;
|
const AnimPose pose = rigToWorldPose * jointPose;
|
||||||
auto &multiSphere = _multiSphereShapes[i];
|
auto &multiSphere = _multiSphereShapes[i];
|
||||||
auto debugLines = multiSphere.getDebugLines();
|
auto debugLines = multiSphere.getDebugLines();
|
||||||
DebugDraw::getInstance().drawRays(debugLines, DEBUG_COLORS[count++ % NUM_DEBUG_COLORS], pose.trans(), pose.rot());
|
DebugDraw::getInstance().drawRays(debugLines, DEBUG_COLORS[i % NUM_DEBUG_COLORS], pose.trans(), pose.rot());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5218,6 +5217,3 @@ void MyAvatar::releaseGrab(const QUuid& grabID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MyAvatar> MyAvatar::getMyAvatarSharedPointer() {
|
|
||||||
return DependencyManager::get<AvatarManager>()->getMyAvatar();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1158,8 +1158,6 @@ public:
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void releaseGrab(const QUuid& grabID);
|
Q_INVOKABLE void releaseGrab(const QUuid& grabID);
|
||||||
|
|
||||||
std::shared_ptr<MyAvatar> getMyAvatarSharedPointer();
|
|
||||||
|
|
||||||
AvatarEntityMap getAvatarEntityData() const override;
|
AvatarEntityMap getAvatarEntityData() const override;
|
||||||
void setAvatarEntityData(const AvatarEntityMap& avatarEntityData) override;
|
void setAvatarEntityData(const AvatarEntityMap& avatarEntityData) override;
|
||||||
void updateAvatarEntity(const QUuid& entityID, const QByteArray& entityData) override;
|
void updateAvatarEntity(const QUuid& entityID, const QByteArray& entityData) override;
|
||||||
|
|
|
@ -26,7 +26,7 @@ void MyCharacterController::RayShotgunResult::reset() {
|
||||||
walkable = true;
|
walkable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyCharacterController::MyCharacterController(MyAvatar* avatar) {
|
MyCharacterController::MyCharacterController(std::shared_ptr<MyAvatar> avatar) {
|
||||||
|
|
||||||
assert(avatar);
|
assert(avatar);
|
||||||
_avatar = avatar;
|
_avatar = avatar;
|
||||||
|
@ -370,7 +370,7 @@ btCollisionShape* MyCharacterController::createDetailedCollisionShapeForJoint(in
|
||||||
DetailedMotionState* MyCharacterController::createDetailedMotionStateForJoint(int jointIndex) {
|
DetailedMotionState* MyCharacterController::createDetailedMotionStateForJoint(int jointIndex) {
|
||||||
auto shape = createDetailedCollisionShapeForJoint(jointIndex);
|
auto shape = createDetailedCollisionShapeForJoint(jointIndex);
|
||||||
if (shape) {
|
if (shape) {
|
||||||
DetailedMotionState* motionState = new DetailedMotionState(_avatar->getMyAvatarSharedPointer(), shape, jointIndex);
|
DetailedMotionState* motionState = new DetailedMotionState(_avatar, shape, jointIndex);
|
||||||
motionState->setMass(_avatar->computeMass());
|
motionState->setMass(_avatar->computeMass());
|
||||||
return motionState;
|
return motionState;
|
||||||
}
|
}
|
||||||
|
@ -384,9 +384,6 @@ void MyCharacterController::clearDetailedMotionStates() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyCharacterController::resetDetailedMotionStates() {
|
void MyCharacterController::resetDetailedMotionStates() {
|
||||||
for (size_t i = 0; i < _detailedMotionStates.size(); i++) {
|
|
||||||
_detailedMotionStates[i] = nullptr;
|
|
||||||
}
|
|
||||||
_detailedMotionStates.clear();
|
_detailedMotionStates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +395,6 @@ void MyCharacterController::buildPhysicsTransaction(PhysicsEngine::Transaction&
|
||||||
_pendingFlags &= ~PENDING_FLAG_REMOVE_DETAILED_FROM_SIMULATION;
|
_pendingFlags &= ~PENDING_FLAG_REMOVE_DETAILED_FROM_SIMULATION;
|
||||||
for (size_t i = 0; i < _detailedMotionStates.size(); i++) {
|
for (size_t i = 0; i < _detailedMotionStates.size(); i++) {
|
||||||
transaction.objectsToRemove.push_back(_detailedMotionStates[i]);
|
transaction.objectsToRemove.push_back(_detailedMotionStates[i]);
|
||||||
_detailedMotionStates[i] = nullptr;
|
|
||||||
}
|
}
|
||||||
_detailedMotionStates.clear();
|
_detailedMotionStates.clear();
|
||||||
}
|
}
|
||||||
|
@ -423,9 +419,9 @@ void MyCharacterController::handleProcessedPhysicsTransaction(PhysicsEngine::Tra
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ClosestDetailed : public btCollisionWorld::AllHitsRayResultCallback {
|
class DetailedRayResultCallback : public btCollisionWorld::AllHitsRayResultCallback {
|
||||||
public:
|
public:
|
||||||
ClosestDetailed()
|
DetailedRayResultCallback()
|
||||||
: btCollisionWorld::AllHitsRayResultCallback(btVector3(0.0f, 0.0f, 0.0f), btVector3(0.0f, 0.0f, 0.0f)) {
|
: btCollisionWorld::AllHitsRayResultCallback(btVector3(0.0f, 0.0f, 0.0f), btVector3(0.0f, 0.0f, 0.0f)) {
|
||||||
// the RayResultCallback's group and mask must match MY_AVATAR
|
// the RayResultCallback's group and mask must match MY_AVATAR
|
||||||
m_collisionFilterGroup = BULLET_COLLISION_GROUP_DETAILED_RAY;
|
m_collisionFilterGroup = BULLET_COLLISION_GROUP_DETAILED_RAY;
|
||||||
|
@ -442,11 +438,12 @@ std::vector<MyCharacterController::RayAvatarResult> MyCharacterController::rayTe
|
||||||
std::vector<RayAvatarResult> foundAvatars;
|
std::vector<RayAvatarResult> foundAvatars;
|
||||||
if (_dynamicsWorld) {
|
if (_dynamicsWorld) {
|
||||||
btVector3 end = origin + length * direction;
|
btVector3 end = origin + length * direction;
|
||||||
ClosestDetailed rayCallback = ClosestDetailed();
|
DetailedRayResultCallback rayCallback = DetailedRayResultCallback();
|
||||||
rayCallback.m_flags |= btTriangleRaycastCallback::kF_KeepUnflippedNormal;
|
rayCallback.m_flags |= btTriangleRaycastCallback::kF_KeepUnflippedNormal;
|
||||||
rayCallback.m_flags |= btTriangleRaycastCallback::kF_UseSubSimplexConvexCastRaytest;
|
rayCallback.m_flags |= btTriangleRaycastCallback::kF_UseSubSimplexConvexCastRaytest;
|
||||||
_dynamicsWorld->rayTest(origin, end, rayCallback);
|
_dynamicsWorld->rayTest(origin, end, rayCallback);
|
||||||
if (rayCallback.m_hitFractions.size() > 0) {
|
if (rayCallback.m_hitFractions.size() > 0) {
|
||||||
|
foundAvatars.reserve(rayCallback.m_hitFractions.size());
|
||||||
for (int i = 0; i < rayCallback.m_hitFractions.size(); i++) {
|
for (int i = 0; i < rayCallback.m_hitFractions.size(); i++) {
|
||||||
auto object = rayCallback.m_collisionObjects[i];
|
auto object = rayCallback.m_collisionObjects[i];
|
||||||
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(object->getUserPointer());
|
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(object->getUserPointer());
|
||||||
|
|
|
@ -23,7 +23,7 @@ class DetailedMotionState;
|
||||||
|
|
||||||
class MyCharacterController : public CharacterController {
|
class MyCharacterController : public CharacterController {
|
||||||
public:
|
public:
|
||||||
explicit MyCharacterController(MyAvatar* avatar);
|
explicit MyCharacterController(std::shared_ptr<MyAvatar> avatar);
|
||||||
~MyCharacterController ();
|
~MyCharacterController ();
|
||||||
|
|
||||||
void setDynamicsWorld(btDynamicsWorld* world) override;
|
void setDynamicsWorld(btDynamicsWorld* world) override;
|
||||||
|
@ -77,7 +77,7 @@ private:
|
||||||
btConvexHullShape* computeShape() const;
|
btConvexHullShape* computeShape() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MyAvatar* _avatar { nullptr };
|
std::shared_ptr<MyAvatar> _avatar { nullptr };
|
||||||
|
|
||||||
// shotgun scan data
|
// shotgun scan data
|
||||||
btAlignedObjectArray<btVector3> _topPoints;
|
btAlignedObjectArray<btVector3> _topPoints;
|
||||||
|
|
|
@ -1727,6 +1727,8 @@ void Avatar::computeDetailedShapeInfo(ShapeInfo& shapeInfo, int jointIndex) {
|
||||||
auto& data = _multiSphereShapes[jointIndex].getSpheresData();
|
auto& data = _multiSphereShapes[jointIndex].getSpheresData();
|
||||||
std::vector<glm::vec3> positions;
|
std::vector<glm::vec3> positions;
|
||||||
std::vector<btScalar> radiuses;
|
std::vector<btScalar> radiuses;
|
||||||
|
positions.reserve(data.size());
|
||||||
|
radiuses.reserve(data.size());
|
||||||
for (auto& sphere : data) {
|
for (auto& sphere : data) {
|
||||||
positions.push_back(sphere._position);
|
positions.push_back(sphere._position);
|
||||||
radiuses.push_back(sphere._radius);
|
radiuses.push_back(sphere._radius);
|
||||||
|
|
|
@ -48,12 +48,10 @@ void SphereRegion::extractEdges(bool reverseY) {
|
||||||
if (vec.z == 0.0f) {
|
if (vec.z == 0.0f) {
|
||||||
insertUnique(p1, _edgesX);
|
insertUnique(p1, _edgesX);
|
||||||
insertUnique(p2, _edgesX);
|
insertUnique(p2, _edgesX);
|
||||||
}
|
} else if (vec.y == 0.0f && p1.y == yVal && p2.y == yVal) {
|
||||||
else if (vec.y == 0.0f && p1.y == yVal && p2.y == yVal) {
|
|
||||||
insertUnique(p1, _edgesY);
|
insertUnique(p1, _edgesY);
|
||||||
insertUnique(p2, _edgesY);
|
insertUnique(p2, _edgesY);
|
||||||
}
|
} else if (vec.x == 0.0f) {
|
||||||
else if (vec.x == 0.0f) {
|
|
||||||
insertUnique(p1, _edgesZ);
|
insertUnique(p1, _edgesZ);
|
||||||
insertUnique(p2, _edgesZ);
|
insertUnique(p2, _edgesZ);
|
||||||
}
|
}
|
||||||
|
@ -104,8 +102,7 @@ CollisionShapeExtractionMode MultiSphereShape::getExtractionModeByName(const QSt
|
||||||
mode = CollisionShapeExtractionMode::SphereCollapse;
|
mode = CollisionShapeExtractionMode::SphereCollapse;
|
||||||
} else if (isRightHand || isLeftHand) {
|
} else if (isRightHand || isLeftHand) {
|
||||||
mode = CollisionShapeExtractionMode::SpheresXY;
|
mode = CollisionShapeExtractionMode::SpheresXY;
|
||||||
}
|
} else if (isSim || isFlow || isEye || isToe) {
|
||||||
else if (isSim || isFlow || isEye || isToe) {
|
|
||||||
mode = CollisionShapeExtractionMode::None;
|
mode = CollisionShapeExtractionMode::None;
|
||||||
}
|
}
|
||||||
return mode;
|
return mode;
|
||||||
|
@ -174,17 +171,13 @@ bool MultiSphereShape::computeMultiSphereShape(int jointIndex, const QString& na
|
||||||
|
|
||||||
if (xyDif < 0.5f * xyEpsilon && xzDif < 0.5f * xzEpsilon && yzDif < 0.5f * yzEpsilon) {
|
if (xyDif < 0.5f * xyEpsilon && xzDif < 0.5f * xzEpsilon && yzDif < 0.5f * yzEpsilon) {
|
||||||
applyMode = CollisionShapeExtractionMode::Sphere;
|
applyMode = CollisionShapeExtractionMode::Sphere;
|
||||||
}
|
} else if (xzDif < xzEpsilon) {
|
||||||
else if (xzDif < xzEpsilon) {
|
|
||||||
applyMode = dimensions.y > dimensions.z ? CollisionShapeExtractionMode::SpheresY : CollisionShapeExtractionMode::SpheresXZ;
|
applyMode = dimensions.y > dimensions.z ? CollisionShapeExtractionMode::SpheresY : CollisionShapeExtractionMode::SpheresXZ;
|
||||||
}
|
} else if (xyDif < xyEpsilon) {
|
||||||
else if (xyDif < xyEpsilon) {
|
|
||||||
applyMode = dimensions.z > dimensions.y ? CollisionShapeExtractionMode::SpheresZ : CollisionShapeExtractionMode::SpheresXY;
|
applyMode = dimensions.z > dimensions.y ? CollisionShapeExtractionMode::SpheresZ : CollisionShapeExtractionMode::SpheresXY;
|
||||||
}
|
} else if (yzDif < yzEpsilon) {
|
||||||
else if (yzDif < yzEpsilon) {
|
|
||||||
applyMode = dimensions.x > dimensions.y ? CollisionShapeExtractionMode::SpheresX : CollisionShapeExtractionMode::SpheresYZ;
|
applyMode = dimensions.x > dimensions.y ? CollisionShapeExtractionMode::SpheresX : CollisionShapeExtractionMode::SpheresYZ;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
applyMode = CollisionShapeExtractionMode::SpheresXYZ;
|
applyMode = CollisionShapeExtractionMode::SpheresXYZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,8 +466,7 @@ void MultiSphereShape::calculateSphereLines(std::vector<std::pair<glm::vec3, glm
|
||||||
}
|
}
|
||||||
if ((vAxis.z == 0 && vAxis.x < 0) || (vAxis.x == 0 && vAxis.z < 0)) {
|
if ((vAxis.z == 0 && vAxis.x < 0) || (vAxis.x == 0 && vAxis.z < 0)) {
|
||||||
vAxis = -vAxis;
|
vAxis = -vAxis;
|
||||||
}
|
} else if (vAxis.x < 0) {
|
||||||
else if (vAxis.x < 0) {
|
|
||||||
vAxis = -vAxis;
|
vAxis = -vAxis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue