Merge branch 'development' into issue_2115

This commit is contained in:
Areloch 2018-02-14 01:43:34 -06:00 committed by GitHub
commit 6497ea5c76
46 changed files with 805 additions and 399 deletions

View file

@ -90,14 +90,9 @@ ConsoleSetType(TypeImageAssetPtr)
//-----------------------------------------------------------------------------
ImageAsset::ImageAsset()
ImageAsset::ImageAsset() : AssetBase(), mImage(nullptr), mUseMips(true), mIsHDRImage(false), mIsValidImage(false)
{
mImageFileName = StringTable->EmptyString();
mImage = NULL;
mUseMips = true;
mIsHDRImage = false;
mIsValidImage = false;
}
//-----------------------------------------------------------------------------

View file

@ -47,11 +47,6 @@ class ImageAsset : public AssetBase
{
typedef AssetBase Parent;
AssetManager* mpOwningAssetManager;
bool mAssetInitialized;
AssetDefinition* mpAssetDefinition;
U32 mAcquireReferenceCount;
StringTableEntry mImageFileName;
GFXTexHandle mImage;

View file

@ -90,10 +90,12 @@ ConsoleSetType(TypeLevelAssetPtr)
//-----------------------------------------------------------------------------
LevelAsset::LevelAsset()
LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
{
mLevelFile = StringTable->EmptyString();
mPreviewImage = StringTable->EmptyString();
mMainLevelAsset = StringTable->EmptyString();
}
//-----------------------------------------------------------------------------

View file

@ -89,7 +89,7 @@ ConsoleSetType(TypeScriptAssetPtr)
//-----------------------------------------------------------------------------
ScriptAsset::ScriptAsset()
ScriptAsset::ScriptAsset() : AssetBase(), mIsServerSide(true)
{
mScriptFilePath = StringTable->EmptyString();
}

View file

@ -92,8 +92,13 @@ ConsoleSetType(TypeShapeAnimationAssetPtr)
//-----------------------------------------------------------------------------
ShapeAnimationAsset::ShapeAnimationAsset()
ShapeAnimationAsset::ShapeAnimationAsset() :
mIsEmbedded(false), mIsCyclical(true), mIsBlend(false), mBlendFrame(0), mStartFrame(0), mEndFrame(-1), mPadRotation(true), mPadTransforms(false)
{
mFileName = StringTable->EmptyString();
mAnimationName = StringTable->EmptyString();
mBlendAnimAssetName = StringTable->EmptyString();
}
//-----------------------------------------------------------------------------
@ -116,6 +121,14 @@ void ShapeAnimationAsset::initPersistFields()
addField("animationFile", TypeFilename, Offset(mFileName, ShapeAnimationAsset), "Path to the file name containing the animation");
addField("animationName", TypeString, Offset(mAnimationName, ShapeAnimationAsset), "Name of the animation");
addField("isEmbedded", TypeBool, Offset(mIsEmbedded, ShapeAnimationAsset), "If true, this animation asset just referrs to an embedded animation of a regular shape mesh. If false, it is a self-contained animation file");
addField("isCyclic", TypeBool, Offset(mIsCyclical, ShapeAnimationAsset), "Is this animation looping?");
addField("isBlend", TypeBool, Offset(mIsBlend, ShapeAnimationAsset), "Is this animation blended with another?");
addField("blendRefAnimation", TypeString, Offset(mBlendAnimAssetName, ShapeAnimationAsset), "AssetID of the animation to reference for our blending");
addField("blendFrame", TypeS32, Offset(mBlendFrame, ShapeAnimationAsset), "Which frame of the reference animation do we use for our blending");
addField("startFrame", TypeS32, Offset(mStartFrame, ShapeAnimationAsset), "What frame does this animation clip start on");
addField("endFrame", TypeS32, Offset(mEndFrame, ShapeAnimationAsset), "What fram does this animation clip end on");
addField("padRotation", TypeBool, Offset(mPadRotation, ShapeAnimationAsset), "Are the rotation values padded");
@ -128,4 +141,35 @@ void ShapeAnimationAsset::copyTo(SimObject* object)
{
// Call to parent.
Parent::copyTo(object);
}
void ShapeAnimationAsset::initializeAsset(void)
{
if (!mIsEmbedded)
{
//If we're not embedded, we need to load in our initial shape and do some prepwork
char filenameBuf[1024];
Con::expandScriptFilename(filenameBuf, sizeof(filenameBuf), mFileName);
mSourceShape = ResourceManager::get().load(filenameBuf);
if (!mSourceShape->addSequence("ambient", "", mAnimationName, mStartFrame, mEndFrame, mPadRotation, mPadTransforms))
{
Con::errorf("ShapeAnimationAsset::initializeAsset - Unable to do initial setup of the animation clip named %s for asset %s", mAnimationName, getAssetName());
return;
}
S32 sequenceId = mSourceShape->findSequence(mAnimationName);
if(mIsCyclical)
mSourceShape->sequences[sequenceId].flags |= TSShape::Cyclic;
else
mSourceShape->sequences[sequenceId].flags &= (~(TSShape::Cyclic));
}
}
void ShapeAnimationAsset::onAssetRefresh(void)
{
}

View file

@ -37,6 +37,12 @@
#ifndef _ASSET_FIELD_TYPES_H_
#include "assets/assetFieldTypes.h"
#endif
#ifndef _TSSHAPE_H_
#include "ts/tsShape.h"
#endif
#ifndef __RESOURCE_H__
#include "core/resource.h"
#endif
//-----------------------------------------------------------------------------
class ShapeAnimationAsset : public AssetBase
@ -46,6 +52,15 @@ class ShapeAnimationAsset : public AssetBase
protected:
StringTableEntry mFileName;
bool mIsEmbedded;
bool mIsCyclical;
bool mIsBlend;
StringTableEntry mBlendAnimAssetName;
S32 mBlendFrame;
//
StringTableEntry mAnimationName;
S32 mStartFrame;
@ -53,6 +68,8 @@ protected:
bool mPadRotation;
bool mPadTransforms;
Resource<TSShape> mSourceShape;
public:
ShapeAnimationAsset();
virtual ~ShapeAnimationAsset();
@ -65,18 +82,25 @@ public:
DECLARE_CONOBJECT(ShapeAnimationAsset);
protected:
virtual void initializeAsset(void) {}
virtual void onAssetRefresh(void) {}
virtual void initializeAsset(void);
virtual void onAssetRefresh(void);
public:
StringTableEntry getAnimationFilename() { return mFileName; }
StringTableEntry getAnimationName() { return mAnimationName; }
StringTableEntry getBlendAnimationName() { return mBlendAnimAssetName; }
S32 getStartFrame() { return mStartFrame; }
S32 getEndFrame() { return mEndFrame; }
bool getPadRotation() { return mPadRotation; }
bool getPadTransforms() { return mPadTransforms; }
bool isEmbedded() { return mIsEmbedded; }
bool isCyclic() { return mIsCyclical; }
bool isBlend() { return mIsBlend; }
S32 getBlendFrame() { return mBlendFrame; }
};
DefineConsoleType(TypeShapeAnimationAssetPtr, ShapeAnimationAsset)

