mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
first try at angular-velocity setting action
This commit is contained in:
parent
6808cf62b6
commit
7f69bdecb2
7 changed files with 49 additions and 40 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <ObjectConstraintSlider.h>
|
||||
#include <ObjectConstraintBallSocket.h>
|
||||
#include <ObjectConstraintConeTwist.h>
|
||||
#include <ObjectActionMotor.h>
|
||||
#include <LogHandler.h>
|
||||
|
||||
#include "InterfaceDynamicFactory.h"
|
||||
|
@ -47,6 +48,8 @@ EntityDynamicPointer interfaceDynamicFactory(EntityDynamicType type, const QUuid
|
|||
return std::make_shared<ObjectConstraintBallSocket>(id, ownerEntity);
|
||||
case DYNAMIC_TYPE_CONE_TWIST:
|
||||
return std::make_shared<ObjectConstraintConeTwist>(id, ownerEntity);
|
||||
case DYNAMIC_TYPE_MOTOR:
|
||||
return std::make_shared<ObjectActionMotor>(id, ownerEntity);
|
||||
}
|
||||
|
||||
qDebug() << "Unknown entity dynamic type";
|
||||
|
|
|
@ -126,6 +126,9 @@ EntityDynamicType EntityDynamicInterface::dynamicTypeFromString(QString dynamicT
|
|||
if (normalizedDynamicTypeString == "conetwist") {
|
||||
return DYNAMIC_TYPE_CONE_TWIST;
|
||||
}
|
||||
if (normalizedDynamicTypeString == "motor") {
|
||||
return DYNAMIC_TYPE_MOTOR;
|
||||
}
|
||||
|
||||
qCDebug(entities) << "Warning -- EntityDynamicInterface::dynamicTypeFromString got unknown dynamic-type name"
|
||||
<< dynamicTypeString;
|
||||
|
@ -154,6 +157,8 @@ QString EntityDynamicInterface::dynamicTypeToString(EntityDynamicType dynamicTyp
|
|||
return "ball-socket";
|
||||
case DYNAMIC_TYPE_CONE_TWIST:
|
||||
return "cone-twist";
|
||||
case DYNAMIC_TYPE_MOTOR:
|
||||
return "motor";
|
||||
}
|
||||
assert(false);
|
||||
return "none";
|
||||
|
|
|
@ -34,7 +34,8 @@ enum EntityDynamicType {
|
|||
DYNAMIC_TYPE_FAR_GRAB = 6000,
|
||||
DYNAMIC_TYPE_SLIDER = 7000,
|
||||
DYNAMIC_TYPE_BALL_SOCKET = 8000,
|
||||
DYNAMIC_TYPE_CONE_TWIST = 9000
|
||||
DYNAMIC_TYPE_CONE_TWIST = 9000,
|
||||
DYNAMIC_TYPE_MOTOR = 10000
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -42,41 +42,6 @@ ObjectActionSpring::~ObjectActionSpring() {
|
|||
#endif
|
||||
}
|
||||
|
||||
SpatiallyNestablePointer ObjectActionSpring::getOther() {
|
||||
SpatiallyNestablePointer other;
|
||||
withWriteLock([&]{
|
||||
if (_otherID == QUuid()) {
|
||||
// no other
|
||||
return;
|
||||
}
|
||||
other = _other.lock();
|
||||
if (other && other->getID() == _otherID) {
|
||||
// other is already up-to-date
|
||||
return;
|
||||
}
|
||||
if (other) {
|
||||
// we have a pointer to other, but it's wrong
|
||||
other.reset();
|
||||
_other.reset();
|
||||
}
|
||||
// we have an other-id but no pointer to other cached
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
if (!parentFinder) {
|
||||
return;
|
||||
}
|
||||
EntityItemPointer ownerEntity = _ownerEntity.lock();
|
||||
if (!ownerEntity) {
|
||||
return;
|
||||
}
|
||||
bool success;
|
||||
_other = parentFinder->find(_otherID, success, ownerEntity->getParentTree());
|
||||
if (success) {
|
||||
other = _other.lock();
|
||||
}
|
||||
});
|
||||
return other;
|
||||
}
|
||||
|
||||
bool ObjectActionSpring::getTarget(float deltaTimeStep, glm::quat& rotation, glm::vec3& position,
|
||||
glm::vec3& linearVelocity, glm::vec3& angularVelocity,
|
||||
float& linearTimeScale, float& angularTimeScale) {
|
||||
|
|
|
@ -47,10 +47,6 @@ protected:
|
|||
glm::vec3 _linearVelocityTarget;
|
||||
glm::vec3 _angularVelocityTarget;
|
||||
|
||||
EntityItemID _otherID;
|
||||
SpatiallyNestableWeakPointer _other;
|
||||
SpatiallyNestablePointer getOther();
|
||||
|
||||
virtual bool prepareForSpringUpdate(btScalar deltaTimeStep);
|
||||
|
||||
void serializeParameters(QDataStream& dataStream) const;
|
||||
|
|
|
@ -274,3 +274,38 @@ QList<btRigidBody*> ObjectDynamic::getRigidBodies() {
|
|||
result += getRigidBody();
|
||||
return result;
|
||||
}
|
||||
|
||||
SpatiallyNestablePointer ObjectDynamic::getOther() {
|
||||
SpatiallyNestablePointer other;
|
||||
withWriteLock([&]{
|
||||
if (_otherID == QUuid()) {
|
||||
// no other
|
||||
return;
|
||||
}
|
||||
other = _other.lock();
|
||||
if (other && other->getID() == _otherID) {
|
||||
// other is already up-to-date
|
||||
return;
|
||||
}
|
||||
if (other) {
|
||||
// we have a pointer to other, but it's wrong
|
||||
other.reset();
|
||||
_other.reset();
|
||||
}
|
||||
// we have an other-id but no pointer to other cached
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
if (!parentFinder) {
|
||||
return;
|
||||
}
|
||||
EntityItemPointer ownerEntity = _ownerEntity.lock();
|
||||
if (!ownerEntity) {
|
||||
return;
|
||||
}
|
||||
bool success;
|
||||
_other = parentFinder->find(_otherID, success, ownerEntity->getParentTree());
|
||||
if (success) {
|
||||
other = _other.lock();
|
||||
}
|
||||
});
|
||||
return other;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,10 @@ protected:
|
|||
QString _tag;
|
||||
quint64 _expires { 0 }; // in seconds since epoch
|
||||
|
||||
EntityItemID _otherID;
|
||||
SpatiallyNestableWeakPointer _other;
|
||||
SpatiallyNestablePointer getOther();
|
||||
|
||||
private:
|
||||
qint64 getEntityServerClockSkew() const;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue