diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llcharacter/llkeyframemotion.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/llcharacter/llkeyframemotion.cpp')
-rw-r--r-- | linden/indra/llcharacter/llkeyframemotion.cpp | 127 |
1 files changed, 81 insertions, 46 deletions
diff --git a/linden/indra/llcharacter/llkeyframemotion.cpp b/linden/indra/llcharacter/llkeyframemotion.cpp index d09de0e..94e45b6 100644 --- a/linden/indra/llcharacter/llkeyframemotion.cpp +++ b/linden/indra/llcharacter/llkeyframemotion.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | 5 | * Copyright (c) 2001-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -48,7 +49,7 @@ | |||
48 | // Static Definitions | 49 | // Static Definitions |
49 | //----------------------------------------------------------------------------- | 50 | //----------------------------------------------------------------------------- |
50 | LLVFS* LLKeyframeMotion::sVFS = NULL; | 51 | LLVFS* LLKeyframeMotion::sVFS = NULL; |
51 | LLKeyframeDataCache::LLKeyframeDataMap LLKeyframeDataCache::sKeyframeDataMap; | 52 | LLKeyframeDataCache::keyframe_data_map_t LLKeyframeDataCache::sKeyframeDataMap; |
52 | 53 | ||
53 | //----------------------------------------------------------------------------- | 54 | //----------------------------------------------------------------------------- |
54 | // Globals | 55 | // Globals |
@@ -64,8 +65,20 @@ static F32 MIN_ACCELERATION_SQUARED = 0.0005f * 0.0005f; | |||
64 | static F32 MAX_CONSTRAINTS = 10; | 65 | static F32 MAX_CONSTRAINTS = 10; |
65 | 66 | ||
66 | //----------------------------------------------------------------------------- | 67 | //----------------------------------------------------------------------------- |
67 | // JointMotionList::dumpDiagInfo() | 68 | // JointMotionList |
68 | //----------------------------------------------------------------------------- | 69 | //----------------------------------------------------------------------------- |
70 | LLKeyframeMotion::JointMotionList::JointMotionList() | ||
71 | : mNumJointMotions(0), | ||
72 | mJointMotionArray(NULL) | ||
73 | { | ||
74 | } | ||
75 | |||
76 | LLKeyframeMotion::JointMotionList::~JointMotionList() | ||
77 | { | ||
78 | for_each(mConstraints.begin(), mConstraints.end(), DeletePointer()); | ||
79 | delete [] mJointMotionArray; | ||
80 | } | ||
81 | |||
69 | U32 LLKeyframeMotion::JointMotionList::dumpDiagInfo() | 82 | U32 LLKeyframeMotion::JointMotionList::dumpDiagInfo() |
70 | { | 83 | { |
71 | S32 total_size = sizeof(JointMotionList); | 84 | S32 total_size = sizeof(JointMotionList); |
@@ -434,7 +447,7 @@ LLKeyframeMotion::~LLKeyframeMotion() | |||
434 | { | 447 | { |
435 | delete [] mJointStates; | 448 | delete [] mJointStates; |
436 | } | 449 | } |
437 | mConstraints.deleteAllData(); | 450 | for_each(mConstraints.begin(), mConstraints.end(), DeletePointer()); |
438 | } | 451 | } |
439 | 452 | ||
440 | //----------------------------------------------------------------------------- | 453 | //----------------------------------------------------------------------------- |
@@ -569,8 +582,7 @@ LLMotion::LLMotionInitStatus LLKeyframeMotion::onInitialize(LLCharacter *charact | |||
569 | BOOL LLKeyframeMotion::setupPose() | 582 | BOOL LLKeyframeMotion::setupPose() |
570 | { | 583 | { |
571 | // add all valid joint states to the pose | 584 | // add all valid joint states to the pose |
572 | U32 jm; | 585 | for (U32 jm=0; jm<mJointMotionList->mNumJointMotions; jm++) |
573 | for (jm=0; jm<mJointMotionList->mNumJointMotions; jm++) | ||
574 | { | 586 | { |
575 | if ( mJointStates[jm].getJoint() ) | 587 | if ( mJointStates[jm].getJoint() ) |
576 | { | 588 | { |
@@ -579,16 +591,16 @@ BOOL LLKeyframeMotion::setupPose() | |||
579 | } | 591 | } |
580 | 592 | ||
581 | // initialize joint constraints | 593 | // initialize joint constraints |
582 | for (JointConstraintSharedData* shared_constraintp = mJointMotionList->mConstraints.getFirstData(); | 594 | for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin(); |
583 | shared_constraintp; | 595 | iter != mJointMotionList->mConstraints.end(); ++iter) |
584 | shared_constraintp = mJointMotionList->mConstraints.getNextData()) | 596 | { |
585 | { | 597 | JointConstraintSharedData* shared_constraintp = *iter; |
586 | JointConstraint* constraintp = new JointConstraint(shared_constraintp); | 598 | JointConstraint* constraintp = new JointConstraint(shared_constraintp); |
587 | initializeConstraint(constraintp); | 599 | initializeConstraint(constraintp); |
588 | mConstraints.addData(constraintp); | 600 | mConstraints.push_front(constraintp); |
589 | } | 601 | } |
590 | 602 | ||
591 | if (mJointMotionList->mConstraints.getLength()) | 603 | if (mJointMotionList->mConstraints.size()) |
592 | { | 604 | { |
593 | mPelvisp = mCharacter->getJoint("mPelvis"); | 605 | mPelvisp = mCharacter->getJoint("mPelvis"); |
594 | if (!mPelvisp) | 606 | if (!mPelvisp) |
@@ -711,21 +723,21 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask) | |||
711 | if (mCharacter->getSkeletonSerialNum() != mLastSkeletonSerialNum) | 723 | if (mCharacter->getSkeletonSerialNum() != mLastSkeletonSerialNum) |
712 | { | 724 | { |
713 | mLastSkeletonSerialNum = mCharacter->getSkeletonSerialNum(); | 725 | mLastSkeletonSerialNum = mCharacter->getSkeletonSerialNum(); |
714 | for (JointConstraint* constraintp = mConstraints.getFirstData(); | 726 | for (constraint_list_t::iterator iter = mConstraints.begin(); |
715 | constraintp; | 727 | iter != mConstraints.end(); ++iter) |
716 | constraintp = mConstraints.getNextData()) | 728 | { |
717 | { | 729 | JointConstraint* constraintp = *iter; |
718 | initializeConstraint(constraintp); | 730 | initializeConstraint(constraintp); |
719 | } | 731 | } |
720 | } | 732 | } |
721 | 733 | ||
722 | // apply constraints | 734 | // apply constraints |
723 | for (JointConstraint* constraintp = mConstraints.getFirstData(); | 735 | for (constraint_list_t::iterator iter = mConstraints.begin(); |
724 | constraintp; | 736 | iter != mConstraints.end(); ++iter) |
725 | constraintp = mConstraints.getNextData()) | 737 | { |
726 | { | 738 | JointConstraint* constraintp = *iter; |
727 | applyConstraint(constraintp, time, joint_mask); | 739 | applyConstraint(constraintp, time, joint_mask); |
728 | } | 740 | } |
729 | } | 741 | } |
730 | 742 | ||
731 | //----------------------------------------------------------------------------- | 743 | //----------------------------------------------------------------------------- |
@@ -733,12 +745,12 @@ void LLKeyframeMotion::applyConstraints(F32 time, U8* joint_mask) | |||
733 | //----------------------------------------------------------------------------- | 745 | //----------------------------------------------------------------------------- |
734 | void LLKeyframeMotion::onDeactivate() | 746 | void LLKeyframeMotion::onDeactivate() |
735 | { | 747 | { |
736 | for (JointConstraint* constraintp = mConstraints.getFirstData(); | 748 | for (constraint_list_t::iterator iter = mConstraints.begin(); |
737 | constraintp; | 749 | iter != mConstraints.end(); ++iter) |
738 | constraintp = mConstraints.getNextData()) | 750 | { |
739 | { | 751 | JointConstraint* constraintp = *iter; |
740 | deactivateConstraint(constraintp); | 752 | deactivateConstraint(constraintp); |
741 | } | 753 | } |
742 | } | 754 | } |
743 | 755 | ||
744 | //----------------------------------------------------------------------------- | 756 | //----------------------------------------------------------------------------- |
@@ -1605,7 +1617,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) | |||
1605 | return FALSE; | 1617 | return FALSE; |
1606 | } | 1618 | } |
1607 | 1619 | ||
1608 | mJointMotionList->mConstraints.addData(constraintp); | 1620 | mJointMotionList->mConstraints.push_front(constraintp); |
1609 | 1621 | ||
1610 | constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; | 1622 | constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; |
1611 | 1623 | ||
@@ -1713,10 +1725,19 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const | |||
1713 | } | 1725 | } |
1714 | } | 1726 | } |
1715 | 1727 | ||
1716 | success &= dp.packS32(mJointMotionList->mConstraints.getLength(), "num_constraints"); | 1728 | success &= dp.packS32(mJointMotionList->mConstraints.size(), "num_constraints"); |
1717 | for (JointConstraintSharedData* shared_constraintp = mJointMotionList->mConstraints.getFirstData(); | 1729 | for (JointMotionList::constraint_list_t::iterator iter = mJointMotionList->mConstraints.begin(); |
1718 | shared_constraintp; | 1730 | iter != mJointMotionList->mConstraints.end(); ++iter) |
1719 | shared_constraintp = mJointMotionList->mConstraints.getNextData()) | 1731 | { |
1732 | JointConstraintSharedData* shared_constraintp = *iter; | ||
1733 | success &= dp.packU8(shared_constraintp->mChainLength, "chain_length"); | ||
1734 | success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type"); | ||
1735 | char volume_name[16]; /* Flawfinder: ignore */ | ||
1736 | snprintf(volume_name, sizeof(volume_name), "%s", /* Flawfinder: ignore */ | ||
1737 | mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str()); | ||
1738 | success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "source_volume"); | ||
1739 | success &= dp.packVector3(shared_constraintp->mSourceConstraintOffset, "source_offset"); | ||
1740 | if (shared_constraintp->mConstraintTargetType == TYPE_GROUND) | ||
1720 | { | 1741 | { |
1721 | success &= dp.packU8(shared_constraintp->mChainLength, "chain_length"); | 1742 | success &= dp.packU8(shared_constraintp->mChainLength, "chain_length"); |
1722 | success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type"); | 1743 | success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type"); |
@@ -1731,7 +1752,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const | |||
1731 | } | 1752 | } |
1732 | else | 1753 | else |
1733 | { | 1754 | { |
1734 | snprintf(volume_name, sizeof(volume_name),"%s", /* Flawfinder: ignore */ | 1755 | snprintf(volume_name, sizeof(volume_name),"%s", /* Flawfinder: ignore */ |
1735 | mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str()); | 1756 | mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str()); |
1736 | } | 1757 | } |
1737 | success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "target_volume"); | 1758 | success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "target_volume"); |
@@ -1742,6 +1763,19 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const | |||
1742 | success &= dp.packF32(shared_constraintp->mEaseOutStartTime, "ease_out_start"); | 1763 | success &= dp.packF32(shared_constraintp->mEaseOutStartTime, "ease_out_start"); |
1743 | success &= dp.packF32(shared_constraintp->mEaseOutStopTime, "ease_out_stop"); | 1764 | success &= dp.packF32(shared_constraintp->mEaseOutStopTime, "ease_out_stop"); |
1744 | } | 1765 | } |
1766 | else | ||
1767 | { | ||
1768 | snprintf(volume_name, sizeof(volume_name),"%s", /* Flawfinder: ignore */ | ||
1769 | mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str()); | ||
1770 | } | ||
1771 | success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "target_volume"); | ||
1772 | success &= dp.packVector3(shared_constraintp->mTargetConstraintOffset, "target_offset"); | ||
1773 | success &= dp.packVector3(shared_constraintp->mTargetConstraintDir, "target_dir"); | ||
1774 | success &= dp.packF32(shared_constraintp->mEaseInStartTime, "ease_in_start"); | ||
1775 | success &= dp.packF32(shared_constraintp->mEaseInStopTime, "ease_in_stop"); | ||
1776 | success &= dp.packF32(shared_constraintp->mEaseOutStartTime, "ease_out_start"); | ||
1777 | success &= dp.packF32(shared_constraintp->mEaseOutStopTime, "ease_out_stop"); | ||
1778 | } | ||
1745 | 1779 | ||
1746 | return success; | 1780 | return success; |
1747 | } | 1781 | } |
@@ -1832,7 +1866,8 @@ void LLKeyframeMotion::setEaseOut(F32 ease_in) | |||
1832 | //----------------------------------------------------------------------------- | 1866 | //----------------------------------------------------------------------------- |
1833 | void LLKeyframeMotion::flushKeyframeCache() | 1867 | void LLKeyframeMotion::flushKeyframeCache() |
1834 | { | 1868 | { |
1835 | LLKeyframeDataCache::clear(); | 1869 | // TODO: Make this safe to do |
1870 | // LLKeyframeDataCache::clear(); | ||
1836 | } | 1871 | } |
1837 | 1872 | ||
1838 | //----------------------------------------------------------------------------- | 1873 | //----------------------------------------------------------------------------- |
@@ -2041,8 +2076,8 @@ void LLKeyframeDataCache::dumpDiagInfo() | |||
2041 | llinfos << "-----------------------------------------------------" << llendl; | 2076 | llinfos << "-----------------------------------------------------" << llendl; |
2042 | 2077 | ||
2043 | // print each loaded mesh, and it's memory usage | 2078 | // print each loaded mesh, and it's memory usage |
2044 | LLKeyframeDataMap::iterator map_it; | 2079 | for (keyframe_data_map_t::iterator map_it = sKeyframeDataMap.begin(); |
2045 | for (map_it = sKeyframeDataMap.begin(); map_it != sKeyframeDataMap.end(); ++map_it) | 2080 | map_it != sKeyframeDataMap.end(); ++map_it) |
2046 | { | 2081 | { |
2047 | U32 joint_motion_kb; | 2082 | U32 joint_motion_kb; |
2048 | 2083 | ||
@@ -2076,12 +2111,12 @@ void LLKeyframeDataCache::addKeyframeData(const LLUUID& id, LLKeyframeMotion::Jo | |||
2076 | //-------------------------------------------------------------------- | 2111 | //-------------------------------------------------------------------- |
2077 | void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id) | 2112 | void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id) |
2078 | { | 2113 | { |
2079 | LLKeyframeMotion::JointMotionList* joint_motion_listp = getKeyframeData(id); | 2114 | keyframe_data_map_t::iterator found_data = sKeyframeDataMap.find(id); |
2080 | if (joint_motion_listp) | 2115 | if (found_data != sKeyframeDataMap.end()) |
2081 | { | 2116 | { |
2082 | delete joint_motion_listp; | 2117 | delete found_data->second; |
2118 | sKeyframeDataMap.erase(found_data); | ||
2083 | } | 2119 | } |
2084 | sKeyframeDataMap.erase(id); | ||
2085 | } | 2120 | } |
2086 | 2121 | ||
2087 | //-------------------------------------------------------------------- | 2122 | //-------------------------------------------------------------------- |
@@ -2089,7 +2124,7 @@ void LLKeyframeDataCache::removeKeyframeData(const LLUUID& id) | |||
2089 | //-------------------------------------------------------------------- | 2124 | //-------------------------------------------------------------------- |
2090 | LLKeyframeMotion::JointMotionList* LLKeyframeDataCache::getKeyframeData(const LLUUID& id) | 2125 | LLKeyframeMotion::JointMotionList* LLKeyframeDataCache::getKeyframeData(const LLUUID& id) |
2091 | { | 2126 | { |
2092 | LLKeyframeDataMap::iterator found_data = sKeyframeDataMap.find(id); | 2127 | keyframe_data_map_t::iterator found_data = sKeyframeDataMap.find(id); |
2093 | if (found_data == sKeyframeDataMap.end()) | 2128 | if (found_data == sKeyframeDataMap.end()) |
2094 | { | 2129 | { |
2095 | return NULL; | 2130 | return NULL; |