View file

@ -182,17 +182,49 @@ bool ShapeAsset::loadShape()
return false; //if it failed to load, bail out
}
bool hasBlends = false;
//Now that we've successfully loaded our shape and have any materials and animations loaded
//we need to set up the animations we're using on our shape
for (U32 i = 0; i < mAnimationAssets.size(); i++)
for (S32 i = mAnimationAssets.size()-1; i >= 0; --i)
{
String srcName;
String srcName = mAnimationAssets[i]->getAnimationName();
String srcPath(mAnimationAssets[i]->getAnimationFilename());
SplitSequencePathAndName(srcPath, srcName);
//SplitSequencePathAndName(srcPath, srcName);
if (!mShape->addSequence(srcPath, srcName, mAnimationAssets[i]->getAnimationName(),
if (!mShape->addSequence(srcPath, srcName, srcName,
mAnimationAssets[i]->getStartFrame(), mAnimationAssets[i]->getEndFrame(), mAnimationAssets[i]->getPadRotation(), mAnimationAssets[i]->getPadTransforms()))
return false;
if (mAnimationAssets[i]->isBlend())
hasBlends = true;
}
//if any of our animations are blends, set those up now
if (hasBlends)
{
for (U32 i=0; i < mAnimationAssets.size(); ++i)
{
if (mAnimationAssets[i]->isBlend() && mAnimationAssets[i]->getBlendAnimationName() != StringTable->EmptyString())
{
//gotta do a bit of logic here.
//First, we need to make sure the anim asset we depend on for our blend is loaded
AssetPtr<ShapeAnimationAsset> blendAnimAsset = mAnimationAssets[i]->getBlendAnimationName();
if (blendAnimAsset.isNull())
{
Con::errorf("ShapeAsset::initializeAsset - Unable to acquire reference animation asset %s for asset %s to blend!", mAnimationAssets[i]->getBlendAnimationName(), mAnimationAssets[i]->getAssetName());
return false;
}
String refAnimName = blendAnimAsset->getAnimationName();
if (!mShape->setSequenceBlend(mAnimationAssets[i]->getAnimationName(), true, blendAnimAsset->getAnimationName(), mAnimationAssets[i]->getBlendFrame()))
{
Con::errorf("ShapeAnimationAsset::initializeAsset - Unable to set animation clip %s for asset %s to blend!", mAnimationAssets[i]->getAnimationName(), mAnimationAssets[i]->getAssetName());
return false;
}
}
}
}
return true;

View file

@ -222,7 +222,7 @@ U32 AnimationComponent::packUpdate(NetConnection *con, U32 mask, BitStream *stre
{
U32 retMask = Parent::packUpdate(con, mask, stream);
/*for (int i = 0; i < MaxScriptThreads; i++)
for (int i = 0; i < MaxScriptThreads; i++)
{
Thread& st = mAnimationThreads[i];
if (stream->writeFlag((st.sequence != -1 || st.state == Thread::Destroy) && (mask & (ThreadMaskN << i))))
@ -234,7 +234,7 @@ U32 AnimationComponent::packUpdate(NetConnection *con, U32 mask, BitStream *stre
stream->writeFlag(st.atEnd);
stream->writeFlag(st.transition);
}
}*/
}
return retMask;
}
@ -243,7 +243,7 @@ void AnimationComponent::unpackUpdate(NetConnection *con, BitStream *stream)
{
Parent::unpackUpdate(con, stream);
/*for (S32 i = 0; i < MaxScriptThreads; i++)
for (S32 i = 0; i < MaxScriptThreads; i++)
{
if (stream->readFlag())
{
@ -260,7 +260,7 @@ void AnimationComponent::unpackUpdate(NetConnection *con, BitStream *stream)
else
updateThread(st);
}
}*/
}
}
void AnimationComponent::processTick()
@ -613,6 +613,9 @@ void AnimationComponent::advanceThreads(F32 dt)
if (!mOwnerRenderInst)
return;
if (mOwnerShapeInstance == nullptr || !getShape())
return;
for (U32 i = 0; i < MaxScriptThreads; i++)
{
Thread& st = mAnimationThreads[i];

View file

@ -142,10 +142,12 @@ CollisionComponent::CollisionComponent() : Component()
StaticShapeObjectType | VehicleObjectType |
VehicleBlockerObjectType | DynamicShapeObjectType | StaticObjectType | EntityObjectType | TriggerObjectType);
mPhysicsRep = NULL;
mPhysicsWorld = NULL;
mPhysicsRep = nullptr;
mPhysicsWorld = nullptr;
mTimeoutList = NULL;
mTimeoutList = nullptr;
mAnimated = false;
}
CollisionComponent::~CollisionComponent()

