mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 06:34:36 +00:00
Merge branch 'master' into console-func-refactor
Conflicts: Engine/source/app/net/net.cpp Engine/source/console/astNodes.cpp Engine/source/console/compiledEval.cpp Engine/source/console/console.h Engine/source/console/consoleInternal.h Engine/source/console/engineAPI.h
This commit is contained in:
commit
b507dc9555
6487 changed files with 315149 additions and 609761 deletions
|
|
@ -650,7 +650,7 @@ void ForestBrushTool::_collectElements()
|
|||
}
|
||||
}
|
||||
|
||||
bool ForestBrushTool::getGroundAt( const Point3F &worldPt, float *zValueOut, VectorF *normalOut )
|
||||
bool ForestBrushTool::getGroundAt( const Point3F &worldPt, F32 *zValueOut, VectorF *normalOut )
|
||||
{
|
||||
const U32 mask = TerrainObjectType | StaticShapeObjectType;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public:
|
|||
void setPressure( F32 val );
|
||||
void setHardness( F32 val );
|
||||
void collectElements() { _collectElements(); }
|
||||
bool getGroundAt( const Point3F &worldPt, float *zValueOut, VectorF *normalOut );
|
||||
bool getGroundAt( const Point3F &worldPt, F32 *zValueOut, VectorF *normalOut );
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
|
|
@ -330,7 +330,12 @@ void Forest::createNewFile()
|
|||
|
||||
// We need to construct a default file name
|
||||
String missionName( Con::getVariable( "$Client::MissionFile" ) );
|
||||
missionName.replace( "tools/levels", "levels" );
|
||||
String levelDirectory( Con::getVariable( "$pref::Directories::Level" ) );
|
||||
if ( levelDirectory.isEmpty() )
|
||||
{
|
||||
levelDirectory = "levels";
|
||||
}
|
||||
missionName.replace( "tools/levels", levelDirectory );
|
||||
missionName = Platform::makeRelativePathName(missionName, Platform::getMainDotCsDir());
|
||||
|
||||
Torque::Path basePath( missionName );
|
||||
|
|
|
|||
|
|
@ -64,13 +64,14 @@ ScriptMethod( Forest, forestRayCast, const char*, 4, 4, "( Point3F start, Point3
|
|||
dSscanf(argv[2], "%g %g %g", &start.x, &start.y, &start.z);
|
||||
dSscanf(argv[3], "%g %g %g", &end.x, &end.y, &end.z);
|
||||
|
||||
char *returnBuffer = Con::getReturnBuffer(256);
|
||||
static const U32 bufSize = 256;
|
||||
char *returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
returnBuffer[0] = '0';
|
||||
returnBuffer[1] = '\0';
|
||||
|
||||
ForestRayInfo rinfo;
|
||||
if ( object->castRayI( start, end, &rinfo ) )
|
||||
dSprintf( returnBuffer, 256, "%d %d %g", rinfo.item->getData()->getId(), rinfo.key, rinfo.t );
|
||||
dSprintf( returnBuffer, bufSize, "%d %d %g", rinfo.item->getData()->getId(), rinfo.key, rinfo.t );
|
||||
|
||||
return returnBuffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ void Forest::prepRenderImage( SceneRenderState *state )
|
|||
// the forest, so pass down a LightQuery for it.
|
||||
LightQuery lightQuery;
|
||||
rdata.setLightQuery( &lightQuery );
|
||||
Frustum culler = state->getFrustum();
|
||||
Frustum culler = state->getCullingFrustum();
|
||||
|
||||
// Adjust the far distance if the cull scale has changed.
|
||||
if ( !mIsEqual( cullScale, 1.0f ) )
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@
|
|||
|
||||
static void _onRegisterFeatures( GFXAdapterType type )
|
||||
{
|
||||
if ( type != OpenGL )
|
||||
return;
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_WindEffect, new WindDeformationGLSL );
|
||||
}
|
||||
|
||||
|
|
@ -83,29 +86,14 @@ void WindDeformationGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
// save constant space and reduce the memory copied to the
|
||||
// card.
|
||||
//
|
||||
// This in particular helps when we're instancing.
|
||||
//
|
||||
// .x = bend scale
|
||||
// .y = branch amplitude
|
||||
// .z = detail amplitude
|
||||
// .w = detail frequency
|
||||
//
|
||||
Var *windParams;
|
||||
if ( fd.features[MFT_UseInstancing] )
|
||||
{
|
||||
ShaderConnector *vertStruct = dynamic_cast<ShaderConnector *>( componentList[C_VERT_STRUCT] );
|
||||
windParams = vertStruct->getElement( RT_TEXCOORD );
|
||||
windParams->setName( "inst_windParams" );
|
||||
windParams->setType( "vec4" );
|
||||
|
||||
mInstancingFormat->addElement( "windParams", GFXDeclType_Float4, windParams->constNum );
|
||||
}
|
||||
else
|
||||
{
|
||||
windParams = new Var( "windParams", "vec4" );
|
||||
Var *windParams = new Var( "windParams", "vec4" );
|
||||
windParams->uniform = true;
|
||||
windParams->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
// If we're instancing then we need to instance the wind direction
|
||||
// and speed as its unique for each tree instance.
|
||||
|
|
@ -114,6 +102,7 @@ void WindDeformationGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
{
|
||||
ShaderConnector *vertStruct = dynamic_cast<ShaderConnector *>( componentList[C_VERT_STRUCT] );
|
||||
windDirAndSpeed = vertStruct->getElement( RT_TEXCOORD );
|
||||
windDirAndSpeed->setStructName( "IN" );
|
||||
windDirAndSpeed->setName( "inst_windDirAndSpeed" );
|
||||
windDirAndSpeed->setType( "vec3" );
|
||||
|
||||
|
|
@ -143,16 +132,31 @@ void WindDeformationGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
if ( !inPosition )
|
||||
inPosition = (Var*)LangElement::find( "position" );
|
||||
|
||||
// Copy the input position to the output first as
|
||||
// the wind effects are conditional.
|
||||
Var *outPosition = (Var*)LangElement::find( "inPosition" );
|
||||
if ( !outPosition )
|
||||
{
|
||||
outPosition = new Var;
|
||||
outPosition->setType( "vec3" );
|
||||
outPosition->setName( "inPosition" );
|
||||
meta->addStatement( new GenOp(" @ = @.xyz;\r\n", new DecOp( outPosition ), inPosition ) );
|
||||
}
|
||||
|
||||
// Get the incoming color data
|
||||
Var *inColor = (Var*)LangElement::find( "diffuse" );
|
||||
|
||||
// Do a dynamic branch based on wind force.
|
||||
if ( GFX->getPixelShaderVersion() >= 3.0f )
|
||||
meta->addStatement( new GenOp(" if ( any( bvec3(@) ) ) {\r\n", windDirAndSpeed ) );
|
||||
|
||||
// Do the branch and detail bending first so that
|
||||
// it can work in pure object space of the tree.
|
||||
LangElement *effect =
|
||||
new GenOp( "windBranchBending( "
|
||||
|
||||
"@.xyz, " // vPos
|
||||
"normalize( normal ), " // vNormal
|
||||
"@, " // vPos
|
||||
"normalize( IN_normal ), " // vNormal
|
||||
|
||||
"@, " // fTime
|
||||
"@.z, " // fWindSpeed
|
||||
|
|
@ -161,13 +165,13 @@ void WindDeformationGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
"@.y, " // fBranchAmp
|
||||
"@.r, " // fBranchAtten
|
||||
|
||||
"dot( @[3], vec4( 1.0 ) ), " // fDetailPhase
|
||||
"dot( @[3], vec4(1) ), " // fDetailPhase
|
||||
"@.z, " // fDetailAmp
|
||||
"@.w, " // fDetailFreq
|
||||
|
||||
|
||||
"@.b )", // fEdgeAtten
|
||||
|
||||
inPosition, // vPos
|
||||
outPosition, // vPos
|
||||
// vNormal
|
||||
|
||||
accumTime, // fTime
|
||||
|
|
@ -183,22 +187,15 @@ void WindDeformationGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
inColor ); // fEdgeAtten
|
||||
|
||||
Var *outPosition = (Var*)LangElement::find( "inPosition" );
|
||||
if ( outPosition )
|
||||
meta->addStatement( new GenOp( " @.xyz = @;\r\n", outPosition, effect, inPosition ) );
|
||||
else
|
||||
{
|
||||
outPosition = new Var;
|
||||
outPosition->setType( "vec3" );
|
||||
outPosition->setName( "inPosition" );
|
||||
meta->addStatement( new GenOp(" vec3 inPosition = @;\r\n", effect, inPosition ) );
|
||||
}
|
||||
meta->addStatement( new GenOp( " @ = @;\r\n", outPosition, effect ) );
|
||||
|
||||
// Now do the trunk bending.
|
||||
effect = new GenOp( "windTrunkBending( @, @.xy, @.z * @.x )",
|
||||
outPosition, windDirAndSpeed, outPosition, windParams );
|
||||
meta->addStatement( new GenOp(" @ = windTrunkBending( @, @.xy, @.z * @.x );\r\n",
|
||||
outPosition, outPosition, windDirAndSpeed, outPosition, windParams ) );
|
||||
|
||||
meta->addStatement( new GenOp(" @ = @;\r\n", outPosition, effect ) );
|
||||
// End the dynamic branch.
|
||||
if ( GFX->getPixelShaderVersion() >= 3.0f )
|
||||
meta->addStatement( new GenOp(" } // [branch]\r\n" ) );
|
||||
}
|
||||
|
||||
ShaderFeatureConstHandles* WindDeformationGLSL::createConstHandles( GFXShader *shader, SimObject *userObject )
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ void TSForestCellBatch::_rebuildBatch()
|
|||
|
||||
// Fill this puppy!
|
||||
ImposterState *vertPtr = mVB.lock();
|
||||
if(!vertPtr) return;
|
||||
|
||||
Vector<ForestItem>::const_iterator item = mItems.begin();
|
||||
|
||||
const F32 radius = mDetail->getRadius();
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "materials/materialManager.h"
|
||||
#include "forest/windDeformation.h"
|
||||
|
||||
using namespace Torque;
|
||||
|
||||
IMPLEMENT_CO_DATABLOCK_V1(TSForestItemData);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue