Skip to content

Commit

Permalink
Merge pull request #1430 from Areloch/release-3.8
Browse files Browse the repository at this point in the history
Release 3.8
  • Loading branch information
Areloch committed Oct 6, 2015
2 parents d84bd0f + 2044b26 commit 51fa8a3
Show file tree
Hide file tree
Showing 398 changed files with 5,097 additions and 3,723 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Engine/lib/collada/src/dae/daeStringTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 5 additions & 1 deletion Engine/lib/convexDecomp/NvRemoveTjunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions Engine/lib/convexDecomp/NvSimpleTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Engine/lib/libvorbis/lib/codebook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
34 changes: 17 additions & 17 deletions Engine/source/T3D/aiPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -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();
}
}

Expand Down
4 changes: 3 additions & 1 deletion Engine/source/T3D/aiPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ class AIPlayer : public Player {
SimObjectPtr<SceneObject> object;
/// Distance at whcih to follow.
F32 radius;
Point3F lastPos;
/// Default constructor.
FollowData() : object(NULL)
{
radius = 5.0f;
lastPos = Point3F::Zero;
}
};

Expand Down Expand Up @@ -161,7 +163,7 @@ class AIPlayer : public Player {

// 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; }
Expand Down
53 changes: 53 additions & 0 deletions Engine/source/T3D/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ Camera::Camera()

mLastAbsoluteYaw = 0.0f;
mLastAbsolutePitch = 0.0f;
mLastAbsoluteRoll = 0.0f;

// For NewtonFlyMode
mNewtonRotation = false;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions Engine/source/T3D/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// @{
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion Engine/source/T3D/convexShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 38 additions & 8 deletions Engine/source/T3D/decal/decalManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Engine/source/T3D/examples/renderMeshExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions Engine/source/T3D/fps/guiClockHud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
}


Expand Down
Loading

0 comments on commit 51fa8a3

Please sign in to comment.