Merge remote-tracking branch 'refs/remotes/origin/development' into pr/1153

This commit is contained in:
Anis A. Hireche 2016-02-26 14:39:38 +01:00
commit 10cb6ab9c4
893 changed files with 44063 additions and 6437 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,243 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _VolumetricFog_H_
#define _VolumetricFog_H_
#ifndef _SCENEOBJECT_H_
#include "scene/sceneObject.h"
#endif
#ifndef _MATTEXTURETARGET_H_
#include "materials/matTextureTarget.h"
#endif
#ifndef _GFXSHADER_H_
#include "gfx/gfxShader.h"
#endif
#ifndef _GFXTARGET_H_
#include "gfx/gfxTarget.h"
#endif
#ifndef _GFXVERTEXBUFFER_H_
#include "gfx/gfxVertexBuffer.h"
#endif
#ifndef _TSSHAPE_H_
#include "ts/tsShape.h"
#endif
#ifndef _POST_EFFECT_H_
#include "postFx/postEffect.h"
#endif
#include "gui/core/guiCanvas.h"
class VolumetricFogRTManager;
class VolumetricFog : public SceneObject
{
typedef SceneObject Parent;
// Maskbits for updating
enum
{
VolumetricFogMask = Parent::NextFreeMask,
FogColorMask = Parent::NextFreeMask << 1,
FogDensityMask = Parent::NextFreeMask << 2,
FogModulationMask = Parent::NextFreeMask << 3,
FogPostFXMask = Parent::NextFreeMask << 4,
FogShapeMask = Parent::NextFreeMask << 5,
NextFreeMask = Parent::NextFreeMask << 6
};
// Struct which holds the shape details
struct meshes
{
F32 det_size;
S32 sub_shape;
S32 obj_det;
U32 num_verts;
GFXVertexPNTT *verts;
Vector <GFXPrimitive> *piArray;
Vector <U32> *indices;
};
protected:
// Rendertargets;
GFXTextureTargetRef z_buf;
NamedTexTargetRef mPrepassTarget;
NamedTexTargetRef mDepthBufferTarget;
NamedTexTargetRef mFrontBufferTarget;
// Fog Modulation texture
GFXTexHandle mTexture;
// Shaders
GFXShaderRef mShader;
GFXShaderRef mPrePassShader;
GFXShaderRef mReflectionShader;
// Stateblocks
GFXStateBlockDesc descD;
GFXStateBlockDesc descF;
GFXStateBlockDesc desc_preD;
GFXStateBlockDesc desc_preF;
GFXStateBlockDesc desc_refl;
GFXStateBlockRef mStateblockD;
GFXStateBlockRef mStateblockF;
GFXStateBlockRef mStateblock_preD;
GFXStateBlockRef mStateblock_preF;
GFXStateBlockRef mStateblock_refl;
// Shaderconstants
GFXShaderConstBufferRef mShaderConsts;
GFXShaderConstHandle *mModelViewProjSC;
GFXShaderConstHandle *mFadeSizeSC;
GFXShaderConstHandle *mFogColorSC;
GFXShaderConstHandle *mFogDensitySC;
GFXShaderConstHandle *mPreBias;
GFXShaderConstHandle *mAccumTime;
GFXShaderConstHandle *mIsTexturedSC;
GFXShaderConstHandle *mModSpeedSC;
GFXShaderConstHandle *mModStrengthSC;
GFXShaderConstHandle *mViewPointSC;
GFXShaderConstHandle *mTexScaleSC;
GFXShaderConstHandle *mTexTilesSC;
GFXShaderConstBufferRef mPPShaderConsts;
GFXShaderConstHandle *mPPModelViewProjSC;
GFXShaderConstHandle *mAmbientColorSC;
GFXShaderConstBufferRef mReflShaderConsts;
GFXShaderConstHandle *mReflModelViewProjSC;
GFXShaderConstHandle *mReflFogColorSC;
GFXShaderConstHandle *mReflFogDensitySC;
GFXShaderConstHandle *mReflFogStrengthSC;
// Vertex and Prim. Buffer
GFXVertexBufferHandle<GFXVertexPNTT> mVB;
GFXPrimitiveBufferHandle mPB;
// Fog volume data;
StringTableEntry mShapeName;
ColorI mFogColor;
F32 mFogDensity;
bool mIgnoreWater;
bool mReflect;
Vector<meshes> det_size;
bool mShapeLoaded;
F32 mPixelSize;
F32 mFadeSize;
U32 mCurDetailLevel;
U32 mNumDetailLevels;
F32 mObjSize;
F32 mRadius;
OrientedBox3F ColBox;
VectorF mObjScale;
F32 mMinDisplaySize;
F32 mInvScale;
// Fog Modulation data
String mTextureName;
bool mIsTextured;
F32 mTexTiles;
F32 mStrength;
Point2F mSpeed1;
Point2F mSpeed2;
Point4F mSpeed;
Point2F mTexScale;
// Fog Rendering data
Point3F camPos;
Point2F mViewPoint;
F32 mFOV;
F32 viewDist;
bool mIsVBDirty;
bool mIsPBDirty;
bool mCamInFog;
bool mResizing;
PlatformWindow *mPlatformWindow;
// Reflections
F32 mFogReflStrength;
// PostFX
PostEffect *glowFX;
bool mUseGlow;
F32 mGlowStrength;
U8 mGlowing;
F32 mCurGlow;
bool mModifLightRays;
F32 mLightRayMod;
F32 mOldLightRayStrength;
GameConnection* conn;
U32 mCounter;
void ResizeRT(PlatformWindow *win, bool resize);
protected:
// Protected methods
bool onAdd();
void onRemove();
void handleResize(VolumetricFogRTManager *RTM, bool resize);
void handleCanvasResize(GuiCanvas* canvas);
bool LoadShape();
bool setupRenderer();
void InitTexture();
bool UpdateBuffers(U32 dl,bool force=true);
void processTick(const Move *move);
void _enterFog(ShapeBase *control);
void _leaveFog(ShapeBase *control);
public:
// Public methods
VolumetricFog();
~VolumetricFog();
static void initPersistFields();
virtual void inspectPostApply();
U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
void unpackUpdate(NetConnection *conn, BitStream *stream);
void prepRenderImage(SceneRenderState* state);
void render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat);
void reflect_render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat);
// Methods for modifying & networking various fog elements
// Used in script
void setFogColor(ColorF color);
void setFogColor(ColorI color);
void setFogDensity(F32 density);
void setFogModulation(F32 strength, Point2F speed1, Point2F speed2);
void setFogGlow(bool on_off, F32 strength);
void setFogLightray(bool on_off, F32 strength);
bool isInsideFog();
DECLARE_CONOBJECT(VolumetricFog);
DECLARE_CALLBACK(void, onEnterFog, (SimObjectId obj));
DECLARE_CALLBACK(void, onLeaveFog, (SimObjectId obj));
};
#endif

