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
60 60
61Model::Model(RigPointer rig, QObject* parent) :61Model::Model(RigPointer rig, QObject* parent) :
62 QObject(parent),62 QObject(parent),
63 _translation(0.0f),
64 _rotation(),
63 _scale(1.0f, 1.0f, 1.0f),65 _scale(1.0f, 1.0f, 1.0f),
64 _scaleToFit(false),66 _scaleToFit(false),
65 _scaleToFitDimensions(0.0f),67 _scaleToFitDimensions(0.0f),
@@ -70,7 +72,6 @@ Model::Model(RigPointer rig, QObject* parent) : · 4 unmodified lines
70 _cauterizeBones(false),72 _cauterizeBones(false),
71 _pupilDilation(0.0f),73 _pupilDilation(0.0f),
72 _url(HTTP_INVALID_COM),74 _url(HTTP_INVALID_COM),
73 _urlAsString(HTTP_INVALID_COM),
74 _isVisible(true),75 _isVisible(true),
75 _blendNumber(0),76 _blendNumber(0),
76 _appliedBlendNumber(0),77 _appliedBlendNumber(0),
@@ -195,6 +196,13 @@ void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model: · 118 unmodified lines
195 196
196AbstractViewStateInterface* Model::_viewState = NULL;197AbstractViewStateInterface* Model::_viewState = NULL;
197 198
199void Model::setTranslation(const glm::vec3& translation) {
200 _translation = translation;
201}
202
203void Model::setRotation(const glm::quat& rotation) {
204 _rotation = rotation;
205}
198 206
199void Model::setScale(const glm::vec3& scale) {207void Model::setScale(const glm::vec3& scale) {
200 setScaleInternal(scale);208 setScaleInternal(scale);
@@ -433,14 +441,14 @@ void Model::initJointStates(QVector<JointState> states) { · 232 unmodified lines
433 int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1;441 int rightElbowJointIndex = rightHandJointIndex >= 0 ? geometry.joints.at(rightHandJointIndex).parentIndex : -1;
434 int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1;442 int rightShoulderJointIndex = rightElbowJointIndex >= 0 ? geometry.joints.at(rightElbowJointIndex).parentIndex : -1;
435 443
436 _boundingRadius = _rig->initJointStates(states, parentTransform,444 _rig->initJointStates(states, parentTransform,
437 rootJointIndex,445 rootJointIndex,
438 leftHandJointIndex,446 leftHandJointIndex,
439 leftElbowJointIndex,447 leftElbowJointIndex,
440 leftShoulderJointIndex,448 leftShoulderJointIndex,
441 rightHandJointIndex,449 rightHandJointIndex,
442 rightElbowJointIndex,450 rightElbowJointIndex,
443 rightShoulderJointIndex);451 rightShoulderJointIndex);
444}452}
445 453
446bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const glm::vec3& direction, float& distance,454bool 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
1023}1031}
1024 1032
1025void Model::setURL(const QUrl& url) {1033void Model::setURL(const QUrl& url) {
1026
1027 // don't recreate the geometry if it's the same URL1034 // don't recreate the geometry if it's the same URL
1028 if (_url == url && _geometry && _geometry->getURL() == url) {1035 if (_url == url && _geometry && _geometry->getURL() == url) {
1029 return;1036 return;
1030 }1037 }
1031 1038
1032 _url = url;1039 _url = url;
1033 _urlAsString = _url.toString();
1034 1040
1035 {1041 {
1036 render::PendingChanges pendingChanges;1042 render::PendingChanges pendingChanges;
@@ -1280,7 +1286,9 @@ void Model::simulateInternal(float deltaTime) { · 243 unmodified lines
1280 const FBXGeometry& geometry = _geometry->getFBXGeometry();1286 const FBXGeometry& geometry = _geometry->getFBXGeometry();
1281 glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;1287 glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
1282 updateRig(deltaTime, parentTransform);1288 updateRig(deltaTime, parentTransform);
1283 1289}
1290void Model::updateClusterMatrices() {
1291 const FBXGeometry& geometry = _geometry->getFBXGeometry();
1284 glm::mat4 zeroScale(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),1292 glm::mat4 zeroScale(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),
1285 glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),1293 glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),
1286 glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),1294 glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1294,7 +1302,7 @@ void Model::simulateInternal(float deltaTime) { · 7 unmodified lines
1294 if (_showTrueJointTransforms) {1302 if (_showTrueJointTransforms) {
1295 for (int j = 0; j < mesh.clusters.size(); j++) {1303 for (int j = 0; j < mesh.clusters.size(); j++) {
1296 const FBXCluster& cluster = mesh.clusters.at(j);1304 const FBXCluster& cluster = mesh.clusters.at(j);
1297 auto jointMatrix =_rig->getJointTransform(cluster.jointIndex);1305 auto jointMatrix = _rig->getJointTransform(cluster.jointIndex);
1298 state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix;1306 state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix;
1299 1307
1300 // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty.1308 // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty.
@@ -1308,7 +1316,7 @@ void Model::simulateInternal(float deltaTime) { · 7 unmodified lines
1308 } else {1316 } else {
1309 for (int j = 0; j < mesh.clusters.size(); j++) {1317 for (int j = 0; j < mesh.clusters.size(); j++) {
1310 const FBXCluster& cluster = mesh.clusters.at(j);1318 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
1312 state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix;1320 state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix;
1313 1321
1314 // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty.1322 // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty.
@@ -1405,6 +1413,7 @@ void Model::deleteGeometry() { · 90 unmodified lines
1405 _rig->clearJointStates();1413 _rig->clearJointStates();
1406 _meshStates.clear();1414 _meshStates.clear();
1407 _rig->deleteAnimations();1415 _rig->deleteAnimations();
1416 _rig->destroyAnimGraph();
1408 _blendedBlendshapeCoefficients.clear();1417 _blendedBlendshapeCoefficients.clear();
1409}1418}
1410 1419
@@ -1422,7 +1431,6 @@ AABox Model::getPartBounds(int meshIndex, int partIndex) { · 11 unmodified lines
1422 return calculateScaledOffsetAABox(_geometry->getFBXGeometry().meshExtents);1431 return calculateScaledOffsetAABox(_geometry->getFBXGeometry().meshExtents);
1423 }1432 }
1424 }1433 }
1425
1426 if (_geometry->getFBXGeometry().meshes.size() > meshIndex) {1434 if (_geometry->getFBXGeometry().meshes.size() > meshIndex) {
1427 1435
1428 // FIX ME! - This is currently a hack because for some mesh parts our efforts to calculate the bounding1436 // 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
1486 return;1494 return;
1487 }1495 }
1488 1496
1497 updateClusterMatrices();
1498
1489 const NetworkMesh& networkMesh = *(networkMeshes.at(meshIndex).get());1499 const NetworkMesh& networkMesh = *(networkMeshes.at(meshIndex).get());
1490 const FBXMesh& mesh = geometry.meshes.at(meshIndex);1500 const FBXMesh& mesh = geometry.meshes.at(meshIndex);
1491 const MeshState& state = _meshStates.at(meshIndex);1501 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