SL-111 WIP - animation dumping/logging

master
Brad Payne (Vir Linden) 2015-05-16 08:18:19 -04:00
parent 82aec2a8ef
commit e8a196f5ff
5 changed files with 111 additions and 9 deletions

View File

@ -1868,6 +1868,8 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
{
BOOL success = TRUE;
LL_DEBUGS("BVH") << "serializing" << LL_ENDL;
success &= dp.packU16(KEYFRAME_MOTION_VERSION, "version");
success &= dp.packU16(KEYFRAME_MOTION_SUBVERSION, "sub_version");
success &= dp.packS32(mJointMotionList->mBasePriority, "base_priority");
@ -1881,7 +1883,18 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
success &= dp.packU32(mJointMotionList->mHandPose, "hand_pose");
success &= dp.packU32(mJointMotionList->getNumJointMotions(), "num_joints");
LL_DEBUGS("BVH") << "bvh" << LL_ENDL;
LL_DEBUGS("BVH") << "version " << KEYFRAME_MOTION_VERSION << LL_ENDL;
LL_DEBUGS("BVH") << "sub_version " << KEYFRAME_MOTION_SUBVERSION << LL_ENDL;
LL_DEBUGS("BVH") << "base_priority " << mJointMotionList->mBasePriority << LL_ENDL;
LL_DEBUGS("BVH") << "duration " << mJointMotionList->mDuration << LL_ENDL;
LL_DEBUGS("BVH") << "emote_name " << mJointMotionList->mEmoteName << LL_ENDL;
LL_DEBUGS("BVH") << "loop_in_point " << mJointMotionList->mLoopInPoint << LL_ENDL;
LL_DEBUGS("BVH") << "loop_out_point " << mJointMotionList->mLoopOutPoint << LL_ENDL;
LL_DEBUGS("BVH") << "loop " << mJointMotionList->mLoop << LL_ENDL;
LL_DEBUGS("BVH") << "ease_in_duration " << mJointMotionList->mEaseInDuration << LL_ENDL;
LL_DEBUGS("BVH") << "ease_out_duration " << mJointMotionList->mEaseOutDuration << LL_ENDL;
LL_DEBUGS("BVH") << "hand_pose " << mJointMotionList->mHandPose << LL_ENDL;
LL_DEBUGS("BVH") << "num_joints " << mJointMotionList->getNumJointMotions() << LL_ENDL;
for (U32 i = 0; i < mJointMotionList->getNumJointMotions(); i++)
{
@ -1909,7 +1922,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
success &= dp.packU16(y, "rot_angle_y");
success &= dp.packU16(z, "rot_angle_z");
LL_DEBUGS("BVH") << " rot " << rot_key.mTime << " - " <<rot_angles.mV[VX] <<","<< rot_angles.mV[VY] <<","<< rot_angles.mV[VZ] << LL_ENDL;
LL_DEBUGS("BVH") << " rot: t " << rot_key.mTime << " angles " << rot_angles.mV[VX] <<","<< rot_angles.mV[VY] <<","<< rot_angles.mV[VZ] << LL_ENDL;
}
success &= dp.packS32(joint_motionp->mPositionCurve.mNumKeys, "num_pos_keys");
@ -1929,38 +1942,53 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
success &= dp.packU16(y, "pos_y");
success &= dp.packU16(z, "pos_z");
LL_DEBUGS("BVH") << " pos " << pos_key.mTime << pos_key.mPosition.mV[VX] <<","<< pos_key.mPosition.mV[VY] <<","<< pos_key.mPosition.mV[VZ] << LL_ENDL;
LL_DEBUGS("BVH") << " pos: t " << pos_key.mTime << " pos " << pos_key.mPosition.mV[VX] <<","<< pos_key.mPosition.mV[VY] <<","<< pos_key.mPosition.mV[VZ] << LL_ENDL;
}
}
success &= dp.packS32(mJointMotionList->mConstraints.size(), "num_constraints");
LL_DEBUGS("BVH") << "num_constraints " << mJointMotionList->mConstraints.size() << LL_ENDL;
for (JointMotionList::constraint_list_t::const_iterator iter = mJointMotionList->mConstraints.begin();
iter != mJointMotionList->mConstraints.end(); ++iter)
{
JointConstraintSharedData* shared_constraintp = *iter;
success &= dp.packU8(shared_constraintp->mChainLength, "chain_length");
success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type");
char volume_name[16]; /* Flawfinder: ignore */
snprintf(volume_name, sizeof(volume_name), "%s", /* Flawfinder: ignore */
char source_volume[16]; /* Flawfinder: ignore */
snprintf(source_volume, sizeof(source_volume), "%s", /* Flawfinder: ignore */
mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str());
success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "source_volume");
success &= dp.packBinaryDataFixed((U8*)source_volume, 16, "source_volume");
success &= dp.packVector3(shared_constraintp->mSourceConstraintOffset, "source_offset");
char target_volume[16]; /* Flawfinder: ignore */
if (shared_constraintp->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
{
snprintf(volume_name,sizeof(volume_name), "%s", "GROUND"); /* Flawfinder: ignore */
snprintf(target_volume,sizeof(target_volume), "%s", "GROUND"); /* Flawfinder: ignore */
}
else
{
snprintf(volume_name, sizeof(volume_name),"%s", /* Flawfinder: ignore */
snprintf(target_volume, sizeof(target_volume),"%s", /* Flawfinder: ignore */
mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str());
}
success &= dp.packBinaryDataFixed((U8*)volume_name, 16, "target_volume");
success &= dp.packBinaryDataFixed((U8*)target_volume, 16, "target_volume");
success &= dp.packVector3(shared_constraintp->mTargetConstraintOffset, "target_offset");
success &= dp.packVector3(shared_constraintp->mTargetConstraintDir, "target_dir");
success &= dp.packF32(shared_constraintp->mEaseInStartTime, "ease_in_start");
success &= dp.packF32(shared_constraintp->mEaseInStopTime, "ease_in_stop");
success &= dp.packF32(shared_constraintp->mEaseOutStartTime, "ease_out_start");
success &= dp.packF32(shared_constraintp->mEaseOutStopTime, "ease_out_stop");
LL_DEBUGS("BVH") << " chain_length " << shared_constraintp->mChainLength << LL_ENDL;
LL_DEBUGS("BVH") << " constraint_type " << (S32)shared_constraintp->mConstraintType << LL_ENDL;
LL_DEBUGS("BVH") << " source_volume " << source_volume << LL_ENDL;
LL_DEBUGS("BVH") << " source_offset " << shared_constraintp->mSourceConstraintOffset << LL_ENDL;
LL_DEBUGS("BVH") << " target_volume " << target_volume << LL_ENDL;
LL_DEBUGS("BVH") << " target_offset " << shared_constraintp->mTargetConstraintOffset << LL_ENDL;
LL_DEBUGS("BVH") << " target_dir " << shared_constraintp->mTargetConstraintDir << LL_ENDL;
LL_DEBUGS("BVH") << " ease_in_start " << shared_constraintp->mEaseInStartTime << LL_ENDL;
LL_DEBUGS("BVH") << " ease_in_stop " << shared_constraintp->mEaseInStopTime << LL_ENDL;
LL_DEBUGS("BVH") << " ease_out_start " << shared_constraintp->mEaseOutStartTime << LL_ENDL;
LL_DEBUGS("BVH") << " ease_out_stop " << shared_constraintp->mEaseOutStopTime << LL_ENDL;
}
return success;
@ -1978,6 +2006,52 @@ U32 LLKeyframeMotion::getFileSize()
return dp.getCurrentSize();
}
//-----------------------------------------------------------------------------
// FIXME BENTO TEMP
// dumpToFile()
//-----------------------------------------------------------------------------
void LLKeyframeMotion::dumpToFile(const std::string& name)
{
if (isLoaded())
{
std::string outfile_base;
if (!name.empty())
{
outfile_base = name;
}
else if (!getName().empty())
{
outfile_base = getName();
}
else
{
const LLUUID& id = getID();
outfile_base = id.asString();
}
std::string outfilename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,outfile_base + ".anim");
if (LLFile::isfile(outfilename))
{
return;
}
S32 file_size = getFileSize();
U8* buffer = new U8[file_size];
LL_DEBUGS("BVH") << "Dumping " << outfilename << LL_ENDL;
LLDataPackerBinaryBuffer dp(buffer, file_size);
if (serialize(dp))
{
LLAPRFile outfile;
outfile.open(outfilename, LL_APR_WPB);
if (outfile.getFileHandle())
{
outfile.write(buffer, file_size);
}
}
delete [] buffer;
}
}
//-----------------------------------------------------------------------------
// getPelvisBBox()
//-----------------------------------------------------------------------------
@ -2178,6 +2252,9 @@ void LLKeyframeMotion::onLoadComplete(LLVFS *vfs,
if (motionp->deserialize(dp))
{
motionp->mAssetStatus = ASSET_LOADED;
// FIXME BENTO TEMP
motionp->dumpToFile("");
}
else
{

View File

@ -153,6 +153,7 @@ public:
BOOL serialize(LLDataPacker& dp) const;
BOOL deserialize(LLDataPacker& dp);
BOOL isLoaded() { return mJointMotionList != NULL; }
void dumpToFile(const std::string& name);
// setters for modifying a keyframe animation

View File

@ -377,6 +377,14 @@ LLMotion* LLMotionController::createMotion( const LLUUID &id )
case LLMotion::STATUS_SUCCESS:
// add motion to our list
mLoadedMotions.insert(motion);
// FIXME SO MUCH DUMP
{
LLKeyframeMotion *km = dynamic_cast<LLKeyframeMotion*>(motion);
if (km)
{
km->dumpToFile("");
}
}
break;
default:
LL_ERRS() << "Invalid initialization status" << LL_ENDL;
@ -780,6 +788,14 @@ void LLMotionController::updateLoadingMotions()
mLoadingMotions.erase(curiter);
// add motion to our loaded motion list
mLoadedMotions.insert(motionp);
// FIXME SO MUCH DUMP
{
LLKeyframeMotion *km = dynamic_cast<LLKeyframeMotion*>(motionp);
if (km)
{
km->dumpToFile("");
}
}
// this motion should be playing
if (!motionp->isStopped())
{

View File

@ -42,6 +42,7 @@
</array>
<key>tags</key>
<array>
<string>BVH</string>
<!-- sample entry for debugging specific items
<string>Avatar</string>
<string>Inventory</string>

View File

@ -37,6 +37,7 @@
#include "lllineeditor.h"
#include "lluictrlfactory.h"
#include "lluictrlfactory.h"
#include "lldatapacker.h"
extern LLAgent gAgent;
@ -109,6 +110,12 @@ void LLPreviewAnim::play(const LLSD& param)
}
else
{
// FIXME BENTO - TEMP HACK TO DUMP AS FILE
LLKeyframeMotion *motionp = dynamic_cast<LLKeyframeMotion*>(gAgentAvatarp->findMotion(itemID));
if (motionp && motionp->isLoaded())
{
motionp->dumpToFile(item->getName());
}
gAgentAvatarp->startMotion(item->getAssetUUID());
}