Merge branch 'development' of https://github.com/GarageGames/Torque3D into PBR_ProbeArrayGLWIP

# Conflicts:
#	Engine/source/gfx/D3D11/gfxD3D11Device.cpp
#	Engine/source/lighting/lightManager.cpp
#	Templates/Full/game/levels/Empty Room.mis
#	Templates/Full/game/levels/Empty Terrain.mis
This commit is contained in:
AzaezelX 2019-05-01 23:18:31 -05:00
commit 97ec99f704
235 changed files with 7064 additions and 3090 deletions

236
Engine/source/T3D/Scene.cpp Normal file
View file

@ -0,0 +1,236 @@
#include "Scene.h"
Scene * Scene::smRootScene = nullptr;
Vector<Scene*> Scene::smSceneList;
IMPLEMENT_CO_NETOBJECT_V1(Scene);
Scene::Scene() :
mIsSubScene(false),
mParentScene(nullptr),
mSceneId(-1),
mIsEditing(false),
mIsDirty(false)
{
}
Scene::~Scene()
{
}
void Scene::initPersistFields()
{
Parent::initPersistFields();
addGroup("Internal");
addField("isSubscene", TypeBool, Offset(mIsSubScene, Scene), "", AbstractClassRep::FIELD_HideInInspectors);
addField("isEditing", TypeBool, Offset(mIsEditing, Scene), "", AbstractClassRep::FIELD_HideInInspectors);
addField("isDirty", TypeBool, Offset(mIsDirty, Scene), "", AbstractClassRep::FIELD_HideInInspectors);
endGroup("Internal");
}
bool Scene::onAdd()
{
if (!Parent::onAdd())
return false;
smSceneList.push_back(this);
mSceneId = smSceneList.size() - 1;
/*if (smRootScene == nullptr)
{
//we're the first scene, so we're the root. woo!
smRootScene = this;
}
else
{
mIsSubScene = true;
smRootScene->mSubScenes.push_back(this);
}*/
return true;
}
void Scene::onRemove()
{
Parent::onRemove();
smSceneList.remove(this);
mSceneId = -1;
/*if (smRootScene == this)
{
for (U32 i = 0; i < mSubScenes.size(); i++)
{
mSubScenes[i]->deleteObject();
}
}
else if (smRootScene != nullptr)
{
for (U32 i = 0; i < mSubScenes.size(); i++)
{
if(mSubScenes[i]->getId() == getId())
smRootScene->mSubScenes.erase(i);
}
}*/
}
void Scene::addObject(SimObject* object)
{
//Child scene
Scene* scene = dynamic_cast<Scene*>(object);
if (scene)
{
//We'll keep these principly separate so they don't get saved into each other
mSubScenes.push_back(scene);
return;
}
SceneObject* sceneObj = dynamic_cast<SceneObject*>(object);
if (sceneObj)
{
//We'll operate on the presumption that if it's being added via regular parantage means, it's considered permanent
mPermanentObjects.push_back(sceneObj);
Parent::addObject(object);
return;
}
//Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene?
Parent::addObject(object);
}
void Scene::removeObject(SimObject* object)
{
//Child scene
Scene* scene = dynamic_cast<Scene*>(object);
if (scene)
{
//We'll keep these principly separate so they don't get saved into each other
mSubScenes.remove(scene);
return;
}
SceneObject* sceneObj = dynamic_cast<SceneObject*>(object);
if (sceneObj)
{
//We'll operate on the presumption that if it's being added via regular parantage means, it's considered permanent
mPermanentObjects.remove(sceneObj);
Parent::removeObject(object);
return;
}
Parent::removeObject(object);
}
void Scene::addDynamicObject(SceneObject* object)
{
mDynamicObjects.push_back(object);
//Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene?
Parent::addObject(object);
}
void Scene::removeDynamicObject(SceneObject* object)
{
mDynamicObjects.remove(object);
//Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene?
Parent::removeObject(object);
}
void Scene::interpolateTick(F32 delta)
{
}
void Scene::processTick()
{
}
void Scene::advanceTime(F32 timeDelta)
{
}
U32 Scene::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
{
bool ret = Parent::packUpdate(conn, mask, stream);
return ret;
}
void Scene::unpackUpdate(NetConnection *conn, BitStream *stream)
{
}
//
Vector<SceneObject*> Scene::getObjectsByClass(String className)
{
return Vector<SceneObject*>();
}
DefineEngineFunction(getScene, Scene*, (U32 sceneId), (0),
"Get the root Scene object that is loaded.\n"
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
{
if (Scene::smSceneList.empty() || sceneId >= Scene::smSceneList.size())
return nullptr;
return Scene::smSceneList[sceneId];
}
DefineEngineFunction(getRootScene, S32, (), ,
"Get the root Scene object that is loaded.\n"
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
{
Scene* root = Scene::getRootScene();
if (root)
return root->getId();
return 0;
}
DefineEngineMethod(Scene, getRootScene, S32, (),,
"Get the root Scene object that is loaded.\n"
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
{
Scene* root = Scene::getRootScene();
if (root)
return root->getId();
return 0;
}
DefineEngineMethod(Scene, addDynamicObject, void, (SceneObject* sceneObj), (nullAsType<SceneObject*>()),
"Get the root Scene object that is loaded.\n"
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
{
object->addDynamicObject(sceneObj);
}
DefineEngineMethod(Scene, removeDynamicObject, void, (SceneObject* sceneObj), (nullAsType<SceneObject*>()),
"Get the root Scene object that is loaded.\n"
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
{
object->removeDynamicObject(sceneObj);
}
DefineEngineMethod(Scene, getObjectsByClass, String, (String className), (""),
"Get the root Scene object that is loaded.\n"
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
{
if (className == String::EmptyString)
return "";
//return object->getObjectsByClass(className);
return "";
}

79
Engine/source/T3D/Scene.h Normal file
View file

@ -0,0 +1,79 @@
#pragma once
#include "console/engineAPI.h"
#ifndef _NETOBJECT_H_
#include "sim/netObject.h"
#endif
#ifndef _ITICKABLE_H_
#include "core/iTickable.h"
#endif
#include "scene/sceneObject.h"
/// Scene
/// This object is effectively a smart container to hold and manage any relevent scene objects and data
/// used to run things.
class Scene : public NetObject, public virtual ITickable
{
typedef NetObject Parent;
bool mIsSubScene;
Scene* mParentScene;
Vector<Scene*> mSubScenes;
Vector<SceneObject*> mPermanentObjects;
Vector<SceneObject*> mDynamicObjects;
S32 mSceneId;
bool mIsEditing;
bool mIsDirty;
protected:
static Scene * smRootScene;
DECLARE_CONOBJECT(Scene);
public:
Scene();
~Scene();
static void initPersistFields();
virtual bool onAdd();
virtual void onRemove();
virtual void interpolateTick(F32 delta);
virtual void processTick();
virtual void advanceTime(F32 timeDelta);
virtual void addObject(SimObject* object);
virtual void removeObject(SimObject* object);
void addDynamicObject(SceneObject* object);
void removeDynamicObject(SceneObject* object);
//
//Networking
U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
void unpackUpdate(NetConnection *conn, BitStream *stream);
//
Vector<SceneObject*> getObjectsByClass(String className);
static Scene *getRootScene()
{
if (Scene::smSceneList.empty())
return nullptr;
return Scene::smSceneList[0];
}
static Vector<Scene*> smSceneList;
};

View file

@ -621,8 +621,6 @@ void AnimationComponent::advanceThreads(F32 dt)
Thread& st = mAnimationThreads[i];
if (st.thread && st.sequence != -1)
{
bool cyclic = getShape()->sequences[st.sequence].isCyclic();
if (!getShape()->sequences[st.sequence].isCyclic() &&
!st.atEnd &&
((st.timescale > 0.f) ? mOwnerShapeInstance->getPos(st.thread) >= 1.0 : mOwnerShapeInstance->getPos(st.thread) <= 0))

View file

@ -237,8 +237,6 @@ bool CameraComponent::getCameraTransform(F32* pos,MatrixF* mat)
{
// Returns camera to world space transform
// Handles first person / third person camera position
bool isServer = isServerObject();
if (mTargetNodeIdx == -1)
{
if (mUseParentTransform)
@ -479,7 +477,6 @@ void CameraComponent::setRotation(RotationF newRot)
Frustum CameraComponent::getFrustum()
{
Frustum visFrustum;
F32 left, right, top, bottom;
F32 aspectRatio = mClientScreen.x / mClientScreen.y;
visFrustum.set(false, mDegToRad(mCameraFov), aspectRatio, 0.1f, 1000, mOwner->getTransform());

View file

@ -538,7 +538,6 @@ PhysicsCollision* CollisionComponent::buildColShapes()
for (S32 o = start; o < end; o++)
{
const TSShape::Object &object = shape->objects[o];
const String &meshName = shape->names[object.nameIndex];
if (object.numMeshes <= detail.objectDetailNum)
continue;

View file

@ -152,7 +152,6 @@ void StateMachine::readConditions(StateTransition &currentTransition)
//get our first state
StateTransition::Condition firstCondition;
StateField firstField;
bool fieldRead = false;
readFieldName(&firstField, reader);
firstCondition.field = firstField;

View file

@ -239,8 +239,6 @@ bool TriggerComponent::testObject(SceneObject* enter)
myList.setObject(mOwner);
myCI->buildPolyList(PLC_Collision, &myList, enterBox, sphere);
bool test = true;
}
}
}

View file

@ -330,9 +330,6 @@ void PlayerControllerComponent::updateMove()
}
// Update current orientation
bool doStandardMove = true;
GameConnection* con = mOwner->getControllingClient();
MatrixF zRot;
zRot.set(EulerF(0.0f, 0.0f, mOwner->getRotation().asEulerF().z));
@ -355,7 +352,6 @@ void PlayerControllerComponent::updateMove()
mContactInfo.jump = false;
mContactInfo.run = false;
bool jumpSurface = false, runSurface = false;
if (!mOwner->isMounted())
findContact(&mContactInfo.run, &mContactInfo.jump, &mContactInfo.contactNormal);
if (mContactInfo.jump)
@ -577,7 +573,6 @@ void PlayerControllerComponent::updatePos(const F32 travelTime)
newPos = mPhysicsRep->move(mVelocity * travelTime, collisionList);
bool haveCollisions = false;
bool wasFalling = mFalling;
if (collisionList.getCount() > 0)
{
mFalling = false;

View file

@ -719,8 +719,6 @@ bool ConvexShape::buildExportPolyList(ColladaUtils::ExportData* exportData, cons
//Convex shapes only have the one 'level', so we'll just rely on the export post-process to back-fill
if (isServerObject() && getClientObject())
{
ConvexShape* clientShape = dynamic_cast<ConvexShape*>(getClientObject());
exportData->meshData.increment();
//Prep a meshData for this shape in particular

View file

@ -306,8 +306,6 @@ void Entity::onPostAdd()
bool Entity::_setGameObject(void *object, const char *index, const char *data)
{
Entity *e = static_cast<Entity*>(object);
// Sanity!
AssertFatal(data != NULL, "Cannot use a NULL asset Id.");
@ -513,8 +511,6 @@ U32 Entity::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
for (U32 i = 0; i < mNetworkedComponents.size(); i++)
{
NetworkedComponent::UpdateState state = mNetworkedComponents[i].updateState;
if (mNetworkedComponents[i].updateState == NetworkedComponent::Adding)
{
const char* className = mComponents[mNetworkedComponents[i].componentIndex]->getClassName();
@ -1381,7 +1377,6 @@ bool Entity::removeComponent(Component *comp, bool deleteComponent)
//to re-add them. Need to implement a clean clear function that will clear the local list, and only delete unused behaviors during an update.
void Entity::clearComponents(bool deleteComponents)
{
bool srv = isServerObject();
if (!deleteComponents)
{
while (mComponents.size() > 0)
@ -1399,8 +1394,6 @@ void Entity::clearComponents(bool deleteComponents)
{
comp->onComponentRemove(); //in case the behavior needs to do cleanup on the owner
bool removed = mComponents.remove(comp);
//we only need to delete them on the server side. they'll be cleaned up on the client side
//via the ghosting system for us
if (isServerObject())
@ -1663,7 +1656,6 @@ void Entity::notifyComponents(String signalFunction, String argA, String argB, S
void Entity::setComponentsDirty()
{
bool tmp = true;
/*if (mToLoadComponents.empty())
mStartComponentUpdate = true;
@ -1694,7 +1686,6 @@ void Entity::setComponentsDirty()
void Entity::setComponentDirty(Component *comp, bool forceUpdate)
{
bool found = false;
for (U32 i = 0; i < mComponents.size(); i++)
{
if (mComponents[i]->getId() == comp->getId())

View file

@ -309,7 +309,6 @@ Vector<T*> Entity::getComponents()
Vector<T*> foundObjects;
T *curObj;
Component* comp;
// Loop through our child objects.
for (U32 i = 0; i < mComponents.size(); i++)

View file

@ -490,7 +490,7 @@ void ParticleEmitterData::unpackData(BitStream* stream)
#if defined(AFX_CAP_PARTICLE_POOLS)
if (stream->readFlag())
{
pool_datablock = (afxParticlePoolData*)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
pool_datablock = (afxParticlePoolData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
stream->read(&pool_index);
pool_depth_fade = stream->readFlag();
pool_radial_fade = stream->readFlag();

View file

@ -553,7 +553,6 @@ void renderFrame(GFXTextureTargetRef* target, MatrixF transform, Frustum frustum
GFX->setStateBlock(mDefaultGuiSB);
GFXTargetRef origTarget = GFX->getActiveRenderTarget();
U32 origStyle = GFX->getCurrentRenderStyle();
// Clear the zBuffer so GUI doesn't hose object rendering accidentally
GFX->clear(GFXClearZBuffer, ColorI(20, 20, 20), 1.0f, 0);

View file

@ -6150,8 +6150,22 @@ void Player::updateWorkingCollisionSet()
mWorkingQueryBox.maxExtents += twolPoint;
disableCollision();
//We temporarily disable the collisions of anything mounted to us so we don't accidentally walk into things we've attached to us
for (SceneObject *ptr = mMount.list; ptr; ptr = ptr->getMountLink())
{
ptr->disableCollision();
}
mConvex.updateWorkingList(mWorkingQueryBox,
isGhost() ? sClientCollisionContactMask : sServerCollisionContactMask);
//And now re-enable the collisions of the mounted things
for (SceneObject *ptr = mMount.list; ptr; ptr = ptr->getMountLink())
{
ptr->enableCollision();
}
enableCollision();
}
}
@ -6345,6 +6359,14 @@ U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
if(len > 8191)
len = 8191;
stream->writeInt((S32)len, 13);
// constrain the range of mRot.z
while (mRot.z < 0.0f)
mRot.z += M_2PI_F;
while (mRot.z > M_2PI_F)
mRot.z -= M_2PI_F;
}
stream->writeFloat(mRot.z / M_2PI_F, 7);
stream->writeSignedFloat(mHead.x / (mDataBlock->maxLookAngle - mDataBlock->minLookAngle), 6);

View file

@ -34,6 +34,8 @@
#include "T3D/physics/physicsShape.h"
#include "core/util/path.h"
#include "T3D/Scene.h"
// We use this locally ( within this file ) to prevent infinite recursion
// while loading prefab files that contain other prefabs.
static Vector<String> sPrefabFileStack;
@ -269,11 +271,11 @@ void Prefab::setFile( String file )
SimGroup* Prefab::explode()
{
SimGroup *missionGroup;
Scene* scene = Scene::getRootScene();
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
if ( !scene)
{
Con::errorf( "Prefab::explode, MissionGroup was not found." );
Con::errorf( "Prefab::explode, Scene was not found." );
return NULL;
}
@ -295,7 +297,7 @@ SimGroup* Prefab::explode()
smChildToPrefabMap.erase( child->getId() );
}
missionGroup->addObject(group);
scene->addObject(group);
mChildGroup = NULL;
mChildMap.clear();
@ -468,10 +470,10 @@ Prefab* Prefab::getPrefabByChild( SimObject *child )
bool Prefab::isValidChild( SimObject *simobj, bool logWarnings )
{
if ( simobj->getName() && dStricmp(simobj->getName(),"MissionGroup") == 0 )
if ( simobj->getName() && simobj == Scene::getRootScene() )
{
if ( logWarnings )
Con::warnf( "MissionGroup is not valid within a Prefab." );
Con::warnf( "root Scene is not valid within a Prefab." );
return false;
}

View file

@ -93,7 +93,7 @@ public:
void setFile( String file );
/// Removes all children from this Prefab and puts them into a SimGroup
/// which is added to the MissionGroup and returned to the caller.
/// which is added to the Scene and returned to the caller.
SimGroup* explode();
bool buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere);

View file

@ -72,8 +72,7 @@ class ProximityMine: public Item
protected:
enum MaskBits {
DeployedMask = Parent::NextFreeMask,
ExplosionMask = Parent::NextFreeMask << 1,
NextFreeMask = Parent::NextFreeMask << 2
ExplosionMask = Parent::NextFreeMask << 1
};
enum State

View file

@ -3266,7 +3266,7 @@ void ShapeBase::unpackUpdate(NetConnection *con, BitStream *stream)
st.play = stream->readFlag();
if ( st.play )
{
st.profile = (SFXTrack*) stream->readRangedU32( DataBlockObjectIdFirst,
st.profile = (SFXTrack*)(uintptr_t)stream->readRangedU32( DataBlockObjectIdFirst,
DataBlockObjectIdLast );
}

View file

@ -189,7 +189,7 @@ ShapeBaseImageData::ShapeBaseImageData()
lightRadius = 10.f;
lightBrightness = 1.0f;
shapeName = "core/art/shapes/noshape.dts";
shapeName = "core/shapes/noshape.dts";
shapeNameFP = "";
imageAnimPrefix = "";
imageAnimPrefixFP = "";
@ -1202,7 +1202,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream)
}
projectile = (stream->readFlag() ?
(ProjectileData*)stream->readRangedU32(DataBlockObjectIdFirst,
(ProjectileData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast) : 0);
cloakable = stream->readFlag();
@ -1340,7 +1340,7 @@ void ShapeBaseImageData::unpackData(BitStream* stream)
if (stream->readFlag())
{
s.emitter = (ParticleEmitterData*) stream->readRangedU32(DataBlockObjectIdFirst,
s.emitter = (ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast);
stream->read(&s.emitterTime);

View file

@ -21,11 +21,9 @@ void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* stat
for (U32 i = 0; i < count; i++)
{
//Server side items exist for data, but we don't actually render them
bool isClient = MeshRenderSystemInterface::all[i]->mIsClient;
if (!MeshRenderSystemInterface::all[i]->mIsClient)
continue;
bool isStatic = MeshRenderSystemInterface::all[i]->mStatic;
if (MeshRenderSystemInterface::all[i]->mStatic)
continue;

View file

@ -1135,7 +1135,6 @@ bool TSStatic::buildExportPolyList(ColladaUtils::ExportData* exportData, const B
if (isServerObject() && getClientObject())
{
TSStatic* clientShape = dynamic_cast<TSStatic*>(getClientObject());
U32 numDetails = clientShape->mShapeInstance->getNumDetails() - 1;
exportData->meshData.increment();

View file

@ -282,14 +282,14 @@ void FlyingVehicleData::unpackData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++) {
sound[i] = NULL;
if (stream->readFlag())
sound[i] = (SFXProfile*)stream->readRangedU32(DataBlockObjectIdFirst,
sound[i] = (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast);
}
for (S32 j = 0; j < MaxJetEmitters; j++) {
jetEmitter[j] = NULL;
if (stream->readFlag())
jetEmitter[j] = (ParticleEmitterData*)stream->readRangedU32(DataBlockObjectIdFirst,
jetEmitter[j] = (ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast);
}

View file

@ -411,13 +411,13 @@ void HoverVehicleData::unpackData(BitStream* stream)
for (S32 i = 0; i < MaxSounds; i++)
sound[i] = stream->readFlag()?
(SFXProfile*) stream->readRangedU32(DataBlockObjectIdFirst,
(SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast): 0;
for (S32 j = 0; j < MaxJetEmitters; j++) {
jetEmitter[j] = NULL;
if (stream->readFlag())
jetEmitter[j] = (ParticleEmitterData*)stream->readRangedU32(DataBlockObjectIdFirst,
jetEmitter[j] = (ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast);
}

View file

@ -374,7 +374,7 @@ void VehicleData::unpackData(BitStream* stream)
for (i = 0; i < Body::MaxSounds; i++) {
body.sound[i] = NULL;
if (stream->readFlag())
body.sound[i] = (SFXProfile*)stream->readRangedU32(DataBlockObjectIdFirst,
body.sound[i] = (SFXProfile*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast);
}

View file

@ -494,7 +494,7 @@ void WheeledVehicleData::unpackData(BitStream* stream)
Parent::unpackData(stream);
tireEmitter = stream->readFlag()?
(ParticleEmitterData*) stream->readRangedU32(DataBlockObjectIdFirst,
(ParticleEmitterData*)(uintptr_t)stream->readRangedU32(DataBlockObjectIdFirst,
DataBlockObjectIdLast): 0;
for (S32 i = 0; i < MaxSounds; i++)