View file

@ -0,0 +1,299 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Volumetric Fog Rendertarget Manager
//
// Creates and maintains one set of rendertargets to be used by every
// VolumetricFog object in the scene.
//
// Will be loaded at startup end removed when ending game.
//
//-----------------------------------------------------------------------------
#include "VolumetricFogRTManager.h"
#include "core/module.h"
#include "scene/sceneManager.h"
#include "windowManager/platformWindowMgr.h"
#include "console/engineAPI.h"
#include "gui/core/guiCanvas.h"
MODULE_BEGIN(VolumetricFogRTManager)
MODULE_INIT_AFTER(Scene)
MODULE_SHUTDOWN_BEFORE(Scene)
MODULE_INIT
{
gVolumetricFogRTManager = new VolumetricFogRTManager;
gClientSceneGraph->addObjectToScene(gVolumetricFogRTManager);
}
MODULE_SHUTDOWN
{
gClientSceneGraph->removeObjectFromScene(gVolumetricFogRTManager);
SAFE_DELETE(gVolumetricFogRTManager);
}
MODULE_END;
ConsoleDocClass( VolumetricFogRTManager,
"@brief Creates and maintains one set of rendertargets to be used by every\n"
"VolumetricFog object in the scene.\n\n"
"Will be loaded at startup end removed when ending game.\n\n"
"Methods:\n"
" get() returns the currently loaded VolumetricFogRTManager, also accessible\n"
" through VFRTM define.\n"
" Init() Initializes the rendertargets, called when a VolumetricFog object is\n"
" added to the scene.\n"
" isInitialed() returns true if Rendertargets are present, false if not, then\n"
" Init() should be called to create the rendertargets.\n"
" setQuality(U32 Quality) Normally a rendertarget has the same size as the view,\n"
" with this method you can scale down the size of it.\n"
" Be aware that scaling down will introduce renderartefacts.\n"
"@ingroup Atmosphere"
);
VolumetricFogRTMResizeSignal VolumetricFogRTManager::smVolumetricFogRTMResizeSignal;
VolumetricFogRTManager *gVolumetricFogRTManager = NULL;
S32 VolumetricFogRTManager::mTargetScale = 1;
IMPLEMENT_CONOBJECT(VolumetricFogRTManager);
VolumetricFogRTManager::VolumetricFogRTManager()
{
setGlobalBounds();
mTypeMask |= EnvironmentObjectType;
mNetFlags.set(IsGhost);
mIsInitialized = false;
mNumFogObjects = 0;
}
VolumetricFogRTManager::~VolumetricFogRTManager()
{
if (mFrontTarget.isRegistered())
mFrontTarget.unregister();
if (mDepthTarget.isRegistered())
mDepthTarget.unregister();
if (mDepthBuffer.isValid())
mDepthBuffer->kill();
if (mFrontBuffer.isValid())
mFrontBuffer->kill();
}
void VolumetricFogRTManager::onSceneRemove()
{
if (mIsInitialized)
mPlatformWindow->getScreenResChangeSignal().remove(this, &VolumetricFogRTManager::ResizeRT);
}
void VolumetricFogRTManager::onRemove()
{
removeFromScene();
Parent::onRemove();
}
void VolumetricFogRTManager::consoleInit()
{
Con::addVariable("$pref::VolumetricFog::Quality", TypeS32, &mTargetScale,
"The scale of the rendertargets.\n"
"@ingroup Rendering\n");
}
bool VolumetricFogRTManager::Init()
{
if (mIsInitialized)
{
Con::errorf("VolumetricFogRTManager allready initialized!!");
return true;
}
GuiCanvas* cv = dynamic_cast<GuiCanvas*>(Sim::findObject("Canvas"));
if (cv == NULL)
{
Con::errorf("VolumetricFogRTManager::Init() - Canvas not found!!");
return false;
}
mPlatformWindow = cv->getPlatformWindow();
mPlatformWindow->getScreenResChangeSignal().notify(this,&VolumetricFogRTManager::ResizeRT);
if (mTargetScale < 1)
mTargetScale = 1;
mWidth = mFloor(mPlatformWindow->getClientExtent().x / mTargetScale);
mHeight = mPlatformWindow->getClientExtent().y;
mFullScreen = mPlatformWindow->isFullscreen();
if (!mFullScreen)
mHeight -= 20;//subtract caption bar from rendertarget size.
mHeight = mFloor(mHeight / mTargetScale);
mDepthBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
&GFXDefaultRenderTargetProfile, avar("%s() - mDepthBuffer (line %d)", __FUNCTION__, __LINE__));
if (!mDepthBuffer.isValid())
{
Con::errorf("VolumetricFogRTManager Fatal Error: Unable to create Depthbuffer");
return false;
}
if (!mDepthTarget.registerWithName("volfogdepth"))
{
Con::errorf("VolumetricFogRTManager Fatal Error : Unable to register Depthbuffer");
return false;
}
mDepthTarget.setTexture(mDepthBuffer);
mFrontBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
&GFXDefaultRenderTargetProfile, avar("%s() - mFrontBuffer (line %d)", __FUNCTION__, __LINE__));
if (!mFrontBuffer.isValid())
{
Con::errorf("VolumetricFogRTManager Fatal Error: Unable to create front buffer");
return false;
}
if (!mFrontTarget.registerWithName("volfogfront"))
{
Con::errorf("VolumetricFogRTManager Fatal Error : Unable to register Frontbuffer");
return false;
}
mFrontTarget.setTexture(mFrontBuffer);
Con::setVariable("$VolumetricFog::density", "0.0");
mIsInitialized = true;
return true;
}
U32 VolumetricFogRTManager::IncFogObjects()
{
mNumFogObjects++;
return mNumFogObjects;
}
U32 VolumetricFogRTManager::DecFogObjects()
{
if (mNumFogObjects > 0)
mNumFogObjects--;
return mNumFogObjects;
}
void VolumetricFogRTManager::ResizeRT(PlatformWindow* win,bool resize)
{
mFogHasAnswered = 0;
smVolumetricFogRTMResizeSignal.trigger(this, true);
}
void VolumetricFogRTManager::FogAnswered()
{
mFogHasAnswered++;
if (mFogHasAnswered == mNumFogObjects)
{
if (Resize())
smVolumetricFogRTMResizeSignal.trigger(this, false);
else
Con::errorf("VolumetricFogRTManager::FogAnswered - Error resizing rendertargets!");
}
}
bool VolumetricFogRTManager::Resize()
{
if (mTargetScale < 1)
mTargetScale = 1;
mWidth = mFloor(mPlatformWindow->getClientExtent().x / mTargetScale);
mHeight = mPlatformWindow->getClientExtent().y;
if (!mPlatformWindow->isFullscreen())
mHeight -= 20;//subtract caption bar from rendertarget size.
mHeight = mFloor(mHeight / mTargetScale);
if (mWidth < 16 || mHeight < 16)
return false;
if (mFrontTarget.isRegistered())
mFrontTarget.setTexture(NULL);
if (mDepthTarget.isRegistered())
mDepthTarget.setTexture(NULL);
if (mDepthBuffer.isValid())
mDepthBuffer->kill();
if (mFrontBuffer.isValid())
mFrontBuffer->kill();
mFrontBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
&GFXDefaultRenderTargetProfile, avar("%s() - mFrontBuffer (line %d)", __FUNCTION__, __LINE__));
if (!mFrontBuffer.isValid())
{
Con::errorf("VolumetricFogRTManager::Resize() Fatal Error: Unable to create front buffer");
return false;
}
mFrontTarget.setTexture(mFrontBuffer);
mDepthBuffer = GFXTexHandle(mWidth, mHeight, GFXFormatR32F,
&GFXDefaultRenderTargetProfile, avar("%s() - mDepthBuffer (line %d)", __FUNCTION__, __LINE__));
if (!mDepthBuffer.isValid())
{
Con::errorf("VolumetricFogRTManager::Resize() Fatal Error: Unable to create Depthbuffer");
return false;
}
mDepthTarget.setTexture(mDepthBuffer);
return true;
}
S32 VolumetricFogRTManager::setQuality(U32 Quality)
{
if (!mIsInitialized)
return (mTargetScale = Quality);
if (Quality < 1)
Quality = 1;
if (Quality == mTargetScale)
return mTargetScale;
mTargetScale = Quality;
mFogHasAnswered = 0;
smVolumetricFogRTMResizeSignal.trigger(this, true);
return mTargetScale;
}
VolumetricFogRTManager* VolumetricFogRTManager::get()
{
return gVolumetricFogRTManager;
}
DefineConsoleFunction(SetFogVolumeQuality, S32, (U32 new_quality), ,
"@brief Resizes the rendertargets of the Volumetric Fog object.\n"
"@params new_quality new quality for the rendertargets 1 = full size, 2 = halfsize, 3 = 1/3, 4 = 1/4 ...")
{
if (VFRTM == NULL)
return -1;
return VFRTM->setQuality(new_quality);
}