View file

@ -67,6 +67,13 @@ Component::Component()
mOriginatingAssetId = StringTable->EmptyString();
mIsServerObject = true;
componentIdx = 0;
mHidden = false;
mEnabled = true;
mDirtyMaskBits = 0;
}
Component::~Component()
@ -535,7 +542,7 @@ const char * Component::getDescriptionText(const char *desc)
if (desc == NULL)
return NULL;
char *newDesc;
char *newDesc = "";
// [tom, 1/12/2007] If it isn't a file, just do it the easy way
if (!Platform::isFile(desc))
@ -568,7 +575,7 @@ const char * Component::getDescriptionText(const char *desc)
}
str.close();
delete stream;
//delete stream;
return newDesc;
}

View file

@ -30,6 +30,10 @@ StateMachine::StateMachine()
mStartingState = "";
mCurCreateState = NULL;
mStateMachineFile = StringTable->EmptyString();
mCurCreateState = nullptr;
}
StateMachine::~StateMachine()

View file

@ -158,6 +158,8 @@ public:
{
if (index <= mFields.size())
return mFields[index];
return StateField(); //return a blank one
}
Signal< void(StateMachine*, S32 stateIdx) > onStateChanged;

View file

@ -119,8 +119,11 @@ PlayerControllerComponent::PlayerControllerComponent() : Component()
mInputVelocity = Point3F(0, 0, 0);
mPhysicsRep = NULL;
mPhysicsWorld = NULL;
mPhysicsRep = nullptr;
mPhysicsWorld = nullptr;
mOwnerCollisionInterface = nullptr;
mIntegrationCount = 0;
}
PlayerControllerComponent::~PlayerControllerComponent()

