back out some changes to Model.cpp, change how rig pointer is delivered to model initilizer

This commit is contained in:
Seth Alves 2015-07-22 13:41:31 -07:00
parent fecdc08720
commit 7c8d52cbd1
12 changed files with 228 additions and 358 deletions

View file

@ -75,9 +75,9 @@ namespace render {
}
}
Avatar::Avatar() :
Avatar::Avatar(RigPointer rig) :
AvatarData(),
_skeletonModel(this),
_skeletonModel(this, nullptr, rig),
_skeletonOffset(0.0f),
_bodyYawDelta(0.0f),
_positionDeltaAccumulator(0.0f),

View file

@ -72,7 +72,7 @@ class Avatar : public AvatarData {
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
public:
Avatar();
Avatar(RigPointer rig = nullptr);
~Avatar();
typedef render::Payload<AvatarData> Payload;

View file

@ -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
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
_myAvatar = std::make_shared<MyAvatar>();
_myAvatar = std::make_shared<MyAvatar>(std::make_shared<Rig>());
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
packetReceiver.registerListener(PacketType::BulkAvatarData, this, "processAvatarDataPacket");
@ -160,7 +160,7 @@ void AvatarManager::simulateAvatarFades(float deltaTime) {
}
AvatarSharedPointer AvatarManager::newSharedAvatar() {
return AvatarSharedPointer(std::make_shared<Avatar>());
return AvatarSharedPointer(std::make_shared<Avatar>(std::make_shared<Rig>()));
}
// virtual

View file

@ -78,8 +78,8 @@ const float MyAvatar::ZOOM_MIN = 0.5f;
const float MyAvatar::ZOOM_MAX = 25.0f;
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
MyAvatar::MyAvatar() :
Avatar(),
MyAvatar::MyAvatar(RigPointer rig) :
Avatar(rig),
_gravity(0.0f, 0.0f, 0.0f),
_wasPushing(false),
_isPushing(false),
@ -102,8 +102,8 @@ MyAvatar::MyAvatar() :
_eyeContactTarget(LEFT_EYE),
_realWorldFieldOfView("realWorldFieldOfView",
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
_rig(new Rig()),
_firstPersonSkeletonModel(this, nullptr, _rig),
_rig(rig),
_firstPersonSkeletonModel(this, nullptr, rig),
_prevShouldDrawHead(true)
{
_firstPersonSkeletonModel.setIsFirstPerson(true);

View file

@ -36,7 +36,7 @@ class MyAvatar : public Avatar {
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
public:
MyAvatar();
MyAvatar(RigPointer rig);
~MyAvatar();
QByteArray toByteArray();

View file

@ -42,6 +42,7 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer r
_headClipDistance(DEFAULT_NEAR_CLIP),
_isFirstPerson(false)
{
assert(_rig);
assert(_owningAvatar);
_enableShapes = true;
}
@ -269,7 +270,6 @@ void SkeletonModel::applyPalmData(int jointIndex, PalmData& palm) {
}
}
void SkeletonModel::updateJointState(int index) {
if (index < 0 && index >= _jointStates.size()) {
return; // bail
@ -297,7 +297,6 @@ void SkeletonModel::updateJointState(int index) {
}
}
void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, JointState& state) {
if (!_owningAvatar->isMyAvatar()) {
return;

View file

@ -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;
if (jointIndex == -1 || _jointStates.isEmpty()) {
return endRotation;
}
JointState& state = _jointStates[jointIndex];
state.setRotationInBindFrame(rotation, priority);
state.setRotationInBindFrame(rotation, priority, constrain);
endRotation = state.getRotationInBindFrame();
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) {
if (jointIndex == -1 || _jointStates.isEmpty()) {
return;

View file

@ -54,7 +54,9 @@ public:
void clearJointStates();
void setJointState(int index, bool valid, const glm::quat& rotation, float priority);
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);
QVector<JointState> getJointStates() { return _jointStates; }

View file

@ -83,7 +83,6 @@ Model::Model(QObject* parent, RigPointer rig) :
_isWireframe(false),
_renderCollisionHull(false),
_rig(rig) {
// we may have been created in the network thread, but we live in the main thread
if (_viewState) {
moveToThread(_viewState->getMainThread());
@ -114,9 +113,11 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vertexShader, pixelShader));
gpu::Shader::makeProgram(*program, slotBindings);
auto locations = std::make_shared<Locations>();
initLocations(program, *locations);
auto state = std::make_shared<gpu::State>();
// Backface on shadow
@ -133,8 +134,7 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
// Blend on transparent
state->setBlendFunction(key.isTranslucent(),
gpu::State::ONE, gpu::State::BLEND_OP_ADD,
gpu::State::INV_SRC_ALPHA, // For transparent only, this keep the highlight intensity
gpu::State::ONE, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, // For transparent only, this keep the highlight intensity
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
// Good to go add the brand new pipeline
@ -145,13 +145,8 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
if (!key.isWireFrame()) {
RenderKey wireframeKey(key.getRaw() | RenderKey::IS_WIREFRAME);
<<<<<<< HEAD
gpu::StatePointer wireframeState = gpu::StatePointer(new gpu::State(state->getValues()));
=======
auto wireframeState = std::make_shared<gpu::State>(state->getValues());
>>>>>>> cf88bce0820df76a55473370db0fcb8c5fe6763d
wireframeState->setFillMode(gpu::State::FILL_LINE);
// create a new RenderPipeline with the same shader side and the mirrorState
@ -173,13 +168,8 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key,
if (!key.isWireFrame()) {
RenderKey wireframeKey(key.getRaw() | RenderKey::IS_MIRROR | RenderKey::IS_WIREFRAME);
<<<<<<< HEAD
gpu::StatePointer wireframeState = gpu::StatePointer(new gpu::State(state->getValues()));;
=======
auto wireframeState = std::make_shared<gpu::State>(state->getValues());
>>>>>>> cf88bce0820df76a55473370db0fcb8c5fe6763d
wireframeState->setFillMode(gpu::State::FILL_LINE);
// create a new RenderPipeline with the same shader side and the mirrorState
@ -262,9 +252,6 @@ QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) {
};
void Model::initJointTransforms() {
if (_rig) {
_rig->initJointTransforms(_scale, _offset);
} else {
// compute model transforms
int numStates = _jointStates.size();
for (int i = 0; i < numStates; ++i) {
@ -281,7 +268,6 @@ void Model::initJointTransforms() {
state.initTransform(parentState.getTransform());
}
}
}
}
void Model::init() {
@ -410,9 +396,6 @@ void Model::init() {
}
void Model::reset() {
if (_rig) {
_rig->resetJoints();
} else {
if (_jointStates.isEmpty()) {
return;
}
@ -420,7 +403,6 @@ void Model::reset() {
for (int i = 0; i < _jointStates.size(); i++) {
_jointStates[i].setRotationInConstrainedFrame(geometry.joints.at(i).rotation, 0.0f);
}
}
_meshGroupsKnown = false;
_readyWhenAdded = false; // in case any of our users are using scenes
@ -446,8 +428,6 @@ bool Model::updateGeometry() {
return false;
}
bool jointStatesEmpty = _rig ? _rig->jointStatesEmpty() : _jointStates.isEmpty();
QSharedPointer<NetworkGeometry> geometry = _geometry->getLODOrFallback(_lodDistance, _lodHysteresis);
if (_geometry != geometry) {
@ -456,7 +436,7 @@ bool Model::updateGeometry() {
const FBXGeometry& newGeometry = geometry->getFBXGeometry();
QVector<JointState> newJointStates = createJointStates(newGeometry);
if (! jointStatesEmpty) {
if (! _jointStates.isEmpty()) {
// copy the existing joint states
const FBXGeometry& oldGeometry = _geometry->getFBXGeometry();
for (QHash<QString, int>::const_iterator it = oldGeometry.jointIndices.constBegin();
@ -464,11 +444,7 @@ bool Model::updateGeometry() {
int oldIndex = it.value() - 1;
int newIndex = newGeometry.getJointIndex(it.key());
if (newIndex != -1) {
JointState jointState;
if (!getJointStateAtIndex(oldIndex, jointState)) {
return false;
}
newJointStates[newIndex].copyState(jointState);
newJointStates[newIndex].copyState(_jointStates[oldIndex]);
}
}
}
@ -481,7 +457,7 @@ bool Model::updateGeometry() {
invalidCalculatedMeshBoxes(); // if we have to reload, we need to assume our mesh boxes are all invalid
initJointStates(newJointStates);
needToRebuild = true;
} else if (jointStatesEmpty) {
} else if (_jointStates.isEmpty()) {
const FBXGeometry& fbxGeometry = geometry->getFBXGeometry();
if (fbxGeometry.joints.size() > 0) {
initJointStates(createJointStates(fbxGeometry));
@ -499,15 +475,9 @@ bool Model::updateGeometry() {
foreach (const FBXMesh& mesh, fbxGeometry.meshes) {
MeshState state;
state.clusterMatrices.resize(mesh.clusters.size());
<<<<<<< HEAD
_meshStates.append(state);
gpu::BufferPointer buffer(new gpu::Buffer());
=======
_meshStates.append(state);
auto buffer = std::make_shared<gpu::Buffer>();
>>>>>>> cf88bce0820df76a55473370db0fcb8c5fe6763d
if (!mesh.blendshapes.isEmpty()) {
buffer->resize((mesh.vertices.size() + mesh.normals.size()) * sizeof(glm::vec3));
buffer->setSubData(0, mesh.vertices.size() * sizeof(glm::vec3), (gpu::Byte*) mesh.vertices.constData());
@ -523,9 +493,6 @@ bool Model::updateGeometry() {
// virtual
void Model::initJointStates(QVector<JointState> states) {
if (_rig) {
_boundingRadius = _rig->initJointStates(_scale, _offset, states);
} else {
_jointStates = states;
initJointTransforms();
@ -542,7 +509,6 @@ void Model::initJointStates(QVector<JointState> states) {
_jointStates[i].slaveVisibleTransform();
}
_boundingRadius = radius;
}
}
bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& direction, float& distance,
@ -1106,40 +1072,28 @@ glm::vec3 Model::calculateScaledOffsetPoint(const glm::vec3& point) const {
bool Model::getJointState(int index, glm::quat& rotation) const {
if (_rig) {
return _rig->getJointState(index, rotation);
} else {
if (index == -1 || index >= _jointStates.size()) {
return false;
}
const JointState& state = _jointStates.at(index);
rotation = state.getRotationInConstrainedFrame();
return !state.rotationIsDefault(rotation);
}
}
bool Model::getVisibleJointState(int index, glm::quat& rotation) const {
if (_rig) {
return _rig->getVisibleJointState(index, rotation);
} else {
if (index == -1 || index >= _jointStates.size()) {
return false;
}
const JointState& state = _jointStates.at(index);
rotation = state.getVisibleRotationInConstrainedFrame();
return !state.rotationIsDefault(rotation);
}
}
void Model::clearJointState(int index) {
if (_rig) {
_rig->clearJointState(index);
} else {
if (index != -1 && index < _jointStates.size()) {
JointState& state = _jointStates[index];
state.setRotationInConstrainedFrame(glm::quat(), 0.0f);
}
}
}
void Model::clearJointAnimationPriority(int index) {
@ -1153,9 +1107,6 @@ void Model::clearJointAnimationPriority(int index) {
}
void Model::setJointState(int index, bool valid, const glm::quat& rotation, float priority) {
if (_rig) {
_rig->setJointState(index, valid, rotation, priority);
} else {
if (index != -1 && index < _jointStates.size()) {
JointState& state = _jointStates[index];
if (valid) {
@ -1164,7 +1115,6 @@ void Model::setJointState(int index, bool valid, const glm::quat& rotation, floa
state.restoreRotation(1.0f, priority);
}
}
}
}
int Model::getParentJointIndex(int jointIndex) const {
@ -1238,82 +1188,62 @@ void Model::setCollisionModelURL(const QUrl& url) {
_collisionGeometry = DependencyManager::get<GeometryCache>()->getGeometry(url, QUrl(), true);
}
bool Model::getJointStateAtIndex(int jointIndex, JointState& jointState) const {
if (_rig) {
return _rig->getJointStateAtIndex(jointIndex, jointState);
} else {
bool Model::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const {
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false;
}
jointState = _jointStates[jointIndex];
return true;
}
}
bool Model::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const {
JointState jointState;
if (!getJointStateAtIndex(jointIndex, jointState)) {
return false;
}
// position is in world-frame
position = _translation + _rotation * jointState.getPosition();
position = _translation + _rotation * _jointStates[jointIndex].getPosition();
return true;
}
bool Model::getJointPosition(int jointIndex, glm::vec3& position) const {
JointState jointState;
if (!getJointStateAtIndex(jointIndex, jointState)) {
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false;
}
// position is in model-frame
position = extractTranslation(jointState.getTransform());
position = extractTranslation(_jointStates[jointIndex].getTransform());
return true;
}
bool Model::getJointRotationInWorldFrame(int jointIndex, glm::quat& rotation) const {
JointState jointState;
if (!getJointStateAtIndex(jointIndex, jointState)) {
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false;
}
rotation = _rotation * jointState.getRotation();
rotation = _rotation * _jointStates[jointIndex].getRotation();
return true;
}
bool Model::getJointRotation(int jointIndex, glm::quat& rotation) const {
JointState jointState;
if (!getJointStateAtIndex(jointIndex, jointState)) {
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false;
}
rotation = jointState.getRotation();
rotation = _jointStates[jointIndex].getRotation();
return true;
}
bool Model::getJointCombinedRotation(int jointIndex, glm::quat& rotation) const {
JointState jointState;
if (!getJointStateAtIndex(jointIndex, jointState)) {
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false;
}
rotation = _rotation * jointState.getRotation();
rotation = _rotation * _jointStates[jointIndex].getRotation();
return true;
}
bool Model::getVisibleJointPositionInWorldFrame(int jointIndex, glm::vec3& position) const {
JointState jointState;
if (!getJointStateAtIndex(jointIndex, jointState)) {
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false;
}
// position is in world-frame
position = _translation + _rotation * jointState.getVisiblePosition();
position = _translation + _rotation * _jointStates[jointIndex].getVisiblePosition();
return true;
}
bool Model::getVisibleJointRotationInWorldFrame(int jointIndex, glm::quat& rotation) const {
JointState jointState;
if (!getJointStateAtIndex(jointIndex, jointState)) {
if (jointIndex == -1 || jointIndex >= _jointStates.size()) {
return false;
}
rotation = _rotation * jointState.getVisibleRotation();
rotation = _rotation * _jointStates[jointIndex].getVisibleRotation();
return true;
}
@ -1508,20 +1438,12 @@ void Model::updateClusterMatrices() {
if (_showTrueJointTransforms) {
for (int j = 0; j < mesh.clusters.size(); j++) {
const FBXCluster& cluster = mesh.clusters.at(j);
JointState jointState;
if (!getJointStateAtIndex(cluster.jointIndex, jointState)) {
return;
}
state.clusterMatrices[j] = modelToWorld * jointState.getTransform() * cluster.inverseBindMatrix;
state.clusterMatrices[j] = modelToWorld * _jointStates[cluster.jointIndex].getTransform() * cluster.inverseBindMatrix;
}
} else {
for (int j = 0; j < mesh.clusters.size(); j++) {
const FBXCluster& cluster = mesh.clusters.at(j);
JointState jointState;
if (!getJointStateAtIndex(cluster.jointIndex, jointState)) {
return;
}
state.clusterMatrices[j] = modelToWorld * jointState.getVisibleTransform() * cluster.inverseBindMatrix;
state.clusterMatrices[j] = modelToWorld * _jointStates[cluster.jointIndex].getVisibleTransform() * cluster.inverseBindMatrix;
}
}
}
@ -1535,17 +1457,12 @@ void Model::simulateInternal(float deltaTime) {
handle->simulate(deltaTime);
}
if (_rig) {
const FBXGeometry& geometry = _geometry->getFBXGeometry();
glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
_rig->updateJointStates(parentTransform);
_rig->resetAllTransformsChanged();
} else {
updateJointStates();
for (int i = 0; i < _jointStates.size(); i++) {
updateJointState(i);
}
for (int i = 0; i < _jointStates.size(); i++) {
_jointStates[i].resetTransformChanged();
}
}
_shapesAreDirty = !_shapes.isEmpty();
@ -1557,20 +1474,12 @@ void Model::simulateInternal(float deltaTime) {
if (_showTrueJointTransforms) {
for (int j = 0; j < mesh.clusters.size(); j++) {
const FBXCluster& cluster = mesh.clusters.at(j);
JointState jointState;
if (!getJointStateAtIndex(cluster.jointIndex, jointState)) {
return;
}
state.clusterMatrices[j] = modelToWorld * jointState.getTransform() * cluster.inverseBindMatrix;
state.clusterMatrices[j] = modelToWorld * _jointStates[cluster.jointIndex].getTransform() * cluster.inverseBindMatrix;
}
} else {
for (int j = 0; j < mesh.clusters.size(); j++) {
const FBXCluster& cluster = mesh.clusters.at(j);
JointState jointState;
if (!getJointStateAtIndex(cluster.jointIndex, jointState)) {
return;
}
state.clusterMatrices[j] = modelToWorld * jointState.getVisibleTransform() * cluster.inverseBindMatrix;
state.clusterMatrices[j] = modelToWorld * _jointStates[cluster.jointIndex].getVisibleTransform() * cluster.inverseBindMatrix;
}
}
}
@ -1582,15 +1491,7 @@ void Model::simulateInternal(float deltaTime) {
}
}
void Model::updateJointStates() {
assert(!_rig);
for (int i = 0; i < _jointStates.size(); i++) {
updateJointState(i);
}
}
void Model::updateJointState(int index) {
assert(!_rig);
JointState& state = _jointStates[index];
const FBXJoint& joint = state.getFBXJoint();
@ -1614,38 +1515,13 @@ void Model::updateVisibleJointStates() {
// no need to update visible transforms
return;
}
if (_rig) {
_rig->updateVisibleJointStates();
} else {
for (int i = 0; i < _jointStates.size(); i++) {
_jointStates[i].slaveVisibleTransform();
}
}
}
glm::quat Model::setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority) {
glm::quat endRotation;
if (jointIndex == -1 || _jointStates.isEmpty()) {
return endRotation;
}
JointState& state = _jointStates[jointIndex];
state.setRotationInBindFrame(rotation, priority);
endRotation = state.getRotationInBindFrame();
return endRotation;
}
bool Model::setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation, bool useRotation,
int lastFreeIndex, bool allIntermediatesFree, const glm::vec3& alignment, float priority) {
if (_rig) {
const FBXGeometry& geometry = _geometry->getFBXGeometry();
glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
bool result = _rig->setJointPosition(jointIndex, position, rotation, useRotation, lastFreeIndex, allIntermediatesFree,
alignment, priority, parentTransform);
_shapesAreDirty = !_shapes.isEmpty();
return result;
}
if (jointIndex == -1 || _jointStates.isEmpty()) {
return false;
}
@ -1730,16 +1606,8 @@ bool Model::setJointPosition(int jointIndex, const glm::vec3& position, const gl
return true;
}
void Model::inverseKinematics(int endIndex, glm::vec3 targetPosition,
const glm::quat& targetRotation, float priority) {
void Model::inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm::quat& targetRotation, float priority) {
// NOTE: targetRotation is from bind- to model-frame
if (_rig) {
const FBXGeometry& geometry = _geometry->getFBXGeometry();
glm::mat4 topParentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
_rig->inverseKinematics( endIndex, targetPosition, targetRotation, priority, topParentTransform);
_shapesAreDirty = !_shapes.isEmpty();
return;
}
if (endIndex == -1 || _jointStates.isEmpty()) {
return;
@ -1854,9 +1722,6 @@ void Model::inverseKinematics(int endIndex, glm::vec3 targetPosition,
}
bool Model::restoreJointPosition(int jointIndex, float fraction, float priority) {
if (_rig) {
return _rig->restoreJointPosition(jointIndex, fraction, priority);
}
if (jointIndex == -1 || _jointStates.isEmpty()) {
return false;
}
@ -1871,9 +1736,6 @@ bool Model::restoreJointPosition(int jointIndex, float fraction, float priority)
}
float Model::getLimbLength(int jointIndex) const {
if (_rig) {
return _rig->getLimbLength(jointIndex, _scale);
}
if (jointIndex == -1 || _jointStates.isEmpty()) {
return 0.0f;
}
@ -1955,9 +1817,6 @@ void Model::applyNextGeometry() {
void Model::deleteGeometry() {
_blendedVertexBuffers.clear();
_jointStates.clear();
if (_rig) {
_rig->clearJointStates();
}
_meshStates.clear();
clearShapes();

View file

@ -64,7 +64,7 @@ public:
static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
Model(QObject* parent = NULL, RigPointer rig = nullptr);
Model(QObject* parent = nullptr, RigPointer rig = nullptr);
virtual ~Model();
/// 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;
AnimationHandlePointer createAnimationHandle();
const QList<AnimationHandlePointer>& getRunningAnimations() const { return _runningAnimations; }
@ -259,7 +260,6 @@ protected:
bool _showTrueJointTransforms;
bool getJointStateAtIndex(int jointIndex, JointState& jointState) const;
QVector<JointState> _jointStates;
class MeshState {
@ -281,13 +281,10 @@ protected:
void simulateInternal(float deltaTime);
/// Updates the state of the joint at the specified index.
void updateJointStates();
virtual void updateJointState(int index);
virtual void updateVisibleJointStates();
glm::quat setJointRotationInBindFrame(int jointIndex, const glm::quat& rotation, float priority);
/// \param jointIndex index of joint in model structure
/// \param position position of joint in model-frame
/// \param rotation rotation of joint in model-frame

View file

@ -113,6 +113,8 @@ void vhacd::VHACDUtil::fattenMeshes(const FBXMesh& mesh, FBXMesh& result,
int index1 = triangles[i * 3 + 1] + 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 p1 = result.vertices[index1];
glm::vec3 p2 = result.vertices[index2];