llcharacter merge
This commit is contained in:
@@ -35,10 +35,6 @@
|
||||
#include "llkeyframemotion.h"
|
||||
#include "llquantize.h"
|
||||
#include "llstl.h"
|
||||
#include "llapr.h"
|
||||
|
||||
|
||||
//using namespace std;
|
||||
|
||||
#define INCHES_TO_METERS 0.02540005f
|
||||
|
||||
@@ -219,9 +215,8 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
|
||||
//--------------------------------------------------------------------
|
||||
std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName);
|
||||
|
||||
LLAPRFile infile(path, LL_APR_R);
|
||||
apr_file_t *fp = infile.getFileHandle();
|
||||
if (!fp)
|
||||
llifstream infstream(path);
|
||||
if (!infstream.is_open())
|
||||
return E_ST_NO_XLT_FILE;
|
||||
|
||||
LL_INFOS() << "NOTE: Loading translation table: " << fileName << LL_ENDL;
|
||||
@@ -233,7 +228,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
|
||||
//--------------------------------------------------------------------
|
||||
// load header
|
||||
//--------------------------------------------------------------------
|
||||
if ( ! getLine(fp) )
|
||||
if ( ! getLine(infstream) )
|
||||
return E_ST_EOF;
|
||||
if ( strncmp(mLine, "Translations 1.0", 16) )
|
||||
return E_ST_NO_XLT_HEADER;
|
||||
@@ -243,7 +238,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
|
||||
//--------------------------------------------------------------------
|
||||
BOOL loadingGlobals = FALSE;
|
||||
Translation *trans = NULL;
|
||||
while ( getLine(fp) )
|
||||
while ( getLine(infstream) )
|
||||
{
|
||||
//----------------------------------------------------------------
|
||||
// check the 1st token on the line to determine if it's empty or a comment
|
||||
@@ -660,7 +655,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
|
||||
|
||||
}
|
||||
|
||||
infile.close() ;
|
||||
infstream.close() ;
|
||||
return E_ST_OK;
|
||||
}
|
||||
|
||||
@@ -1337,13 +1332,9 @@ void LLBVHLoader::reset()
|
||||
//------------------------------------------------------------------------
|
||||
// LLBVHLoader::getLine()
|
||||
//------------------------------------------------------------------------
|
||||
BOOL LLBVHLoader::getLine(apr_file_t* fp)
|
||||
BOOL LLBVHLoader::getLine(llifstream& stream)
|
||||
{
|
||||
if (apr_file_eof(fp) == APR_EOF)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if ( apr_file_gets(mLine, BVH_PARSER_LINE_SIZE, fp) == APR_SUCCESS)
|
||||
if (stream.getline(mLine, BVH_PARSER_LINE_SIZE))
|
||||
{
|
||||
mLineNumber++;
|
||||
return TRUE;
|
||||
|
||||
@@ -2,31 +2,25 @@
|
||||
* @file llbvhloader.h
|
||||
* @brief Translates a BVH files to LindenLabAnimation format.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2004&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2004-2009, Linden Research, Inc.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2004&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
||||
* to you under the terms of the GNU General Public License, version 2.0
|
||||
* ("GPL"), unless you have obtained a separate licensing agreement
|
||||
* ("Other License"), formally executed by you and Linden Lab. Terms of
|
||||
* the GPL can be found in doc/GPL-license.txt in this distribution, or
|
||||
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
||||
* online at
|
||||
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation;
|
||||
* version 2.1 of the License only.
|
||||
*
|
||||
* By copying, modifying or distributing this software, you acknowledge
|
||||
* that you have read and understood your obligations described above,
|
||||
* and agree to abide by those obligations.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
@@ -36,32 +30,11 @@
|
||||
#include "v3math.h"
|
||||
#include "m3math.h"
|
||||
#include "llmath.h"
|
||||
#include "llapr.h"
|
||||
#include "llbvhconsts.h"
|
||||
|
||||
const S32 BVH_PARSER_LINE_SIZE = 2048;
|
||||
class LLDataPacker;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// FileCloser
|
||||
//------------------------------------------------------------------------
|
||||
class FileCloser
|
||||
{
|
||||
public:
|
||||
FileCloser( apr_file_t *file )
|
||||
{
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
~FileCloser()
|
||||
{
|
||||
apr_file_close(mFile);
|
||||
}
|
||||
protected:
|
||||
apr_file_t* mFile;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Key
|
||||
//------------------------------------------------------------------------
|
||||
@@ -304,7 +277,7 @@ public:
|
||||
|
||||
protected:
|
||||
// Consumes one line of input from file.
|
||||
BOOL getLine(apr_file_t *fp);
|
||||
BOOL getLine(llifstream& stream);
|
||||
|
||||
// parser state
|
||||
char mLine[BVH_PARSER_LINE_SIZE]; /* Flawfinder: ignore */
|
||||
|
||||
@@ -225,6 +225,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask)
|
||||
LL_CONT << "NULL";
|
||||
}
|
||||
LL_CONT << LL_ENDL;
|
||||
target.setVec(1.f, 1.f, 1.f);
|
||||
}
|
||||
|
||||
mTarget.setPosition( target + mParentJoint.getPosition());
|
||||
|
||||
@@ -70,22 +70,18 @@ protected:
|
||||
public:
|
||||
// Constructor
|
||||
LLJointState()
|
||||
{
|
||||
mUsage = 0;
|
||||
mJoint = NULL;
|
||||
mUsage = 0;
|
||||
mWeight = 0.f;
|
||||
mPriority = LLJoint::USE_MOTION_PRIORITY;
|
||||
}
|
||||
: mUsage(0)
|
||||
, mJoint(NULL)
|
||||
, mWeight(0.f)
|
||||
, mPriority(LLJoint::USE_MOTION_PRIORITY)
|
||||
{}
|
||||
|
||||
LLJointState(LLJoint* joint)
|
||||
{
|
||||
mUsage = 0;
|
||||
mJoint = joint;
|
||||
mUsage = 0;
|
||||
mWeight = 0.f;
|
||||
mPriority = LLJoint::USE_MOTION_PRIORITY;
|
||||
}
|
||||
: mUsage(0)
|
||||
, mJoint(joint)
|
||||
, mWeight(0.f)
|
||||
, mPriority(LLJoint::USE_MOTION_PRIORITY)
|
||||
{}
|
||||
|
||||
// joint that this state is applied to
|
||||
LLJoint* getJoint() { return mJoint; }
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "llvfile.h"
|
||||
#include "m3math.h"
|
||||
#include "message.h"
|
||||
#include <memory>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Static Definitions
|
||||
@@ -700,7 +701,8 @@ BOOL LLKeyframeMotion::onActivate()
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL LLKeyframeMotion::onUpdate(F32 time, U8* joint_mask)
|
||||
{
|
||||
llassert(time >= 0.f);
|
||||
// llassert(time >= 0.f); // This will fire
|
||||
time = llmax(0.f, time);
|
||||
|
||||
if (mJointMotionList->mLoop)
|
||||
{
|
||||
@@ -965,7 +967,7 @@ void LLKeyframeMotion::deactivateConstraint(JointConstraint *constraintp)
|
||||
constraintp->mSourceVolume->mUpdateXform = FALSE;
|
||||
}
|
||||
|
||||
if (!constraintp->mSharedData->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
|
||||
if (constraintp->mSharedData->mConstraintTargetType != CONSTRAINT_TARGET_TYPE_GROUND)
|
||||
{
|
||||
if (constraintp->mTargetVolume)
|
||||
{
|
||||
@@ -1284,16 +1286,6 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8
|
||||
}
|
||||
}
|
||||
|
||||
// Helper class.
|
||||
template<typename T>
|
||||
struct AIAutoDestruct
|
||||
{
|
||||
T* mPtr;
|
||||
AIAutoDestruct() : mPtr(NULL) { }
|
||||
~AIAutoDestruct() { delete mPtr; }
|
||||
void add(T* ptr) { mPtr = ptr; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// deserialize()
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1495,18 +1487,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
|
||||
|
||||
for(U32 i=0; i<num_motions; ++i)
|
||||
{
|
||||
AIAutoDestruct<JointMotion> watcher;
|
||||
|
||||
JointMotion* joint_motion = new JointMotion;
|
||||
JointMotion* joint_motion = new JointMotion;
|
||||
std::unique_ptr<JointMotion> watcher(joint_motion);
|
||||
if (singu_new_joint_motion_list)
|
||||
{
|
||||
// Pass ownership to mJointMotionList.
|
||||
mJointMotionList->mJointMotionArray.push_back(joint_motion);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just delete this at the end.
|
||||
watcher.add(joint_motion);
|
||||
mJointMotionList->mJointMotionArray.push_back(watcher.release());
|
||||
}
|
||||
|
||||
std::string joint_name;
|
||||
@@ -1785,6 +1771,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
|
||||
{
|
||||
// read in constraint data
|
||||
JointConstraintSharedData* constraintp = new JointConstraintSharedData;
|
||||
std::unique_ptr<JointConstraintSharedData> watcher(constraintp);
|
||||
U8 byte = 0;
|
||||
|
||||
if (!dp.unpackU8(byte, "chain_length"))
|
||||
@@ -1842,21 +1829,18 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
|
||||
if (!dp.unpackVector3(constraintp->mSourceConstraintOffset, "source_offset"))
|
||||
{
|
||||
LL_WARNS() << "can't read constraint source offset" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( !(constraintp->mSourceConstraintOffset.isFinite()) )
|
||||
{
|
||||
LL_WARNS() << "non-finite constraint source offset" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dp.unpackBinaryDataFixed(bin_data, BIN_DATA_LENGTH, "target_volume"))
|
||||
{
|
||||
LL_WARNS() << "can't read target volume name" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1876,28 +1860,24 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
|
||||
if (!dp.unpackVector3(constraintp->mTargetConstraintOffset, "target_offset"))
|
||||
{
|
||||
LL_WARNS() << "can't read constraint target offset" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( !(constraintp->mTargetConstraintOffset.isFinite()) )
|
||||
{
|
||||
LL_WARNS() << "non-finite constraint target offset" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dp.unpackVector3(constraintp->mTargetConstraintDir, "target_dir"))
|
||||
{
|
||||
LL_WARNS() << "can't read constraint target direction" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( !(constraintp->mTargetConstraintDir.isFinite()) )
|
||||
{
|
||||
LL_WARNS() << "non-finite constraint target direction" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1910,39 +1890,30 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp)
|
||||
if (!dp.unpackF32(constraintp->mEaseInStartTime, "ease_in_start") || !std::isfinite(constraintp->mEaseInStartTime))
|
||||
{
|
||||
LL_WARNS() << "can't read constraint ease in start time" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dp.unpackF32(constraintp->mEaseInStopTime, "ease_in_stop") || !std::isfinite(constraintp->mEaseInStopTime))
|
||||
{
|
||||
LL_WARNS() << "can't read constraint ease in stop time" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dp.unpackF32(constraintp->mEaseOutStartTime, "ease_out_start") || !std::isfinite(constraintp->mEaseOutStartTime))
|
||||
{
|
||||
LL_WARNS() << "can't read constraint ease out start time" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dp.unpackF32(constraintp->mEaseOutStopTime, "ease_out_stop") || !std::isfinite(constraintp->mEaseOutStopTime))
|
||||
{
|
||||
LL_WARNS() << "can't read constraint ease out stop time" << LL_ENDL;
|
||||
delete constraintp;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
AIAutoDestruct<JointConstraintSharedData> watcher;
|
||||
if (singu_new_joint_motion_list)
|
||||
{
|
||||
mJointMotionList->mConstraints.push_front(constraintp);
|
||||
}
|
||||
else
|
||||
{
|
||||
watcher.add(constraintp);
|
||||
mJointMotionList->mConstraints.push_front(watcher.release());
|
||||
}
|
||||
|
||||
constraintp->mJointStateIndices = new S32[constraintp->mChainLength + 1]; // note: mChainLength is size-limited - comes from a byte
|
||||
|
||||
Reference in New Issue
Block a user