Commit 51fa8a3b authored by Jeff Raab's avatar Jeff Raab

Merge pull request #1430 from Areloch/release-3.8

Release 3.8
parents d84bd0fc 2044b269
......@@ -2,6 +2,8 @@ cmake_minimum_required (VERSION 2.8.12)
set(TORQUE_APP_NAME "" CACHE STRING "the app name")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/temp" CACHE PATH "default install path" FORCE )
if("${TORQUE_APP_NAME}" STREQUAL "")
message(FATAL_ERROR "Please set TORQUE_APP_NAME first")
endif()
......
......@@ -58,7 +58,7 @@ void daeStringTable::clear()
{
unsigned int i;
for (i=0;i<_stringBuffersList.getCount();i++)
#if _MSC_VER <= 1200
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
delete [] (char *) _stringBuffersList[i];
#else
delete [] _stringBuffersList[i];
......
......@@ -60,8 +60,12 @@ NvRemoveTjunctions.cpp : A code snippet to remove tjunctions from a triangle mes
#include <vector>
#ifdef __APPLE__
#include <ext/hash_map>
#else
#elif LINUX
#include <hash_map>
#elif _MSC_VER < 1500
#include <hash_map>
#elif _MSC_VER > 1800
#include <unordered_map>
#endif
#include "NvUserMemAlloc.h"
#include "NvHashMap.h"
......
......@@ -87,7 +87,7 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
typedef float NxF32;
typedef double NxF64;
#elif LINUX
#elif defined(LINUX)
typedef long long NxI64;
typedef signed int NxI32;
typedef signed short NxI16;
......@@ -101,7 +101,7 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
typedef float NxF32;
typedef double NxF64;
#elif __APPLE__
#elif defined(__APPLE__)
typedef long long NxI64;
typedef signed int NxI32;
typedef signed short NxI16;
......@@ -115,7 +115,7 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
typedef float NxF32;
typedef double NxF64;
#elif __CELLOS_LV2__
#elif defined(__CELLOS_LV2__)
typedef long long NxI64;
typedef signed int NxI32;
typedef signed short NxI16;
......@@ -129,7 +129,7 @@ NvSimpleTypes.h : Defines basic data types for integers and floats.
typedef float NxF32;
typedef double NxF64;
#elif _XBOX
#elif defined(_XBOX)
typedef __int64 NxI64;
typedef signed int NxI32;
typedef signed short NxI16;
......
......@@ -450,7 +450,7 @@ long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
}
}
}else{
int i,j;
int i;
for(i=0;i<n;){
a[i++]=0.f;
......
......@@ -259,7 +259,7 @@ void AIPlayer::setAimObject( GameBase *targetObject )
* @param targetObject The object to target
* @param offset The offest from the target location to aim at
*/
void AIPlayer::setAimObject( GameBase *targetObject, Point3F offset )
void AIPlayer::setAimObject(GameBase *targetObject, const Point3F& offset)
{
mAimObject = targetObject;
mTargetInLOS = false;
......@@ -725,24 +725,20 @@ bool AIPlayer::setPathDestination(const Point3F &pos)
// Create a new path.
NavPath *path = new NavPath();
if(path)
path->mMesh = getNavMesh();
path->mFrom = getPosition();
path->mTo = pos;
path->mFromSet = path->mToSet = true;
path->mAlwaysRender = true;
path->mLinkTypes = mLinkTypes;
path->mXray = true;
// Paths plan automatically upon being registered.
if(!path->registerObject())
{
path->mMesh = getNavMesh();
path->mFrom = getPosition();
path->mTo = pos;
path->mFromSet = path->mToSet = true;
path->mAlwaysRender = true;
path->mLinkTypes = mLinkTypes;
path->mXray = true;
// Paths plan automatically upon being registered.
if(!path->registerObject())
{
delete path;
return false;
}
}
else
delete path;
return false;
}
if(path->success())
{
......@@ -831,11 +827,15 @@ void AIPlayer::followObject(SceneObject *obj, F32 radius)
if(!isServerObject())
return;
if ((mFollowData.lastPos - obj->getPosition()).len()<mMoveTolerance)
return;
if(setPathDestination(obj->getPosition()))
{
clearCover();
mFollowData.object = obj;
mFollowData.radius = radius;
mFollowData.lastPos = obj->getPosition();
}
}
......
......@@ -122,10 +122,12 @@ private:
SimObjectPtr<SceneObject> object;
/// Distance at whcih to follow.
F32 radius;
Point3F lastPos;
/// Default constructor.
FollowData() : object(NULL)
{
radius = 5.0f;
lastPos = Point3F::Zero;
}
};
......@@ -161,7 +163,7 @@ public:
// Targeting and aiming sets/gets
void setAimObject( GameBase *targetObject );
void setAimObject( GameBase *targetObject, Point3F offset );
void setAimObject(GameBase *targetObject, const Point3F& offset);
GameBase* getAimObject() const { return mAimObject; }
void setAimLocation( const Point3F &location );
Point3F getAimLocation() const { return mAimLocation; }
......
......@@ -279,6 +279,7 @@ Camera::Camera()
mLastAbsoluteYaw = 0.0f;
mLastAbsolutePitch = 0.0f;
mLastAbsoluteRoll = 0.0f;
// For NewtonFlyMode
mNewtonRotation = false;
......@@ -379,6 +380,57 @@ void Camera::getCameraTransform(F32* pos, MatrixF* mat)
mat->mul( gCamFXMgr.getTrans() );
}
void Camera::getEyeCameraTransform(IDisplayDevice *displayDevice, U32 eyeId, MatrixF *outMat)
{
// The camera doesn't support a third person mode,
// so we want to override the default ShapeBase behavior.
ShapeBase * obj = dynamic_cast<ShapeBase*>(static_cast<SimObject*>(mOrbitObject));
if(obj && static_cast<ShapeBaseData*>(obj->getDataBlock())->observeThroughObject)
obj->getEyeCameraTransform(displayDevice, eyeId, outMat);
else
{
Parent::getEyeCameraTransform(displayDevice, eyeId, outMat);
}
}
DisplayPose Camera::calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose)
{
// NOTE: this is intended to be similar to updateMove
DisplayPose outPose;
outPose.orientation = EulerF(0,0,0);
outPose.position = inPose.position;
// Pitch
outPose.orientation.x = (inPose.orientation.x - mLastAbsolutePitch);
// Constrain the range of mRot.x
while (outPose.orientation.x < -M_PI_F)
outPose.orientation.x += M_2PI_F;
while (outPose.orientation.x > M_PI_F)
outPose.orientation.x -= M_2PI_F;
// Yaw
outPose.orientation.z = (inPose.orientation.z - mLastAbsoluteYaw);
// Constrain the range of mRot.z
while (outPose.orientation.z < -M_PI_F)
outPose.orientation.z += M_2PI_F;
while (outPose.orientation.z > M_PI_F)
outPose.orientation.z -= M_2PI_F;
// Bank
if (mDataBlock->cameraCanBank)
{
outPose.orientation.y = (inPose.orientation.y - mLastAbsoluteRoll);
}
// Constrain the range of mRot.y
while (outPose.orientation.y > M_PI_F)
outPose.orientation.y -= M_2PI_F;
return outPose;
}
//----------------------------------------------------------------------------
F32 Camera::getCameraFov()
......@@ -547,6 +599,7 @@ void Camera::processTick(const Move* move)
mLastAbsoluteYaw = emove->rotZ[emoveIndex];
mLastAbsolutePitch = emove->rotX[emoveIndex];
mLastAbsoluteRoll = emove->rotY[emoveIndex];
// Bank
mRot.y = emove->rotY[emoveIndex];
......
......@@ -113,6 +113,7 @@ class Camera: public ShapeBase
F32 mLastAbsoluteYaw; ///< Stores that last absolute yaw value as passed in by ExtendedMove
F32 mLastAbsolutePitch; ///< Stores that last absolute pitch value as passed in by ExtendedMove
F32 mLastAbsoluteRoll; ///< Stores that last absolute roll value as passed in by ExtendedMove
/// @name NewtonFlyMode
/// @{
......@@ -235,6 +236,8 @@ class Camera: public ShapeBase
virtual void processTick( const Move* move );
virtual void interpolateTick( F32 delta);
virtual void getCameraTransform( F32* pos,MatrixF* mat );
virtual void getEyeCameraTransform( IDisplayDevice *display, U32 eyeId, MatrixF *outMat );
virtual DisplayPose calcCameraDeltaPose(GameConnection *con, const DisplayPose& inPose);
virtual void writePacketData( GameConnection* conn, BitStream* stream );
virtual void readPacketData( GameConnection* conn, BitStream* stream );
......
......@@ -502,7 +502,7 @@ void ConvexShape::prepRenderImage( SceneRenderState *state )
}
*/
if ( mVertexBuffer.isNull() )
if ( mVertexBuffer.isNull() || !state)
return;
// If we don't have a material instance after the override then
......
......@@ -1235,8 +1235,30 @@ void DecalManager::prepRenderImage( SceneRenderState* state )
currentBatch = &batches.last();
currentBatch->startDecal = i;
currentBatch->decalCount = 1;
currentBatch->iCount = decal->mIndxCount;
currentBatch->vCount = decal->mVertCount;
// Shrink and warning: preventing a potential crash.
currentBatch->iCount =
(decal->mIndxCount > smMaxIndices) ? smMaxIndices : decal->mIndxCount;
currentBatch->vCount =
(decal->mVertCount > smMaxVerts) ? smMaxVerts : decal->mVertCount;
#ifdef TORQUE_DEBUG
// we didn't mean send a spam to the console
static U32 countMsgIndx = 0;
if ( (decal->mIndxCount > smMaxIndices) && ((countMsgIndx++ % 1024) == 0) ) {
Con::warnf(
"DecalManager::prepRenderImage() - Shrinked indices of decal."
" Lost %u.", (decal->mIndxCount - smMaxIndices)
);
}
static U32 countMsgVert = 0;
if ( (decal->mVertCount > smMaxVerts) && ((countMsgVert++ % 1024) == 0) ) {
Con::warnf(
"DecalManager::prepRenderImage() - Shrinked vertices of decal."
" Lost %u.", (decal->mVertCount - smMaxVerts)
);
}
#endif
currentBatch->mat = mat;
currentBatch->matInst = decal->mDataBlock->getMaterialInstance();
currentBatch->priority = decal->getRenderPriority();
......@@ -1299,15 +1321,21 @@ void DecalManager::prepRenderImage( SceneRenderState* state )
{
DecalInstance *dinst = mDecalQueue[j];
for ( U32 k = 0; k < dinst->mIndxCount; k++ )
const U32 indxCount =
(dinst->mIndxCount > currentBatch.iCount) ?
currentBatch.iCount : dinst->mIndxCount;
for ( U32 k = 0; k < indxCount; k++ )
{
*( pbPtr + ioffset + k ) = dinst->mIndices[k] + voffset;
}
ioffset += dinst->mIndxCount;
ioffset += indxCount;
dMemcpy( vpPtr + voffset, dinst->mVerts, sizeof( DecalVertex ) * dinst->mVertCount );
voffset += dinst->mVertCount;
const U32 vertCount =
(dinst->mVertCount > currentBatch.vCount) ?
currentBatch.vCount : dinst->mVertCount;
dMemcpy( vpPtr + voffset, dinst->mVerts, sizeof( DecalVertex ) * vertCount );
voffset += vertCount;
// Ugly hack for ProjectedShadow!
if ( (dinst->mFlags & CustomDecal) && dinst->mCustomTex != NULL )
......@@ -1357,8 +1385,10 @@ void DecalManager::prepRenderImage( SceneRenderState* state )
pb->lock( &pbPtr );
// Memcpy from system to video memory.
dMemcpy( vpPtr, vertData, sizeof( DecalVertex ) * currentBatch.vCount );
dMemcpy( pbPtr, indexData, sizeof( U16 ) * currentBatch.iCount );
const U32 vpCount = sizeof( DecalVertex ) * currentBatch.vCount;
dMemcpy( vpPtr, vertData, vpCount );
const U32 pbCount = sizeof( U16 ) * currentBatch.iCount;
dMemcpy( pbPtr, indexData, pbCount );
pb->unlock();
vb->unlock();
......
......@@ -269,7 +269,7 @@ void RenderMeshExample::prepRenderImage( SceneRenderState *state )
createGeometry();
// If we have no material then skip out.
if ( !mMaterialInst )
if ( !mMaterialInst || !state)
return;
// If we don't have a material instance after the override then
......
......@@ -113,9 +113,11 @@ void GuiClockHud::initPersistFields()
void GuiClockHud::onRender(Point2I offset, const RectI &updateRect)
{
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
// Background first
if (mShowFill)
GFX->getDrawUtil()->drawRectFill(updateRect, mFillColor);
drawUtil->drawRectFill(updateRect, mFillColor);
// Convert ms time into hours, minutes and seconds.
S32 time = S32(getTime());
......@@ -129,13 +131,13 @@ void GuiClockHud::onRender(Point2I offset, const RectI &updateRect)
// Center the text
offset.x += (getWidth() - mProfile->mFont->getStrWidth((const UTF8 *)buf)) / 2;
offset.y += (getHeight() - mProfile->mFont->getHeight()) / 2;
GFX->getDrawUtil()->setBitmapModulation(mTextColor);
GFX->getDrawUtil()->drawText(mProfile->mFont, offset, buf);
GFX->getDrawUtil()->clearBitmapModulation();
drawUtil->setBitmapModulation(mTextColor);
drawUtil->drawText(mProfile->mFont, offset, buf);
drawUtil->clearBitmapModulation();
// Border last
if (mShowFrame)
GFX->getDrawUtil()->drawRect(updateRect, mFrameColor);
drawUtil->drawRect(updateRect, mFrameColor);
}
......
......@@ -162,10 +162,12 @@ void GuiHealthTextHud::onRender(Point2I offset, const RectI &updateRect)
else
mValue = 100 - (100 * control->getDamageValue());
}
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
// If enabled draw background first
if (mShowFill)
GFX->getDrawUtil()->drawRectFill(updateRect, mFillColor);
drawUtil->drawRectFill(updateRect, mFillColor);
// Prepare text and center it
S32 val = (S32)mValue;
......@@ -190,11 +192,11 @@ void GuiHealthTextHud::onRender(Point2I offset, const RectI &updateRect)
}
}
GFX->getDrawUtil()->setBitmapModulation(tColor);
GFX->getDrawUtil()->drawText(mProfile->mFont, offset, buf);
GFX->getDrawUtil()->clearBitmapModulation();
drawUtil->setBitmapModulation(tColor);
drawUtil->drawText(mProfile->mFont, offset, buf);
drawUtil->clearBitmapModulation();
// If enabled draw the border last
if (mShowFrame)
GFX->getDrawUtil()->drawRect(updateRect, mFrameColor);
drawUtil->drawRect(updateRect, mFrameColor);
}
\ No newline at end of file
......@@ -196,7 +196,7 @@ void GuiShapeNameHud::onRender( Point2I, const RectI &updateRect)
// Collision info. We're going to be running LOS tests and we
// don't want to collide with the control object.
static U32 losMask = TerrainObjectType | ShapeBaseObjectType;
static U32 losMask = TerrainObjectType | ShapeBaseObjectType | StaticObjectType;
control->disableCollision();
// All ghosted objects are added to the server connection group,
......@@ -301,18 +301,20 @@ void GuiShapeNameHud::drawName(Point2I offset, const char *name, F32 opacity)
offset.x -= width / 2;
offset.y -= height / 2;
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
// Background fill first
if (mShowLabelFill)
GFX->getDrawUtil()->drawRectFill(RectI(offset, extent), mLabelFillColor);
drawUtil->drawRectFill(RectI(offset, extent), mLabelFillColor);
// Deal with opacity and draw.
mTextColor.alpha = opacity;
GFX->getDrawUtil()->setBitmapModulation(mTextColor);
GFX->getDrawUtil()->drawText(mProfile->mFont, offset + mLabelPadding, name);
GFX->getDrawUtil()->clearBitmapModulation();
drawUtil->setBitmapModulation(mTextColor);
drawUtil->drawText(mProfile->mFont, offset + mLabelPadding, name);
drawUtil->clearBitmapModulation();
// Border last
if (mShowLabelFrame)
GFX->getDrawUtil()->drawRect(RectI(offset, extent), mLabelFrameColor);
drawUtil->drawRect(RectI(offset, extent), mLabelFrameColor);
}
......@@ -248,7 +248,7 @@ fxFoliageCulledList::fxFoliageCulledList(Box3F SearchBox, fxFoliageCulledList* I
//------------------------------------------------------------------------------
void fxFoliageCulledList::FindCandidates(Box3F SearchBox, fxFoliageCulledList* InVec)
void fxFoliageCulledList::FindCandidates(const Box3F& SearchBox, fxFoliageCulledList* InVec)
{
// Search the Culled List.
for (U32 i = 0; i < InVec->GetListCount(); i++)
......@@ -1028,7 +1028,7 @@ void fxFoliageReplicator::SetupBuffers()
//------------------------------------------------------------------------------
Box3F fxFoliageReplicator::FetchQuadrant(Box3F Box, U32 Quadrant)
Box3F fxFoliageReplicator::FetchQuadrant(const Box3F& Box, U32 Quadrant)
{
Box3F QuadrantBox;
......
......@@ -86,7 +86,7 @@ public:
fxFoliageCulledList(Box3F SearchBox, fxFoliageCulledList* InVec);
~fxFoliageCulledList() {};
void FindCandidates(Box3F SearchBox, fxFoliageCulledList* InVec);
void FindCandidates(const Box3F& SearchBox, fxFoliageCulledList* InVec);
U32 GetListCount(void) { return mCulledObjectSet.size(); };
fxFoliageItem* GetElement(U32 index) { return mCulledObjectSet[index]; };
......@@ -157,7 +157,7 @@ protected:
void SyncFoliageReplicators(void);
Box3F FetchQuadrant(Box3F Box, U32 Quadrant);
Box3F FetchQuadrant(const Box3F& Box, U32 Quadrant);
void ProcessQuadrant(fxFoliageQuadrantNode* pParentNode, fxFoliageCulledList* pCullList, U32 Quadrant);
void ProcessNodeChildren(fxFoliageQuadrantNode* pParentNode, fxFoliageCulledList* pCullList);
......
......@@ -1293,7 +1293,7 @@ void Precipitation::interpolateTick(F32 delta)
void Precipitation::processTick(const Move *)
{
//nothing to do on the server
if (isServerObject() || mDataBlock == NULL)
if (isServerObject() || mDataBlock == NULL || isHidden())
return;
const U32 currTime = Platform::getVirtualMilliseconds();
......
......@@ -39,6 +39,9 @@
#include "scene/sceneManager.h"
#define __SCENEMANAGER_H__
#endif
#ifndef _IDISPLAYDEVICE_H_
#include "platform/output/IDisplayDevice.h"
#endif
class NetConnection;
class ProcessList;
......@@ -418,6 +421,7 @@ public:
// Not implemented here, but should return the Camera to world transformation matrix
virtual void getCameraTransform (F32 *pos, MatrixF *mat ) { *mat = MatrixF::Identity; }
virtual void getEyeCameraTransform ( IDisplayDevice *device, U32 eyeId, MatrixF *mat ) { *mat = MatrixF::Identity; }
/// Returns the water object we are colliding with, it is up to derived
/// classes to actually set this object.
......
......@@ -235,6 +235,7 @@ GameConnection::GameConnection()
GameConnection::~GameConnection()
{
setDisplayDevice(NULL);
delete mAuthInfo;
for(U32 i = 0; i < mConnectArgc; i++)
dFree(mConnectArgv[i]);
......@@ -673,6 +674,30 @@ bool GameConnection::getControlCameraTransform(F32 dt, MatrixF* mat)
return true;
}
bool GameConnection::getControlCameraEyeTransforms(IDisplayDevice *display, MatrixF *transforms)
{
GameBase* obj = getCameraObject();
if(!obj)
return false;
GameBase* cObj = obj;