aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcharacter/llkeyframemotion.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llcharacter/llkeyframemotion.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/llcharacter/llkeyframemotion.cpp')
-rw-r--r--linden/indra/llcharacter/llkeyframemotion.cpp110
1 files changed, 94 insertions, 16 deletions
diff --git a/linden/indra/llcharacter/llkeyframemotion.cpp b/linden/indra/llcharacter/llkeyframemotion.cpp
index 212020b..46dee09 100644
--- a/linden/indra/llcharacter/llkeyframemotion.cpp
+++ b/linden/indra/llcharacter/llkeyframemotion.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -861,7 +862,7 @@ void LLKeyframeMotion::activateConstraint(JointConstraint* constraint)
861 S32 joint_num; 862 S32 joint_num;
862 863
863 // grab ground position if we need to 864 // grab ground position if we need to
864 if (shared_data->mConstraintTargetType == TYPE_GROUND) 865 if (shared_data->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
865 { 866 {
866 LLVector3 source_pos = mCharacter->getVolumePos(shared_data->mSourceConstraintVolume, shared_data->mSourceConstraintOffset); 867 LLVector3 source_pos = mCharacter->getVolumePos(shared_data->mSourceConstraintVolume, shared_data->mSourceConstraintOffset);
867 LLVector3 ground_pos_agent; 868 LLVector3 ground_pos_agent;
@@ -888,7 +889,7 @@ void LLKeyframeMotion::deactivateConstraint(JointConstraint *constraintp)
888 constraintp->mSourceVolume->mUpdateXform = FALSE; 889 constraintp->mSourceVolume->mUpdateXform = FALSE;
889 } 890 }
890 891
891 if (!constraintp->mSharedData->mConstraintTargetType == TYPE_GROUND) 892 if (!constraintp->mSharedData->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
892 { 893 {
893 if (constraintp->mTargetVolume) 894 if (constraintp->mTargetVolume)
894 { 895 {
@@ -958,11 +959,11 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
958 959
959 switch(shared_data->mConstraintTargetType) 960 switch(shared_data->mConstraintTargetType)
960 { 961 {
961 case TYPE_GROUND: 962 case CONSTRAINT_TARGET_TYPE_GROUND:
962 target_pos = mCharacter->getPosAgentFromGlobal(constraint->mGroundPos); 963 target_pos = mCharacter->getPosAgentFromGlobal(constraint->mGroundPos);
963// llinfos << "Target Pos " << constraint->mGroundPos << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << llendl; 964// llinfos << "Target Pos " << constraint->mGroundPos << " on " << mCharacter->findCollisionVolume(shared_data->mSourceConstraintVolume)->getName() << llendl;
964 break; 965 break;
965 case TYPE_BODY: 966 case CONSTRAINT_TARGET_TYPE_BODY:
966 target_pos = mCharacter->getVolumePos(shared_data->mTargetConstraintVolume, shared_data->mTargetConstraintOffset); 967 target_pos = mCharacter->getVolumePos(shared_data->mTargetConstraintVolume, shared_data->mTargetConstraintOffset);
967 break; 968 break;
968 default: 969 default:
@@ -973,14 +974,14 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
973 LLJoint *source_jointp = NULL; 974 LLJoint *source_jointp = NULL;
974 LLJoint *target_jointp = NULL; 975 LLJoint *target_jointp = NULL;
975 976
976 if (shared_data->mConstraintType == TYPE_PLANE) 977 if (shared_data->mConstraintType == CONSTRAINT_TYPE_PLANE)
977 { 978 {
978 switch(shared_data->mConstraintTargetType) 979 switch(shared_data->mConstraintTargetType)
979 { 980 {
980 case TYPE_GROUND: 981 case CONSTRAINT_TARGET_TYPE_GROUND:
981 norm = constraint->mGroundNorm; 982 norm = constraint->mGroundNorm;
982 break; 983 break;
983 case TYPE_BODY: 984 case CONSTRAINT_TARGET_TYPE_BODY:
984 target_jointp = mCharacter->findCollisionVolume(shared_data->mTargetConstraintVolume); 985 target_jointp = mCharacter->findCollisionVolume(shared_data->mTargetConstraintVolume);
985 if (target_jointp) 986 if (target_jointp)
986 { 987 {
@@ -1226,6 +1227,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1226 llwarns << "can't read duration" << llendl; 1227 llwarns << "can't read duration" << llendl;
1227 return FALSE; 1228 return FALSE;
1228 } 1229 }
1230
1231 if (mJointMotionList->mDuration > MAX_ANIM_DURATION )
1232 {
1233 llwarns << "invalid animation duration" << llendl;
1234 return FALSE;
1235 }
1229 1236
1230 //------------------------------------------------------------------------- 1237 //-------------------------------------------------------------------------
1231 // get emote (optional) 1238 // get emote (optional)
@@ -1281,6 +1288,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1281 llwarns << "can't read hand pose" << llendl; 1288 llwarns << "can't read hand pose" << llendl;
1282 return FALSE; 1289 return FALSE;
1283 } 1290 }
1291
1292 if(word > LLHandMotion::NUM_HAND_POSES)
1293 {
1294 llwarns << "invalid LLHandMotion::eHandPose index: " << word << llendl;
1295 return FALSE;
1296 }
1297
1284 mJointMotionList->mHandPose = (LLHandMotion::eHandPose)word; 1298 mJointMotionList->mHandPose = (LLHandMotion::eHandPose)word;
1285 1299
1286 //------------------------------------------------------------------------- 1300 //-------------------------------------------------------------------------
@@ -1324,7 +1338,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1324 llwarns << "can't read joint name" << llendl; 1338 llwarns << "can't read joint name" << llendl;
1325 return FALSE; 1339 return FALSE;
1326 } 1340 }
1327 1341
1342 if (joint_name == "mScreen" || joint_name == "mRoot")
1343 {
1344 llwarns << "attempted to animate special " << joint_name << " joint" << llendl;
1345 return FALSE;
1346 }
1347
1328 //--------------------------------------------------------------------- 1348 //---------------------------------------------------------------------
1329 // find the corresponding joint 1349 // find the corresponding joint
1330 //--------------------------------------------------------------------- 1350 //---------------------------------------------------------------------
@@ -1408,6 +1428,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1408 } 1428 }
1409 1429
1410 time = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration); 1430 time = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration);
1431
1432 if (time < 0 || time > mJointMotionList->mDuration)
1433 {
1434 llwarns << "invalid frame time" << llendl;
1435 return FALSE;
1436 }
1411 } 1437 }
1412 1438
1413 RotationKey rot_key; 1439 RotationKey rot_key;
@@ -1437,6 +1463,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1437 rot_key.mRotation.unpackFromVector3(rot_vec); 1463 rot_key.mRotation.unpackFromVector3(rot_vec);
1438 } 1464 }
1439 1465
1466 if( !(rot_key.mRotation.isFinite()) )
1467 {
1468 llwarns << "non-finite angle in rotation key" << llendl;
1469 success = FALSE;
1470 }
1471
1440 if (!success) 1472 if (!success)
1441 { 1473 {
1442 llwarns << "can't read rotation key (" << k << ")" << llendl; 1474 llwarns << "can't read rotation key (" << k << ")" << llendl;
@@ -1508,7 +1540,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1508 pos_key.mPosition.mV[VY] = U16_to_F32(y, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); 1540 pos_key.mPosition.mV[VY] = U16_to_F32(y, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET);
1509 pos_key.mPosition.mV[VZ] = U16_to_F32(z, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); 1541 pos_key.mPosition.mV[VZ] = U16_to_F32(z, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET);
1510 } 1542 }
1511 1543
1544 if( !(pos_key.mPosition.isFinite()) )
1545 {
1546 llwarns << "non-finite position in key" << llendl;
1547 success = FALSE;
1548 }
1549
1512 if (!success) 1550 if (!success)
1513 { 1551 {
1514 llwarns << "can't read position key (" << k << ")" << llendl; 1552 llwarns << "can't read position key (" << k << ")" << llendl;
@@ -1538,7 +1576,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1538 1576
1539 if (num_constraints > MAX_CONSTRAINTS) 1577 if (num_constraints > MAX_CONSTRAINTS)
1540 { 1578 {
1541 llwarns << "Too many constraints...ignoring" << llendl; 1579 llwarns << "Too many constraints... ignoring" << llendl;
1542 } 1580 }
1543 else 1581 else
1544 { 1582 {
@@ -1560,12 +1598,26 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1560 } 1598 }
1561 constraintp->mChainLength = (S32) byte; 1599 constraintp->mChainLength = (S32) byte;
1562 1600
1601 if((U32)constraintp->mChainLength > mJointMotionList->getNumJointMotions())
1602 {
1603 llwarns << "invalid constraint chain length" << llendl;
1604 delete constraintp;
1605 return FALSE;
1606 }
1607
1563 if (!dp.unpackU8(byte, "constraint_type")) 1608 if (!dp.unpackU8(byte, "constraint_type"))
1564 { 1609 {
1565 llwarns << "can't read constraint type" << llendl; 1610 llwarns << "can't read constraint type" << llendl;
1566 delete constraintp; 1611 delete constraintp;
1567 return FALSE; 1612 return FALSE;
1568 } 1613 }
1614
1615 if( byte >= NUM_CONSTRAINT_TYPES )
1616 {
1617 llwarns << "invalid constraint type" << llendl;
1618 delete constraintp;
1619 return FALSE;
1620 }
1569 constraintp->mConstraintType = (EConstraintType)byte; 1621 constraintp->mConstraintType = (EConstraintType)byte;
1570 1622
1571 const S32 BIN_DATA_LENGTH = 16; 1623 const S32 BIN_DATA_LENGTH = 16;
@@ -1587,7 +1639,14 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1587 delete constraintp; 1639 delete constraintp;
1588 return FALSE; 1640 return FALSE;
1589 } 1641 }
1590 1642
1643 if( !(constraintp->mSourceConstraintOffset.isFinite()) )
1644 {
1645 llwarns << "non-finite constraint source offset" << llendl;
1646 delete constraintp;
1647 return FALSE;
1648 }
1649
1591 if (!dp.unpackBinaryDataFixed(bin_data, BIN_DATA_LENGTH, "target_volume")) 1650 if (!dp.unpackBinaryDataFixed(bin_data, BIN_DATA_LENGTH, "target_volume"))
1592 { 1651 {
1593 llwarns << "can't read target volume name" << llendl; 1652 llwarns << "can't read target volume name" << llendl;
@@ -1600,11 +1659,11 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1600 if (str == "GROUND") 1659 if (str == "GROUND")
1601 { 1660 {
1602 // constrain to ground 1661 // constrain to ground
1603 constraintp->mConstraintTargetType = TYPE_GROUND; 1662 constraintp->mConstraintTargetType = CONSTRAINT_TARGET_TYPE_GROUND;
1604 } 1663 }
1605 else 1664 else
1606 { 1665 {
1607 constraintp->mConstraintTargetType = TYPE_BODY; 1666 constraintp->mConstraintTargetType = CONSTRAINT_TARGET_TYPE_BODY;
1608 constraintp->mTargetConstraintVolume = mCharacter->getCollisionVolumeID(str); 1667 constraintp->mTargetConstraintVolume = mCharacter->getCollisionVolumeID(str);
1609 } 1668 }
1610 1669
@@ -1615,6 +1674,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1615 return FALSE; 1674 return FALSE;
1616 } 1675 }
1617 1676
1677 if( !(constraintp->mTargetConstraintOffset.isFinite()) )
1678 {
1679 llwarns << "non-finite constraint target offset" << llendl;
1680 delete constraintp;
1681 return FALSE;
1682 }
1683
1618 if (!dp.unpackVector3(constraintp->mTargetConstraintDir, "target_dir")) 1684 if (!dp.unpackVector3(constraintp->mTargetConstraintDir, "target_dir"))
1619 { 1685 {
1620 llwarns << "can't read constraint target direction" << llendl; 1686 llwarns << "can't read constraint target direction" << llendl;
@@ -1622,6 +1688,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1622 return FALSE; 1688 return FALSE;
1623 } 1689 }
1624 1690
1691 if( !(constraintp->mTargetConstraintDir.isFinite()) )
1692 {
1693 llwarns << "non-finite constraint target direction" << llendl;
1694 delete constraintp;
1695 return FALSE;
1696 }
1697
1625 if (!constraintp->mTargetConstraintDir.isExactlyZero()) 1698 if (!constraintp->mTargetConstraintDir.isExactlyZero())
1626 { 1699 {
1627 constraintp->mUseTargetOffset = TRUE; 1700 constraintp->mUseTargetOffset = TRUE;
@@ -1685,8 +1758,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
1685 break; 1758 break;
1686 } 1759 }
1687 } 1760 }
1761 if (constraintp->mJointStateIndices[i] < 0 )
1762 {
1763 llwarns << "No joint index for constraint " << i << llendl;
1764 delete constraintp;
1765 return FALSE;
1766 }
1688 } 1767 }
1689
1690 } 1768 }
1691 } 1769 }
1692 1770
@@ -1776,7 +1854,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
1776 mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str()); 1854 mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str());
1777 success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "source_volume"); 1855 success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "source_volume");
1778 success &= dp.packVector3(shared_constraintp->mSourceConstraintOffset, "source_offset"); 1856 success &= dp.packVector3(shared_constraintp->mSourceConstraintOffset, "source_offset");
1779 if (shared_constraintp->mConstraintTargetType == TYPE_GROUND) 1857 if (shared_constraintp->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
1780 { 1858 {
1781 snprintf(volume_name,sizeof(volume_name), "%s", "GROUND"); /* Flawfinder: ignore */ 1859 snprintf(volume_name,sizeof(volume_name), "%s", "GROUND"); /* Flawfinder: ignore */
1782 } 1860 }