History

Merging back with master

Sam Gateau committed 11 years ago

Commit c37cdce2 parents 4e94464 c4c6e72427 files · +25473 −4250Browse files

Showing the changes to libraries/render-utils/src/Model.cpp (1 of 427 files). Show all

Unified · Split

libraries/render-utils/src/Model.cpp+25−15
@@ -60,6 +60,8 @@ float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f; · 59 unmodified lines
6060
6161 Model::Model(RigPointer rig, QObject* parent) :
6262 QObject(parent),
63+ _translation(0.0f),
64+ _rotation(),
6365 _scale(1.0f, 1.0f, 1.0f),
6466 _scaleToFit(false),
6567 _scaleToFitDimensions(0.0f),
@@ -70,7 +72,6 @@ Model::Model(RigPointer rig, QObject* parent) : · 4 unmodified lines
7072 _cauterizeBones(false),
7173 _pupilDilation(0.0f),
7274 _url(HTTP_INVALID_COM),
73− _urlAsString(HTTP_INVALID_COM),
7475 _isVisible(true),
7576 _blendNumber(0),
7677 _appliedBlendNumber(0),
@@ -195,6 +196,13 @@ void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model: · 118 unmodified lines
195196
196197 AbstractViewStateInterface* Model::_viewState = NULL;
197198
199+void Model::setTranslation(const glm::vec3& translation) {
200+ _translation = translation;
201+}
202+
203+void Model::setRotation(const glm::quat& rotation) {
204+ _rotation = rotation;
205+}
198206
199207 void Model::setScale(const glm::vec3& scale) {
200208 setScaleInternal(scale);
@@ -433,14 +441,14 @@ void Model::initJointStates(QVector<JointState> states) { · 232 unmodified lines
433441 int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1;
434442 int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1;
435443
436− _boundingRadius = _rig->initJointStates(states, parentTransform,
437− rootJointIndex,
438− leftHandJointIndex,
439− leftElbowJointIndex,
440− leftShoulderJointIndex,
441− rightHandJointIndex,
442− rightElbowJointIndex,
443− rightShoulderJointIndex);
444+ _rig->initJointStates(states, parentTransform,
445+ rootJointIndex,
446+ leftHandJointIndex,
447+ leftElbowJointIndex,
448+ leftShoulderJointIndex,
449+ rightHandJointIndex,
450+ rightElbowJointIndex,
451+ rightShoulderJointIndex);
444452 }
445453
446454 bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& direction, float& distance,
@@ -1023,14 +1031,12 @@ int Model::getLastFreeJointIndex(int jointIndex) const { · 576 unmodified lines
10231031 }
10241032
10251033 void Model::setURL(const QUrl& url) {
1026−
10271034 // don't recreate the geometry if it's the same URL
10281035 if (_url == url && _geometry && _geometry->getURL() == url) {
10291036 return;
10301037 }
10311038
10321039 _url = url;
1033− _urlAsString = _url.toString();
10341040
10351041 {
10361042 render::PendingChanges pendingChanges;
@@ -1280,7 +1286,9 @@ void Model::simulateInternal(float deltaTime) { · 243 unmodified lines
12801286 const FBXGeometry& geometry = _geometry->getFBXGeometry();
12811287 glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
12821288 updateRig(deltaTime, parentTransform);
1283−
1289+}
1290+void Model::updateClusterMatrices() {
1291+ const FBXGeometry& geometry = _geometry->getFBXGeometry();
12841292 glm::mat4 zeroScale(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),
12851293 glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),
12861294 glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1294,7 +1302,7 @@ void Model::simulateInternal(float deltaTime) { · 7 unmodified lines
12941302 if (_showTrueJointTransforms) {
12951303 for (int j = 0; j < mesh.clusters.size(); j++) {
12961304 const FBXCluster& cluster = mesh.clusters.at(j);
1297− auto jointMatrix =_rig->getJointTransform(cluster.jointIndex);
1305+ auto jointMatrix = _rig->getJointTransform(cluster.jointIndex);
12981306 state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix;
12991307
13001308 // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty.
@@ -1308,7 +1316,7 @@ void Model::simulateInternal(float deltaTime) { · 7 unmodified lines
13081316 } else {
13091317 for (int j = 0; j < mesh.clusters.size(); j++) {
13101318 const FBXCluster& cluster = mesh.clusters.at(j);
1311− auto jointMatrix = _rig->getJointVisibleTransform(cluster.jointIndex);
1319+ auto jointMatrix = _rig->getJointVisibleTransform(cluster.jointIndex); // differs from above only in using get...VisibleTransform
13121320 state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix;
13131321
13141322 // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty.
@@ -1405,6 +1413,7 @@ void Model::deleteGeometry() { · 90 unmodified lines
14051413 _rig->clearJointStates();
14061414 _meshStates.clear();
14071415 _rig->deleteAnimations();
1416+ _rig->destroyAnimGraph();
14081417 _blendedBlendshapeCoefficients.clear();
14091418 }
14101419
@@ -1422,7 +1431,6 @@ AABox Model::getPartBounds(int meshIndex, int partIndex) { · 11 unmodified lines
14221431 return calculateScaledOffsetAABox(_geometry->getFBXGeometry().meshExtents);
14231432 }
14241433 }
1425−
14261434 if (_geometry->getFBXGeometry().meshes.size() > meshIndex) {
14271435
14281436 // FIX ME! - This is currently a hack because for some mesh parts our efforts to calculate the bounding
@@ -1486,6 +1494,8 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, int shape · 57 unmodified lines
14861494 return;
14871495 }
14881496
1497+ updateClusterMatrices();
1498+
14891499 const NetworkMesh& networkMesh = *(networkMeshes.at(meshIndex).get());
14901500 const FBXMesh& mesh = geometry.meshes.at(meshIndex);
14911501 const MeshState& state = _meshStates.at(meshIndex);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t