View file

@ -59,7 +59,7 @@ ImplementEnumType(BatchingMode,
//////////////////////////////////////////////////////////////////////////
// Constructor/Destructor
//////////////////////////////////////////////////////////////////////////
MeshComponent::MeshComponent() : Component()
MeshComponent::MeshComponent() : Component(), mShape(nullptr), mRenderMode(Individual)
{
mFriendlyName = "Mesh Component";
mComponentType = "Render";

View file

@ -850,7 +850,7 @@ void Entity::setTransform(const MatrixF &mat)
}
}
void Entity::setTransform(Point3F position, RotationF rotation)
void Entity::setTransform(const Point3F& position, const RotationF& rotation)
{
MatrixF oldTransform = getTransform();
@ -922,7 +922,7 @@ void Entity::setRenderTransform(const MatrixF &mat)
Parent::setRenderTransform(mat);
}
void Entity::setRenderTransform(Point3F position, RotationF rotation)
void Entity::setRenderTransform(const Point3F& position, const RotationF& rotation)
{
if (isMounted())
{
@ -977,7 +977,7 @@ MatrixF Entity::getTransform()
}
}
void Entity::setMountOffset(Point3F posOffset)
void Entity::setMountOffset(const Point3F& posOffset)
{
if (isMounted())
{
@ -987,7 +987,7 @@ void Entity::setMountOffset(Point3F posOffset)
}
}
void Entity::setMountRotation(EulerF rotOffset)
void Entity::setMountRotation(const EulerF& rotOffset)
{
if (isMounted())
{
@ -1111,11 +1111,12 @@ bool Entity::castRayRendered(const Point3F &start, const Point3F &end, RayInfo *
bool Entity::buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF &sphere)
{
Vector<BuildPolyListInterface*> updaters = getComponents<BuildPolyListInterface>();
Con::errorf("Build Poly List not yet implemented as a passthrough for Entity");
/*Vector<BuildPolyListInterface*> updaters = getComponents<BuildPolyListInterface>();
for (Vector<BuildPolyListInterface*>::iterator it = updaters.begin(); it != updaters.end(); it++)
{
return (*it)->buildPolyList(context, polyList, box, sphere);
}
}*/
return false;
}
@ -1131,7 +1132,7 @@ void Entity::buildConvex(const Box3F& box, Convex* convex)
//
// Mounting and heirarchy manipulation
void Entity::mountObject(SceneObject* objB, MatrixF txfm)
void Entity::mountObject(SceneObject* objB, const MatrixF& txfm)
{
Parent::mountObject(objB, -1, txfm);
Parent::addObject(objB);
@ -1604,7 +1605,7 @@ void Entity::onCameraScopeQuery(NetConnection* connection, CameraScopeQuery* que
}
}
//
void Entity::setObjectBox(Box3F objBox)
void Entity::setObjectBox(const Box3F& objBox)
{
mObjBox = objBox;
resetWorldBox();
@ -1705,8 +1706,8 @@ void Entity::setComponentDirty(Component *comp, bool forceUpdate)
}
}
if (!found)
return;
//if (!found)
// return;
//if(mToLoadComponents.empty())
// mStartComponentUpdate = true;

View file

@ -152,14 +152,14 @@ public:
virtual void setTransform(const MatrixF &mat);
virtual void setRenderTransform(const MatrixF &mat);
void setTransform(Point3F position, RotationF rotation);
void setTransform(const Point3F& position, const RotationF& rotation);
void setRenderTransform(Point3F position, RotationF rotation);
void setRenderTransform(const Point3F& position, const RotationF& rotation);
virtual MatrixF getTransform();
virtual Point3F getPosition() const { return mPos; }
void setRotation(RotationF rotation) {
void setRotation(const RotationF& rotation) {
mRot = rotation;
setMaskBits(TransformMask);
};
@ -167,8 +167,8 @@ public:
static bool _setGameObject(void *object, const char *index, const char *data);
void setMountOffset(Point3F posOffset);
void setMountRotation(EulerF rotOffset);
void setMountOffset(const Point3F& posOffset);
void setMountRotation(const EulerF& rotOffset);
//static bool _setEulerRotation( void *object, const char *index, const char *data );
static bool _setPosition(void *object, const char *index, const char *data);
@ -181,7 +181,7 @@ public:
virtual void getRenderMountTransform(F32 delta, S32 index, const MatrixF &xfm, MatrixF *outMat);
virtual void mountObject(SceneObject *obj, S32 node, const MatrixF &xfm = MatrixF::Identity);
void mountObject(SceneObject* objB, MatrixF txfm);
void mountObject(SceneObject* objB, const MatrixF& txfm);
void onMount(SceneObject *obj, S32 node);
void onUnmount(SceneObject *obj, S32 node);
@ -218,7 +218,7 @@ public:
return mComponents.size();
}
virtual void setObjectBox(Box3F objBox);
virtual void setObjectBox(const Box3F& objBox);
void resetWorldBox() { Parent::resetWorldBox(); }
void resetObjectBox() { Parent::resetObjectBox(); }

View file

@ -11,6 +11,9 @@ Vector<MeshRenderSystem::BufferSet> MeshRenderSystem::mStaticBuffers(0);
void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* state)
{
if (sceneManager == nullptr || state == nullptr)
return;
Frustum viewFrustum = state->getCullingFrustum();
MatrixF camTransform = state->getCameraTransform();
@ -129,7 +132,7 @@ void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* stat
// We sort by the material then vertex buffer
ri->defaultKey = matInst->getStateHint();
ri->defaultKey2 = (uintptr_t)ri->vertBuff; // Not 64bit safe!
ri->defaultKey2 = (uintptr_t)ri->vertBuff;
// Submit our RenderInst to the RenderPassManager
state->getRenderPass()->addInst(ri);
@ -372,4 +375,4 @@ U32 MeshRenderSystem::findBufferSetByMaterial(U32 matId)
}
return -1;
}
}