View file

@ -0,0 +1,92 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _VolumetricFogRTManager_H_
#define _VolumetricFogRTManager_H_
#ifndef _SCENEOBJECT_H_
#include "scene/sceneObject.h"
#endif
#ifndef _MATTEXTURETARGET_H_
#include "materials/matTextureTarget.h"
#endif
#ifndef _GFXTARGET_H_
#include "gfx/gfxTarget.h"
#endif
#ifndef _SIGNAL_H_
#include "core/util/tSignal.h"
#endif
class VolumetricFogRTManager;
typedef Signal<void(VolumetricFogRTManager *VolumetricFogRTManager, bool resize)> VolumetricFogRTMResizeSignal;
#define VFRTM VolumetricFogRTManager::get()
class VolumetricFogRTManager : public SceneObject
{
public:
typedef SceneObject Parent;
protected:
GFXTexHandle mDepthBuffer;
GFXTexHandle mFrontBuffer;
NamedTexTarget mDepthTarget;
NamedTexTarget mFrontTarget;
PlatformWindow* mPlatformWindow;
static S32 mTargetScale;
bool mIsInitialized;
U32 mNumFogObjects;
U32 mFogHasAnswered;
U32 mWidth;
U32 mHeight;
bool mFullScreen;
void onRemove();
void onSceneRemove();
void ResizeRT(PlatformWindow *win, bool resize);
static VolumetricFogRTMResizeSignal smVolumetricFogRTMResizeSignal;
public:
VolumetricFogRTManager();
~VolumetricFogRTManager();
static VolumetricFogRTManager *get();
bool Init();
bool IsInitialized() { return mIsInitialized; }
static void consoleInit();
static VolumetricFogRTMResizeSignal& getVolumetricFogRTMResizeSignal() { return smVolumetricFogRTMResizeSignal; }
void FogAnswered();
S32 setQuality(U32 Quality);
bool Resize();
U32 IncFogObjects();
U32 DecFogObjects();
DECLARE_CONOBJECT(VolumetricFogRTManager);
};
extern VolumetricFogRTManager* gVolumetricFogRTManager;
#endif

