mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 13:49:46 +02:00
back out some changes to Model.cpp, change how rig pointer is delivered to model initilizer
This commit is contained in:
parent
fecdc08720
commit
7c8d52cbd1
12 changed files with 228 additions and 358 deletions
|
@ -75,9 +75,9 @@ namespace render {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Avatar::Avatar() :
|
Avatar::Avatar(RigPointer rig) :
|
||||||
AvatarData(),
|
AvatarData(),
|
||||||
_skeletonModel(this),
|
_skeletonModel(this, nullptr, rig),
|
||||||
_skeletonOffset(0.0f),
|
_skeletonOffset(0.0f),
|
||||||
_bodyYawDelta(0.0f),
|
_bodyYawDelta(0.0f),
|
||||||
_positionDeltaAccumulator(0.0f),
|
_positionDeltaAccumulator(0.0f),
|
||||||
|
|
|
@ -72,7 +72,7 @@ class Avatar : public AvatarData {
|
||||||
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Avatar();
|
Avatar(RigPointer rig = nullptr);
|
||||||
~Avatar();
|
~Avatar();
|
||||||
|
|
||||||
typedef render::Payload<AvatarData> Payload;
|
typedef render::Payload<AvatarData> Payload;
|
||||||
|
|
|
@ -65,7 +65,7 @@ AvatarManager::AvatarManager(QObject* parent) :
|
||||||
{
|
{
|
||||||
// register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar
|
// register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar
|
||||||
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
|
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
|
||||||
_myAvatar = std::make_shared<MyAvatar>();
|
_myAvatar = std::make_shared<MyAvatar>(std::make_shared<Rig>());
|
||||||
|
|
||||||
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
||||||
packetReceiver.registerListener(PacketType::BulkAvatarData, this, "processAvatarDataPacket");
|
packetReceiver.registerListener(PacketType::BulkAvatarData, this, "processAvatarDataPacket");
|
||||||
|
@ -160,7 +160,7 @@ void AvatarManager::simulateAvatarFades(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarSharedPointer AvatarManager::newSharedAvatar() {
|
AvatarSharedPointer AvatarManager::newSharedAvatar() {
|
||||||
return AvatarSharedPointer(std::make_shared<Avatar>());
|
return AvatarSharedPointer(std::make_shared<Avatar>(std::make_shared<Rig>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
|
|
|
@ -78,8 +78,8 @@ const float MyAvatar::ZOOM_MIN = 0.5f;
|
||||||
const float MyAvatar::ZOOM_MAX = 25.0f;
|
const float MyAvatar::ZOOM_MAX = 25.0f;
|
||||||
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
||||||
|
|
||||||
MyAvatar::MyAvatar() :
|
MyAvatar::MyAvatar(RigPointer rig) :
|
||||||
Avatar(),
|
Avatar(rig),
|
||||||
_gravity(0.0f, 0.0f, 0.0f),
|
_gravity(0.0f, 0.0f, 0.0f),
|
||||||
_wasPushing(false),
|
_wasPushing(false),
|
||||||
_isPushing(false),
|
_isPushing(false),
|
||||||
|
@ -102,8 +102,8 @@ MyAvatar::MyAvatar() :
|
||||||
_eyeContactTarget(LEFT_EYE),
|
_eyeContactTarget(LEFT_EYE),
|
||||||
_realWorldFieldOfView("realWorldFieldOfView",
|
_realWorldFieldOfView("realWorldFieldOfView",
|
||||||
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
||||||
_rig(new Rig()),
|
_rig(rig),
|
||||||
_firstPersonSkeletonModel(this, nullptr, _rig),
|
_firstPersonSkeletonModel(this, nullptr, rig),
|
||||||
_prevShouldDrawHead(true)
|
_prevShouldDrawHead(true)
|
||||||
{
|
{
|
||||||
_firstPersonSkeletonModel.setIsFirstPerson(true);
|
_firstPersonSkeletonModel.setIsFirstPerson(true);
|
||||||
|
|
|
@ -36,7 +36,7 @@ class MyAvatar : public Avatar {
|
||||||
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyAvatar();
|
MyAvatar(RigPointer rig);
|
||||||
~MyAvatar();
|
~MyAvatar();
|
||||||
|
|
||||||
QByteArray toByteArray();
|
QByteArray toByteArray();
|
||||||
|
|
|
@ -42,6 +42,7 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer r
|
||||||
_headClipDistance(DEFAULT_NEAR_CLIP),
|
_headClipDistance(DEFAULT_NEAR_CLIP),
|
||||||
_isFirstPerson(false)
|
_isFirstPerson(false)
|
||||||
{
|
{
|
||||||
|
assert(_rig);
|
||||||
assert(_owningAvatar);
|
assert(_owningAvatar);
|
||||||
_enableShapes = true;
|
_enableShapes = true;
|
||||||
}
|
}
|
||||||
|
@ -269,7 +270,6 @@ void SkeletonModel::applyPalmData(int jointIndex, PalmData& palm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SkeletonModel::updateJointState(int index) {
|
void SkeletonModel::updateJointState(int index) {
|
||||||
if (index < 0 && index >= _jointStates.size()) {
|
if (index < 0 && index >= _jointStates.size()) {
|
||||||
return; // bail
|
return; // bail
|
||||||
|
@ -281,10 +281,10 @@ void SkeletonModel::updateJointState(int index) {
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
if (index == geometry.leanJointIndex) {
|
if (index == geometry.leanJointIndex) {
|
||||||
maybeUpdateLeanRotation(parentState, state);
|
maybeUpdateLeanRotation(parentState, state);
|
||||||
|
|
||||||
} else if (index == geometry.neckJointIndex) {
|
} else if (index == geometry.neckJointIndex) {
|
||||||
maybeUpdateNeckRotation(parentState, joint, state);
|
maybeUpdateNeckRotation(parentState, joint, state);
|
||||||
|
|
||||||
} else if (index == geometry.leftEyeJointIndex || index == geometry.rightEyeJointIndex) {
|
} else if (index == geometry.leftEyeJointIndex || index == geometry.rightEyeJointIndex) {
|
||||||
maybeUpdateEyeRotation(parentState, joint, state);
|
maybeUpdateEyeRotation(parentState, joint, state);
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,6 @@ void SkeletonModel::updateJointState(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, JointState& state) {
|
void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, JointState& state) {
|
||||||
if (!_owningAvatar->isMyAvatar()) {
|
if (!_owningAvatar->isMyAvatar()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -161,7 +161,7 @@ private:
|
||||||
void setHandPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation);
|
void setHandPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation);
|
||||||
|
|
||||||
bool getEyeModelPositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
|
bool getEyeModelPositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
|
||||||
|
|
||||||
Avatar* _owningAvatar;
|
Avatar* _owningAvatar;
|
||||||
|
|
||||||
CapsuleShape _boundingShape;
|
CapsuleShape _boundingShape;
|
||||||
|
|
|
@ -184,17 +184,28 @@ void Rig::resetAllTransformsChanged() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Rig::setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority) {
|
glm::quat Rig::setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority, bool constrain) {
|
||||||
glm::quat endRotation;
|
glm::quat endRotation;
|
||||||
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
return endRotation;
|
return endRotation;
|
||||||
}
|
}
|
||||||
JointState& state = _jointStates[jointIndex];
|
JointState& state = _jointStates[jointIndex];
|
||||||
state.setRotationInBindFrame(rotation, priority);
|
state.setRotationInBindFrame(rotation, priority, constrain);
|
||||||
endRotation = state.getRotationInBindFrame();
|
endRotation = state.getRotationInBindFrame();
|
||||||
return endRotation;
|
return endRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::quat Rig::setJointRotationInConstrainedFrame(int jointIndex, glm::quat targetRotation, float priority, bool constrain) {
|
||||||
|
glm::quat endRotation;
|
||||||
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
|
return endRotation;
|
||||||
|
}
|
||||||
|
JointState& state = _jointStates[jointIndex];
|
||||||
|
state.setRotationInConstrainedFrame(targetRotation, priority, constrain);
|
||||||
|
endRotation = state.getRotationInConstrainedFrame();
|
||||||
|
return endRotation;
|
||||||
|
}
|
||||||
|
|
||||||
void Rig::applyJointRotationDelta(int jointIndex, const glm::quat& delta, bool constrain, float priority) {
|
void Rig::applyJointRotationDelta(int jointIndex, const glm::quat& delta, bool constrain, float priority) {
|
||||||
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -54,7 +54,9 @@ public:
|
||||||
void clearJointStates();
|
void clearJointStates();
|
||||||
void setJointState(int index, bool valid, const glm::quat& rotation, float priority);
|
void setJointState(int index, bool valid, const glm::quat& rotation, float priority);
|
||||||
void clearJointAnimationPriority(int index);
|
void clearJointAnimationPriority(int index);
|
||||||
glm::quat setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority);
|
glm::quat setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority, bool constrain = false);
|
||||||
|
glm::quat setJointRotationInConstrainedFrame(int jointIndex, glm::quat targetRotation,
|
||||||
|
float priority, bool constrain = false);
|
||||||
void applyJointRotationDelta(int jointIndex, const glm::quat& delta, bool constrain, float priority);
|
void applyJointRotationDelta(int jointIndex, const glm::quat& delta, bool constrain, float priority);
|
||||||
|
|
||||||
QVector<JointState> getJointStates() { return _jointStates; }
|
QVector<JointState> getJointStates() { return _jointStates; }
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -64,7 +64,7 @@ public:
|
||||||
|
|
||||||
static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
|
static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
|
||||||
|
|
||||||
Model(QObject* parent = NULL, RigPointer rig = nullptr);
|
Model(QObject* parent = nullptr, RigPointer rig = nullptr);
|
||||||
virtual ~Model();
|
virtual ~Model();
|
||||||
|
|
||||||
/// enables/disables scale to fit behavior, the model will be automatically scaled to the specified largest dimension
|
/// enables/disables scale to fit behavior, the model will be automatically scaled to the specified largest dimension
|
||||||
|
@ -206,6 +206,7 @@ public:
|
||||||
|
|
||||||
QStringList getJointNames() const;
|
QStringList getJointNames() const;
|
||||||
|
|
||||||
|
AnimationHandlePointer createAnimationHandle();
|
||||||
|
|
||||||
const QList<AnimationHandlePointer>& getRunningAnimations() const { return _runningAnimations; }
|
const QList<AnimationHandlePointer>& getRunningAnimations() const { return _runningAnimations; }
|
||||||
|
|
||||||
|
@ -259,7 +260,6 @@ protected:
|
||||||
|
|
||||||
bool _showTrueJointTransforms;
|
bool _showTrueJointTransforms;
|
||||||
|
|
||||||
bool getJointStateAtIndex(int jointIndex, JointState& jointState) const;
|
|
||||||
QVector<JointState> _jointStates;
|
QVector<JointState> _jointStates;
|
||||||
|
|
||||||
class MeshState {
|
class MeshState {
|
||||||
|
@ -281,13 +281,10 @@ protected:
|
||||||
void simulateInternal(float deltaTime);
|
void simulateInternal(float deltaTime);
|
||||||
|
|
||||||
/// Updates the state of the joint at the specified index.
|
/// Updates the state of the joint at the specified index.
|
||||||
void updateJointStates();
|
|
||||||
virtual void updateJointState(int index);
|
virtual void updateJointState(int index);
|
||||||
|
|
||||||
virtual void updateVisibleJointStates();
|
virtual void updateVisibleJointStates();
|
||||||
|
|
||||||
glm::quat setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority);
|
|
||||||
|
|
||||||
/// \param jointIndex index of joint in model structure
|
/// \param jointIndex index of joint in model structure
|
||||||
/// \param position position of joint in model-frame
|
/// \param position position of joint in model-frame
|
||||||
/// \param rotation rotation of joint in model-frame
|
/// \param rotation rotation of joint in model-frame
|
||||||
|
@ -297,8 +294,8 @@ protected:
|
||||||
/// \param alignment
|
/// \param alignment
|
||||||
/// \return true if joint exists
|
/// \return true if joint exists
|
||||||
bool setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation = glm::quat(),
|
bool setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation = glm::quat(),
|
||||||
bool useRotation = false, int lastFreeIndex = -1, bool allIntermediatesFree = false,
|
bool useRotation = false, int lastFreeIndex = -1, bool allIntermediatesFree = false,
|
||||||
const glm::vec3& alignment = glm::vec3(0.0f, -1.0f, 0.0f), float priority = 1.0f);
|
const glm::vec3& alignment = glm::vec3(0.0f, -1.0f, 0.0f), float priority = 1.0f);
|
||||||
|
|
||||||
/// Restores the indexed joint to its default position.
|
/// Restores the indexed joint to its default position.
|
||||||
/// \param fraction the fraction of the default position to apply (i.e., 0.25f to slerp one fourth of the way to
|
/// \param fraction the fraction of the default position to apply (i.e., 0.25f to slerp one fourth of the way to
|
||||||
|
|
|
@ -113,6 +113,8 @@ void vhacd::VHACDUtil::fattenMeshes(const FBXMesh& mesh, FBXMesh& result,
|
||||||
int index1 = triangles[i * 3 + 1] + indexStartOffset;
|
int index1 = triangles[i * 3 + 1] + indexStartOffset;
|
||||||
int index2 = triangles[i * 3 + 2] + indexStartOffset;
|
int index2 = triangles[i * 3 + 2] + indexStartOffset;
|
||||||
|
|
||||||
|
// TODO: skip triangles with a normal that points more negative-y than positive-y
|
||||||
|
|
||||||
glm::vec3 p0 = result.vertices[index0];
|
glm::vec3 p0 = result.vertices[index0];
|
||||||
glm::vec3 p1 = result.vertices[index1];
|
glm::vec3 p1 = result.vertices[index1];
|
||||||
glm::vec3 p2 = result.vertices[index2];
|
glm::vec3 p2 = result.vertices[index2];
|
||||||
|
|
Loading…
Reference in a new issue