View file

@ -63,6 +63,12 @@ BasicClouds::BasicClouds()
mTypeMask |= EnvironmentObjectType | StaticObjectType;
mNetFlags.set(Ghostable | ScopeAlways);
mTimeSC = 0;
mModelViewProjSC = 0;
mTexScaleSC = 0;
mTexDirectionSC = 0;
mTexOffsetSC = 0;
mLayerEnabled[0] = true;
mLayerEnabled[1] = true;
mLayerEnabled[2] = true;

View file

@ -73,15 +73,27 @@ U32 CloudLayer::smVertCount = smVertStride * smVertStride;
U32 CloudLayer::smTriangleCount = smStrideMinusOne * smStrideMinusOne * 2;
CloudLayer::CloudLayer()
: mBaseColor( 0.9f, 0.9f, 0.9f, 1.0f ),
mCoverage( 0.5f ),
: mLastTime( 0 ),
mBaseColor( 0.9f, 0.9f, 0.9f, 1.0f ),
mExposure( 1.0f ),
mWindSpeed( 1.0f ),
mLastTime( 0 )
mCoverage( 0.5f ),
mWindSpeed( 1.0f )
{
mTypeMask |= EnvironmentObjectType | StaticObjectType;
mNetFlags.set(Ghostable | ScopeAlways);
mModelViewProjSC =
mAmbientColorSC =
mSunColorSC =
mSunVecSC =
mTexScaleSC =
mBaseColorSC =
mCoverageSC =
mExposureSC =
mEyePosWorldSC = 0;
mTexOffsetSC[0] = mTexOffsetSC[1] = mTexOffsetSC[2] = 0;
mTexScale[0] = 1.0;
mTexScale[1] = 1.0;
mTexScale[2] = 1.0;

View file

@ -1091,7 +1091,7 @@ F32 GuiMeshRoadEditorCtrl::getNodeDepth()
return 0.0f;
}
void GuiMeshRoadEditorCtrl::setNodePosition( Point3F pos )
void GuiMeshRoadEditorCtrl::setNodePosition(const Point3F& pos)
{
if ( mSelRoad && mSelNode != -1 )
{
@ -1248,7 +1248,7 @@ DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, (Point3F normal
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, (const char * objName), (""), "" )
{
if ( dStrIsEmpty(objName) )
if ( String::isEmpty(objName) )
object->setSelectedRoad(NULL);
else
{

View file

@ -100,7 +100,7 @@ class GuiMeshRoadEditorCtrl : public EditTSCtrl
void setNodeDepth( F32 depth );
Point3F getNodePosition();
void setNodePosition( Point3F pos );
void setNodePosition(const Point3F& pos);
VectorF getNodeNormal();
void setNodeNormal( const VectorF &normal );

View file

@ -1235,7 +1235,7 @@ F32 GuiRiverEditorCtrl::getNodeDepth()
return 0.0f;
}
void GuiRiverEditorCtrl::setNodePosition( Point3F pos )
void GuiRiverEditorCtrl::setNodePosition(const Point3F& pos)
{
if ( mSelRiver && mSelNode != -1 )
{

View file

@ -110,7 +110,7 @@ class GuiRiverEditorCtrl : public EditTSCtrl
void setNodeDepth( F32 depth );
Point3F getNodePosition();
void setNodePosition( Point3F pos );
void setNodePosition(const Point3F& pos);
VectorF getNodeNormal();
void setNodeNormal( const VectorF &normal );

View file

@ -979,7 +979,7 @@ F32 GuiRoadEditorCtrl::getNodeWidth()
return 0.0f;
}
void GuiRoadEditorCtrl::setNodePosition( Point3F pos )
void GuiRoadEditorCtrl::setNodePosition(const Point3F& pos)
{
if ( mSelRoad && mSelNode != -1 )
{

View file

@ -97,7 +97,7 @@ class GuiRoadEditorCtrl : public EditTSCtrl
void setNodeWidth( F32 width );
Point3F getNodePosition();
void setNodePosition( Point3F pos );
void setNodePosition(const Point3F& pos);
void setTextureFile( StringTableEntry file );

View file

@ -1552,7 +1552,7 @@ bool MeshRoad::castRay( const Point3F &s, const Point3F &e, RayInfo *info )
info->point.interpolate(start, end, out);
info->face = -1;
info->object = this;
info->material = this->mMatInst[0];
return true;
}

View file

@ -82,13 +82,6 @@ const F32 ScatterSky::smEarthRadius = (6378.0f * 1000.0f);
const F32 ScatterSky::smAtmosphereRadius = 200000.0f;
const F32 ScatterSky::smViewerHeight = 1.0f;
GFXImplementVertexFormat( ScatterSkyVertex )
{
addElement( "POSITION", GFXDeclType_Float3 );
addElement( "NORMAL", GFXDeclType_Float3 );
addElement( "COLOR", GFXDeclType_Color );
}
ScatterSky::ScatterSky()
{
mPrimCount = 0;
@ -151,6 +144,8 @@ ScatterSky::ScatterSky()
mBrightness = 1.0f;
mCastShadows = true;
mStaticRefreshFreq = 8;
mDynamicRefreshFreq = 8;
mDirty = true;
mLight = LightManager::createLightInfo();
@ -271,6 +266,8 @@ void ScatterSky::_conformLights()
mLight->setAmbient( mAmbientColor );
mLight->setColor( mSunColor );
mLight->setCastShadows( mCastShadows );
mLight->setStaticRefreshFreq(mStaticRefreshFreq);
mLight->setDynamicRefreshFreq(mDynamicRefreshFreq);
FogData fog = getSceneManager()->getFogData();
fog.color = mFogColor;
@ -329,7 +326,7 @@ void ScatterSky::initPersistFields()
"Affects the size of the sun's disk." );
addField( "colorizeAmount", TypeF32, Offset( mColorizeAmt, ScatterSky ),
"Controls how much the the alpha component of colorize brigthens the sky. Setting to 0 returns default behavior." );
"Controls how much the alpha component of colorize brigthens the sky. Setting to 0 returns default behavior." );
addField( "colorize", TypeColorF, Offset( mColorize, ScatterSky ),
"Tints the sky the color specified, the alpha controls the brigthness. The brightness is multipled by the value of colorizeAmt." );
@ -381,6 +378,9 @@ void ScatterSky::initPersistFields()
addField( "castShadows", TypeBool, Offset( mCastShadows, ScatterSky ),
"Enables/disables shadows cast by objects due to ScatterSky light." );
addField("staticRefreshFreq", TypeS32, Offset(mStaticRefreshFreq, ScatterSky), "static shadow refresh rate (milliseconds)");
addField("dynamicRefreshFreq", TypeS32, Offset(mDynamicRefreshFreq, ScatterSky), "dynamic shadow refresh rate (milliseconds)");
addField( "brightness", TypeF32, Offset( mBrightness, ScatterSky ),
"The brightness of the ScatterSky's light object." );
@ -487,6 +487,8 @@ U32 ScatterSky::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
stream->write( mBrightness );
stream->writeFlag( mCastShadows );
stream->write(mStaticRefreshFreq);
stream->write(mDynamicRefreshFreq);
stream->write( mFlareScale );
@ -588,6 +590,8 @@ void ScatterSky::unpackUpdate(NetConnection *con, BitStream *stream)
stream->read( &mBrightness );
mCastShadows = stream->readFlag();
stream->read(&mStaticRefreshFreq);
stream->read(&mDynamicRefreshFreq);
stream->read( &mFlareScale );
@ -637,12 +641,13 @@ void ScatterSky::prepRenderImage( SceneRenderState *state )
return;
// Regular sky render instance.
ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
RenderPassManager* renderPass = state->getRenderPass();
ObjectRenderInst *ri = renderPass->allocInst<ObjectRenderInst>();
ri->renderDelegate.bind( this, &ScatterSky::_render );
ri->type = RenderPassManager::RIT_Sky;
ri->defaultKey = 10;
ri->defaultKey2 = 0;
state->getRenderPass()->addInst( ri );
renderPass->addInst(ri);
// Debug render instance.
/*
@ -685,13 +690,13 @@ void ScatterSky::prepRenderImage( SceneRenderState *state )
mMatrixSet->setSceneProjection(GFX->getProjectionMatrix());
mMatrixSet->setWorld(GFX->getWorldMatrix());
ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
ObjectRenderInst *ri = renderPass->allocInst<ObjectRenderInst>();
ri->renderDelegate.bind( this, &ScatterSky::_renderMoon );
ri->type = RenderPassManager::RIT_Sky;
// Render after sky objects and before CloudLayer!
ri->defaultKey = 5;
ri->defaultKey2 = 0;
state->getRenderPass()->addInst( ri );
renderPass->addInst(ri);
}
}
@ -760,7 +765,7 @@ void ScatterSky::_initVBIB()
F32 zOffset = -( mCos( mSqrt( 1.0f ) ) + 0.01f );
mVB.set( GFX, mVertCount, GFXBufferTypeStatic );
ScatterSkyVertex *pVert = mVB.lock();
GFXVertexP *pVert = mVB.lock();
if(!pVert) return;
for ( U32 y = 0; y < vertStride; y++ )

View file

@ -57,14 +57,6 @@ class TimeOfDay;
class CubemapData;
class MatrixSet;
GFXDeclareVertexFormat( ScatterSkyVertex )
{
Point3F point;
VectorF normal;
GFXVertexColor color;
};
class ScatterSky : public SceneObject, public ISceneLight
{
typedef SceneObject Parent;
@ -207,6 +199,8 @@ protected:
LightInfo *mLight;
bool mCastShadows;
S32 mStaticRefreshFreq;
S32 mDynamicRefreshFreq;
bool mDirty;
LightFlareData *mFlareData;
@ -228,7 +222,7 @@ protected:
// Prim buffer, vertex buffer and shader for rendering.
GFXPrimitiveBufferHandle mPrimBuffer;
GFXVertexBufferHandle<ScatterSkyVertex> mVB;
GFXVertexBufferHandle<GFXVertexP> mVB;
GFXShaderRef mShader;
GFXStateBlockRef mStateBlock;

View file

@ -252,7 +252,7 @@ void SkyBox::_renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseM
void SkyBox::_initRender()
{
GFXVertexPNTT *tmpVerts = NULL;
GFXVertexPNT *tmpVerts = NULL;
U32 vertCount = 36;
@ -264,7 +264,7 @@ void SkyBox::_initRender()
// Create temp vertex pointer
// so we can read from it
// for generating the normals below.
tmpVerts = new GFXVertexPNTT[vertCount];
tmpVerts = new GFXVertexPNT[vertCount];
// We don't bother sharing
// vertices here, in order to
@ -400,14 +400,14 @@ void SkyBox::_initRender()
mIsVBDirty = false;
}
GFXVertexPNTT *vertPtr = mVB.lock();
GFXVertexPNT *vertPtr = mVB.lock();
if (!vertPtr)
{
delete[] tmpVerts;
return;
}
dMemcpy( vertPtr, tmpVerts, sizeof ( GFXVertexPNTT ) * vertCount );
dMemcpy(vertPtr, tmpVerts, sizeof( GFXVertexPNT) * vertCount);
mVB.unlock();
@ -609,7 +609,7 @@ void SkyBox::_initMaterial()
features.removeFeature( MFT_Visibility );
// Now initialize the material.
mMatInstance->init( features, getGFXVertexFormat<GFXVertexPNTT>() );
mMatInstance->init(features, getGFXVertexFormat<GFXVertexPNT>());
}
void SkyBox::_updateMaterial()

View file

@ -105,7 +105,7 @@ protected:
SimObjectPtr<Material> mMaterial;
GFXVertexBufferHandle<GFXVertexPNTT> mVB;
GFXVertexBufferHandle<GFXVertexPNT> mVB;
GFXVertexBufferHandle<GFXVertexPC> mFogBandVB;
Material *mFogBandMat;

View file

@ -66,6 +66,8 @@ Sun::Sun()
mSunAzimuth = 0.0f;
mSunElevation = 35.0f;
mCastShadows = true;
mStaticRefreshFreq = 250;
mDynamicRefreshFreq = 8;
mAnimateSun = false;
mTotalTime = 0.0f;
@ -163,7 +165,10 @@ void Sun::initPersistFields()
"Adjust the Sun's global contrast/intensity");
addField( "castShadows", TypeBool, Offset( mCastShadows, Sun ),
"Enables/disables shadows cast by objects due to Sun light");
"Enables/disables shadows cast by objects due to Sun light");
addField("staticRefreshFreq", TypeS32, Offset(mStaticRefreshFreq, Sun), "static shadow refresh rate (milliseconds)");
addField("dynamicRefreshFreq", TypeS32, Offset(mDynamicRefreshFreq, Sun), "dynamic shadow refresh rate (milliseconds)");
endGroup( "Lighting" );
@ -220,7 +225,9 @@ U32 Sun::packUpdate(NetConnection *conn, U32 mask, BitStream *stream )
stream->write( mLightColor );
stream->write( mLightAmbient );
stream->write( mBrightness );
stream->writeFlag( mCastShadows );
stream->writeFlag( mCastShadows );
stream->write(mStaticRefreshFreq);
stream->write(mDynamicRefreshFreq);
stream->write( mFlareScale );
if ( stream->writeFlag( mFlareData ) )
@ -254,6 +261,8 @@ void Sun::unpackUpdate( NetConnection *conn, BitStream *stream )
stream->read( &mLightAmbient );
stream->read( &mBrightness );
mCastShadows = stream->readFlag();
stream->read(&mStaticRefreshFreq);
stream->read(&mDynamicRefreshFreq);
stream->read( &mFlareScale );
if ( stream->readFlag() )
@ -426,6 +435,8 @@ void Sun::_conformLights()
// directional color are the same.
bool castShadows = mLightColor != mLightAmbient && mCastShadows;
mLight->setCastShadows( castShadows );
mLight->setStaticRefreshFreq(mStaticRefreshFreq);
mLight->setDynamicRefreshFreq(mDynamicRefreshFreq);
}
void Sun::_initCorona()

View file

@ -65,6 +65,8 @@ protected:
F32 mEndElevation;
bool mCastShadows;
S32 mStaticRefreshFreq;
S32 mDynamicRefreshFreq;
LightInfo *mLight;

View file

@ -205,8 +205,6 @@ void WaterBlock::setupVertexBlock( U32 width, U32 height, U32 rowOffset )
U32 numVerts = width * height;
GFXWaterVertex *verts = new GFXWaterVertex[ numVerts ];
ColorI waterColor(31, 56, 64, 127);
GFXVertexColor vertCol(waterColor);
U32 index = 0;
for( U32 i=0; i<height; i++ )
@ -219,7 +217,6 @@ void WaterBlock::setupVertexBlock( U32 width, U32 height, U32 rowOffset )
vert->point.x = vertX;
vert->point.y = vertY;
vert->point.z = 0.0;
vert->color = vertCol;
vert->normal.set(0,0,1);
vert->undulateData.set( vertX, vertY );
vert->horizonFactor.set( 0, 0, 0, 0 );

View file

@ -50,7 +50,6 @@ GFXImplementVertexFormat( GFXWaterVertex )
{
addElement( "POSITION", GFXDeclType_Float3 );
addElement( "NORMAL", GFXDeclType_Float3 );
addElement( "COLOR", GFXDeclType_Color );
addElement( "TEXCOORD", GFXDeclType_Float2, 0 );
addElement( "TEXCOORD", GFXDeclType_Float4, 1 );
}
@ -207,7 +206,7 @@ WaterObject::WaterObject()
mEmissive( false ),
mUnderwaterColor(9, 6, 5, 240)
{
mTypeMask = WaterObjectType | StaticObjectType;
mTypeMask = WaterObjectType;
for( U32 i=0; i < MAX_WAVES; i++ )
{

View file

@ -49,7 +49,6 @@ GFXDeclareVertexFormat( GFXWaterVertex )
{
Point3F point;
Point3F normal;
GFXVertexColor color;
Point2F undulateData;
Point4F horizonFactor;
};

View file

@ -175,9 +175,6 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
{
const Frustum &frustum = state->getCullingFrustum();
// Water base-color, assigned as color for all verts.
const GFXVertexColor vertCol(mWaterFogData.color);
// World-Up vector, assigned as normal for all verts.
const Point3F worldUp( 0.0f, 0.0f, 1.0f );
@ -250,7 +247,6 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
xVal = cornerPosition.x + (F32)( j * squareSize );
vertPtr->point.set( xVal, yVal, 0.0f );
vertPtr->color = vertCol;
vertPtr->normal = worldUp;
vertPtr->undulateData.set( xVal, yVal );
vertPtr->horizonFactor.set( 0, 0, 0, 0 );
@ -404,7 +400,6 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
vertPtr->point.set( pos.x, pos.y, 0.0f );
vertPtr->undulateData.set( pos.x, pos.y );
vertPtr->horizonFactor.set( 0, 0, 0, 0 );
vertPtr->color = vertCol;
vertPtr->normal = worldUp;
vertPtr++;
}
@ -427,7 +422,6 @@ void WaterPlane::setupVBIB( SceneRenderState *state )
vertPtr->point.set( pos.x, pos.y, 50.0f );
vertPtr->undulateData.set( pos.x, pos.y );
vertPtr->horizonFactor.set( 1, 0, 0, 0 );
vertPtr->color = vertCol;
vertPtr->normal = worldUp;
vertPtr++;
}