mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-01 19:43:49 +00:00
Merge branch 'development' into walkabout
Conflicts: Templates/Empty/game/tools/worldEditor/scripts/editors/creator.ed.cs Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs
This commit is contained in:
commit
7ab6731f51
1453 changed files with 95576 additions and 14818 deletions
349
Engine/source/T3D/accumulationVolume.cpp
Normal file
349
Engine/source/T3D/accumulationVolume.cpp
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/accumulationVolume.h"
|
||||
|
||||
#include "scene/sceneManager.h"
|
||||
#include "scene/sceneRenderState.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "gfx/sim/debugDraw.h"
|
||||
#include "util/tempAlloc.h"
|
||||
#include "materials/materialDefinition.h"
|
||||
#include "materials/materialManager.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "materials/matInstance.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "console/console.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "gfx/gfxTextureHandle.h"
|
||||
#include "scene/sceneContainer.h"
|
||||
|
||||
#include "math/mPolyhedron.impl.h"
|
||||
|
||||
Vector< SimObjectPtr<SceneObject> > AccumulationVolume::smAccuObjects;
|
||||
Vector< SimObjectPtr<AccumulationVolume> > AccumulationVolume::smAccuVolumes;
|
||||
|
||||
//#define DEBUG_DRAW
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1( AccumulationVolume );
|
||||
|
||||
ConsoleDocClass( AccumulationVolume,
|
||||
"@brief An invisible shape that allow objects within it to have an accumulation map.\n\n"
|
||||
|
||||
"AccumulationVolume is used to add additional realism to a scene. It's main use is in outdoor scenes "
|
||||
" where objects could benefit from overlaying environment accumulation textures such as sand, snow, etc.\n\n"
|
||||
|
||||
"Objects within the volume must have accumulation enabled in their material. \n\n"
|
||||
|
||||
"@ingroup enviroMisc"
|
||||
);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AccumulationVolume::AccumulationVolume()
|
||||
: mTransformDirty( true ),
|
||||
mSilhouetteExtractor( mPolyhedron )
|
||||
{
|
||||
VECTOR_SET_ASSOCIATION( mWSPoints );
|
||||
VECTOR_SET_ASSOCIATION( mVolumeQueryList );
|
||||
|
||||
//mObjectFlags.set( VisualOccluderFlag );
|
||||
|
||||
mNetFlags.set( Ghostable | ScopeAlways );
|
||||
mObjScale.set( 1.f, 1.f, 1.f );
|
||||
mObjBox.set(
|
||||
Point3F( -0.5f, -0.5f, -0.5f ),
|
||||
Point3F( 0.5f, 0.5f, 0.5f )
|
||||
);
|
||||
|
||||
mObjToWorld.identity();
|
||||
mWorldToObj.identity();
|
||||
|
||||
// Accumulation Texture.
|
||||
mTextureName = "";
|
||||
mAccuTexture = NULL;
|
||||
|
||||
resetWorldBox();
|
||||
}
|
||||
|
||||
AccumulationVolume::~AccumulationVolume()
|
||||
{
|
||||
mAccuTexture = NULL;
|
||||
}
|
||||
|
||||
void AccumulationVolume::initPersistFields()
|
||||
{
|
||||
addProtectedField( "texture", TypeStringFilename, Offset( mTextureName, AccumulationVolume ),
|
||||
&_setTexture, &defaultProtectedGetFn, "Accumulation texture." );
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::consoleInit()
|
||||
{
|
||||
// Disable rendering of occlusion volumes by default.
|
||||
getStaticClassRep()->mIsRenderEnabled = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AccumulationVolume::onAdd()
|
||||
{
|
||||
if( !Parent::onAdd() )
|
||||
return false;
|
||||
|
||||
// Prepare some client side things.
|
||||
if ( isClientObject() )
|
||||
{
|
||||
smAccuVolumes.push_back(this);
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
// Set up the silhouette extractor.
|
||||
mSilhouetteExtractor = SilhouetteExtractorType( mPolyhedron );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AccumulationVolume::onRemove()
|
||||
{
|
||||
if ( isClientObject() )
|
||||
{
|
||||
smAccuVolumes.remove(this);
|
||||
refreshVolumes();
|
||||
}
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::_renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat )
|
||||
{
|
||||
Parent::_renderObject( ri, state, overrideMat );
|
||||
|
||||
#ifdef DEBUG_DRAW
|
||||
if( state->isDiffusePass() )
|
||||
DebugDrawer::get()->drawPolyhedronDebugInfo( mPolyhedron, getTransform(), getScale() );
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::setTransform( const MatrixF& mat )
|
||||
{
|
||||
Parent::setTransform( mat );
|
||||
mTransformDirty = true;
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::buildSilhouette( const SceneCameraState& cameraState, Vector< Point3F >& outPoints )
|
||||
{
|
||||
// Extract the silhouette of the polyhedron. This works differently
|
||||
// depending on whether we project orthogonally or in perspective.
|
||||
|
||||
TempAlloc< U32 > indices( mPolyhedron.getNumPoints() );
|
||||
U32 numPoints;
|
||||
|
||||
if( cameraState.getFrustum().isOrtho() )
|
||||
{
|
||||
// Transform the view direction into object space.
|
||||
|
||||
Point3F osViewDir;
|
||||
getWorldTransform().mulV( cameraState.getViewDirection(), &osViewDir );
|
||||
|
||||
// And extract the silhouette.
|
||||
|
||||
SilhouetteExtractorOrtho< PolyhedronType > extractor( mPolyhedron );
|
||||
numPoints = extractor.extractSilhouette( osViewDir, indices, indices.size );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a transform to go from view space to object space.
|
||||
|
||||
MatrixF camView( true );
|
||||
camView.scale( Point3F( 1.0f / getScale().x, 1.0f / getScale().y, 1.0f / getScale().z ) );
|
||||
camView.mul( getRenderWorldTransform() );
|
||||
camView.mul( cameraState.getViewWorldMatrix() );
|
||||
|
||||
// Do a perspective-correct silhouette extraction.
|
||||
|
||||
numPoints = mSilhouetteExtractor.extractSilhouette(
|
||||
camView,
|
||||
indices, indices.size );
|
||||
}
|
||||
|
||||
// If we haven't yet, transform the polyhedron's points
|
||||
// to world space.
|
||||
|
||||
if( mTransformDirty )
|
||||
{
|
||||
const U32 numPoints = mPolyhedron.getNumPoints();
|
||||
const PolyhedronType::PointType* points = getPolyhedron().getPoints();
|
||||
|
||||
mWSPoints.setSize( numPoints );
|
||||
for( U32 i = 0; i < numPoints; ++ i )
|
||||
{
|
||||
Point3F p = points[ i ];
|
||||
p.convolve( getScale() );
|
||||
getTransform().mulP( p, &mWSPoints[ i ] );
|
||||
}
|
||||
|
||||
mTransformDirty = false;
|
||||
}
|
||||
|
||||
// Now store the points.
|
||||
|
||||
outPoints.setSize( numPoints );
|
||||
for( U32 i = 0; i < numPoints; ++ i )
|
||||
outPoints[ i ] = mWSPoints[ indices[ i ] ];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
U32 AccumulationVolume::packUpdate( NetConnection *connection, U32 mask, BitStream *stream )
|
||||
{
|
||||
U32 retMask = Parent::packUpdate( connection, mask, stream );
|
||||
|
||||
if (stream->writeFlag(mask & InitialUpdateMask))
|
||||
{
|
||||
stream->write( mTextureName );
|
||||
}
|
||||
|
||||
return retMask;
|
||||
}
|
||||
|
||||
void AccumulationVolume::unpackUpdate( NetConnection *connection, BitStream *stream )
|
||||
{
|
||||
Parent::unpackUpdate( connection, stream );
|
||||
|
||||
if (stream->readFlag())
|
||||
{
|
||||
stream->read( &mTextureName );
|
||||
setTexture(mTextureName);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AccumulationVolume::inspectPostApply()
|
||||
{
|
||||
Parent::inspectPostApply();
|
||||
setMaskBits(U32(-1) );
|
||||
}
|
||||
|
||||
void AccumulationVolume::setTexture( const String& name )
|
||||
{
|
||||
mTextureName = name;
|
||||
if ( isClientObject() && mTextureName.isNotEmpty() )
|
||||
{
|
||||
mAccuTexture.set(mTextureName, &GFXDefaultStaticDiffuseProfile, "AccumulationVolume::mAccuTexture");
|
||||
if ( mAccuTexture.isNull() )
|
||||
Con::warnf( "AccumulationVolume::setTexture - Unable to load texture: %s", mTextureName.c_str() );
|
||||
}
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Static Functions
|
||||
//-----------------------------------------------------------------------------
|
||||
bool AccumulationVolume::_setTexture( void *object, const char *index, const char *data )
|
||||
{
|
||||
AccumulationVolume* volume = reinterpret_cast< AccumulationVolume* >( object );
|
||||
volume->setTexture( data );
|
||||
return false;
|
||||
}
|
||||
|
||||
void AccumulationVolume::refreshVolumes()
|
||||
{
|
||||
// This function tests each accumulation object to
|
||||
// see if it's within the bounds of an accumulation
|
||||
// volume. If so, it will pass on the accumulation
|
||||
// texture of the volume to the object.
|
||||
|
||||
// This function should only be called when something
|
||||
// global like change of volume or material occurs.
|
||||
|
||||
// Clear old data.
|
||||
for (S32 n = 0; n < smAccuObjects.size(); ++n)
|
||||
{
|
||||
SimObjectPtr<SceneObject> object = smAccuObjects[n];
|
||||
if ( object.isValid() )
|
||||
object->mAccuTex = GFXTexHandle::ZERO;
|
||||
}
|
||||
|
||||
//
|
||||
for (S32 i = 0; i < smAccuVolumes.size(); ++i)
|
||||
{
|
||||
SimObjectPtr<AccumulationVolume> volume = smAccuVolumes[i];
|
||||
if ( volume.isNull() ) continue;
|
||||
|
||||
for (S32 n = 0; n < smAccuObjects.size(); ++n)
|
||||
{
|
||||
SimObjectPtr<SceneObject> object = smAccuObjects[n];
|
||||
if ( object.isNull() ) continue;
|
||||
|
||||
if ( volume->containsPoint(object->getPosition()) )
|
||||
object->mAccuTex = volume->mAccuTexture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Accumulation Object Management.
|
||||
void AccumulationVolume::addObject(SimObjectPtr<SceneObject> object)
|
||||
{
|
||||
smAccuObjects.push_back(object);
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
void AccumulationVolume::removeObject(SimObjectPtr<SceneObject> object)
|
||||
{
|
||||
smAccuObjects.remove(object);
|
||||
refreshVolumes();
|
||||
}
|
||||
|
||||
void AccumulationVolume::updateObject(SceneObject* object)
|
||||
{
|
||||
// This function is called when an individual object
|
||||
// has been moved. Tests to see if it's in any of the
|
||||
// accumulation volumes.
|
||||
|
||||
// We use ZERO instead of NULL so the accumulation
|
||||
// texture will be updated in renderMeshMgr.
|
||||
object->mAccuTex = GFXTexHandle::ZERO;
|
||||
|
||||
for (S32 i = 0; i < smAccuVolumes.size(); ++i)
|
||||
{
|
||||
SimObjectPtr<AccumulationVolume> volume = smAccuVolumes[i];
|
||||
if ( volume.isNull() ) continue;
|
||||
|
||||
if ( volume->containsPoint(object->getPosition()) )
|
||||
object->mAccuTex = volume->mAccuTexture;
|
||||
}
|
||||
}
|
||||
104
Engine/source/T3D/accumulationVolume.h
Normal file
104
Engine/source/T3D/accumulationVolume.h
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _ACCUMULATIONVOLUME_H_
|
||||
#define _ACCUMULATIONVOLUME_H_
|
||||
|
||||
#ifndef _SCENEPOLYHEDRALSPACE_H_
|
||||
#include "scene/scenePolyhedralSpace.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MSILHOUETTEEXTRACTOR_H_
|
||||
#include "math/mSilhouetteExtractor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _GFXDEVICE_H_
|
||||
#include "gfx/gfxDevice.h"
|
||||
#endif
|
||||
|
||||
/// A volume in space that blocks visibility.
|
||||
class AccumulationVolume : public ScenePolyhedralSpace
|
||||
{
|
||||
public:
|
||||
|
||||
typedef ScenePolyhedralSpace Parent;
|
||||
|
||||
protected:
|
||||
|
||||
typedef SilhouetteExtractorPerspective< PolyhedronType > SilhouetteExtractorType;
|
||||
|
||||
/// Whether the volume's transform has changed and we need to recompute
|
||||
/// transform-based data.
|
||||
bool mTransformDirty;
|
||||
|
||||
/// World-space points of the volume's polyhedron.
|
||||
Vector< Point3F > mWSPoints;
|
||||
|
||||
/// Silhouette extractor when using perspective projections.
|
||||
SilhouetteExtractorType mSilhouetteExtractor;
|
||||
|
||||
mutable Vector< SceneObject* > mVolumeQueryList;
|
||||
|
||||
// Name (path) of the accumulation texture.
|
||||
String mTextureName;
|
||||
|
||||
// SceneSpace.
|
||||
virtual void _renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat );
|
||||
|
||||
public:
|
||||
|
||||
GFXTexHandle mAccuTexture;
|
||||
|
||||
AccumulationVolume();
|
||||
~AccumulationVolume();
|
||||
|
||||
// SimObject.
|
||||
DECLARE_CONOBJECT( AccumulationVolume );
|
||||
DECLARE_DESCRIPTION( "Allows objects in an area to have accumulation effect applied." );
|
||||
DECLARE_CATEGORY( "3D Scene" );
|
||||
|
||||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
void inspectPostApply();
|
||||
void setTexture( const String& name );
|
||||
|
||||
// Static Functions.
|
||||
static void consoleInit();
|
||||
static void initPersistFields();
|
||||
static Vector< SimObjectPtr<SceneObject> > smAccuObjects;
|
||||
static Vector< SimObjectPtr<AccumulationVolume> > smAccuVolumes;
|
||||
static void addObject(SimObjectPtr<SceneObject> object);
|
||||
static void removeObject(SimObjectPtr<SceneObject> object);
|
||||
static void refreshVolumes();
|
||||
static bool _setTexture( void *object, const char *index, const char *data );
|
||||
static void updateObject(SceneObject* object);
|
||||
|
||||
// Network
|
||||
U32 packUpdate( NetConnection *, U32 mask, BitStream *stream );
|
||||
void unpackUpdate( NetConnection *, BitStream *stream );
|
||||
|
||||
// SceneObject.
|
||||
virtual void buildSilhouette( const SceneCameraState& cameraState, Vector< Point3F >& outPoints );
|
||||
virtual void setTransform( const MatrixF& mat );
|
||||
};
|
||||
|
||||
#endif // !_AccumulationVolume_H_
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
#include "T3D/player.h"
|
||||
#include "T3D/gameBase/moveManager.h"
|
||||
#include "console/consoleInternal.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
|
||||
IMPLEMENT_CONOBJECT( AIClient );
|
||||
|
|
@ -52,6 +53,8 @@ ConsoleDocClass( AIClient,
|
|||
"@ingroup Networking\n"
|
||||
);
|
||||
|
||||
IMPLEMENT_CALLBACK(AIClient, onConnect, void, (const char* idString), (idString),"");
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
|
@ -415,15 +418,17 @@ void AIClient::onAdd( const char *nameSpace ) {
|
|||
/**
|
||||
* Sets the move speed for an AI object
|
||||
*/
|
||||
ConsoleMethod( AIClient, setMoveSpeed, void, 3, 3, "ai.setMoveSpeed( float );" ) {
|
||||
DefineConsoleMethod( AIClient, setMoveSpeed, void, (F32 speed), , "ai.setMoveSpeed( float );" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
ai->setMoveSpeed( dAtof( argv[2] ) );
|
||||
ai->setMoveSpeed( speed );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops all AI movement, halt!
|
||||
*/
|
||||
ConsoleMethod( AIClient, stop, void, 2, 2, "ai.stop();" ) {
|
||||
DefineConsoleMethod( AIClient, stop, void, (),, "ai.stop();" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
ai->setMoveMode( AIClient::ModeStop );
|
||||
}
|
||||
|
|
@ -431,10 +436,9 @@ ConsoleMethod( AIClient, stop, void, 2, 2, "ai.stop();" ) {
|
|||
/**
|
||||
* Tells the AI to aim at the location provided
|
||||
*/
|
||||
ConsoleMethod( AIClient, setAimLocation, void, 3, 3, "ai.setAimLocation( x y z );" ) {
|
||||
DefineConsoleMethod( AIClient, setAimLocation, void, (Point3F v), , "ai.setAimLocation( x y z );" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
Point3F v( 0.0f,0.0f,0.0f );
|
||||
dSscanf( argv[2], "%f %f %f", &v.x, &v.y, &v.z );
|
||||
|
||||
ai->setAimLocation( v );
|
||||
}
|
||||
|
|
@ -442,10 +446,9 @@ ConsoleMethod( AIClient, setAimLocation, void, 3, 3, "ai.setAimLocation( x y z )
|
|||
/**
|
||||
* Tells the AI to move to the location provided
|
||||
*/
|
||||
ConsoleMethod( AIClient, setMoveDestination, void, 3, 3, "ai.setMoveDestination( x y z );" ) {
|
||||
DefineConsoleMethod( AIClient, setMoveDestination, void, (Point3F v), , "ai.setMoveDestination( x y z );" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
Point3F v( 0.0f, 0.0f, 0.0f );
|
||||
dSscanf( argv[2], "%f %f", &v.x, &v.y );
|
||||
|
||||
ai->setMoveDestination( v );
|
||||
}
|
||||
|
|
@ -453,40 +456,31 @@ ConsoleMethod( AIClient, setMoveDestination, void, 3, 3, "ai.setMoveDestination(
|
|||
/**
|
||||
* Returns the point the AI is aiming at
|
||||
*/
|
||||
ConsoleMethod( AIClient, getAimLocation, const char *, 2, 2, "ai.getAimLocation();" ) {
|
||||
DefineConsoleMethod( AIClient, getAimLocation, Point3F, (),, "ai.getAimLocation();" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
Point3F aimPoint = ai->getAimLocation();
|
||||
|
||||
static const U32 bufSize = 256;
|
||||
char *returnBuffer = Con::getReturnBuffer( bufSize );
|
||||
dSprintf( returnBuffer, bufSize, "%f %f %f", aimPoint.x, aimPoint.y, aimPoint.z );
|
||||
|
||||
return returnBuffer;
|
||||
return ai->getAimLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the point the AI is set to move to
|
||||
*/
|
||||
ConsoleMethod( AIClient, getMoveDestination, const char *, 2, 2, "ai.getMoveDestination();" ) {
|
||||
DefineConsoleMethod( AIClient, getMoveDestination, Point3F, (),, "ai.getMoveDestination();" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
Point3F movePoint = ai->getMoveDestination();
|
||||
|
||||
static const U32 bufSize = 256;
|
||||
char *returnBuffer = Con::getReturnBuffer( bufSize );
|
||||
dSprintf( returnBuffer, bufSize, "%f %f %f", movePoint.x, movePoint.y, movePoint.z );
|
||||
|
||||
return returnBuffer;
|
||||
return ai->getMoveDestination();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bots target object
|
||||
*/
|
||||
ConsoleMethod( AIClient, setTargetObject, void, 3, 3, "ai.setTargetObject( obj );" ) {
|
||||
DefineConsoleMethod( AIClient, setTargetObject, void, (const char * objName), , "ai.setTargetObject( obj );" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
|
||||
// Find the target
|
||||
ShapeBase *targetObject;
|
||||
if( Sim::findObject( argv[2], targetObject ) )
|
||||
if( Sim::findObject( objName, targetObject ) )
|
||||
ai->setTargetObject( targetObject );
|
||||
else
|
||||
ai->setTargetObject( NULL );
|
||||
|
|
@ -495,7 +489,8 @@ ConsoleMethod( AIClient, setTargetObject, void, 3, 3, "ai.setTargetObject( obj )
|
|||
/**
|
||||
* Gets the object the AI is targeting
|
||||
*/
|
||||
ConsoleMethod( AIClient, getTargetObject, S32, 2, 2, "ai.getTargetObject();" ) {
|
||||
DefineConsoleMethod( AIClient, getTargetObject, S32, (),, "ai.getTargetObject();" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
|
||||
return ai->getTargetObject();
|
||||
|
|
@ -504,7 +499,8 @@ ConsoleMethod( AIClient, getTargetObject, S32, 2, 2, "ai.getTargetObject();" ) {
|
|||
/**
|
||||
* Tells the bot the mission is cycling
|
||||
*/
|
||||
ConsoleMethod( AIClient, missionCycleCleanup, void, 2, 2, "ai.missionCycleCleanup();" ) {
|
||||
DefineConsoleMethod( AIClient, missionCycleCleanup, void, (),, "ai.missionCycleCleanup();" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient*>( object );
|
||||
ai->missionCycleCleanup();
|
||||
}
|
||||
|
|
@ -512,7 +508,8 @@ ConsoleMethod( AIClient, missionCycleCleanup, void, 2, 2, "ai.missionCycleCleanu
|
|||
/**
|
||||
* Sets the AI to run mode
|
||||
*/
|
||||
ConsoleMethod( AIClient, move, void, 2, 2, "ai.move();" ) {
|
||||
DefineConsoleMethod( AIClient, move, void, (),, "ai.move();" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
ai->setMoveMode( AIClient::ModeMove );
|
||||
}
|
||||
|
|
@ -520,21 +517,17 @@ ConsoleMethod( AIClient, move, void, 2, 2, "ai.move();" ) {
|
|||
/**
|
||||
* Gets the AI's location in the world
|
||||
*/
|
||||
ConsoleMethod( AIClient, getLocation, const char *, 2, 2, "ai.getLocation();" ) {
|
||||
DefineConsoleMethod( AIClient, getLocation, Point3F, (),, "ai.getLocation();" )
|
||||
{
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
Point3F locPoint = ai->getLocation();
|
||||
|
||||
static const U32 bufSize = 256;
|
||||
char *returnBuffer = Con::getReturnBuffer( bufSize );
|
||||
dSprintf( returnBuffer, bufSize, "%f %f %f", locPoint.x, locPoint.y, locPoint.z );
|
||||
|
||||
return returnBuffer;
|
||||
return ai->getLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an AI Player to the game
|
||||
*/
|
||||
ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassType'] );" ) {
|
||||
DefineConsoleFunction( aiAddPlayer, S32, (const char * name, const char * ns), (""), "'playerName'[, 'AIClassType'] );")
|
||||
{
|
||||
// Create the player
|
||||
AIClient *aiPlayer = new AIClient();
|
||||
aiPlayer->registerObject();
|
||||
|
|
@ -548,18 +541,13 @@ ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassT
|
|||
SimGroup *g = Sim::getClientGroup();
|
||||
g->addObject( aiPlayer );
|
||||
|
||||
char *name = new char[ dStrlen( argv[1] ) + 1];
|
||||
char *ns = new char[ dStrlen( argv[2] ) + 1];
|
||||
|
||||
dStrcpy( name, argv[1] );
|
||||
dStrcpy( ns, argv[2] );
|
||||
|
||||
// Execute the connect console function, this is the same
|
||||
// onConnect function invoked for normal client connections
|
||||
Con::executef( aiPlayer, "onConnect", name );
|
||||
aiPlayer->onConnect_callback( name );
|
||||
|
||||
// Now execute the onAdd command and feed it the namespace
|
||||
if( argc > 2 )
|
||||
if(dStrcmp( ns,"" ) != 0 )
|
||||
aiPlayer->onAdd( ns );
|
||||
else
|
||||
aiPlayer->onAdd( "AIClient" );
|
||||
|
|
@ -571,7 +559,8 @@ ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassT
|
|||
/**
|
||||
* Tells the AI to move forward 100 units...TEST FXN
|
||||
*/
|
||||
ConsoleMethod( AIClient, moveForward, void, 2, 2, "ai.moveForward();" ) {
|
||||
DefineConsoleMethod( AIClient, moveForward, void, (),, "ai.moveForward();" )
|
||||
{
|
||||
|
||||
AIClient *ai = static_cast<AIClient *>( object );
|
||||
ShapeBase *player = dynamic_cast<ShapeBase*>(ai->getControlObject());
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ class AIClient : public AIConnection {
|
|||
|
||||
DECLARE_CONOBJECT( AIClient );
|
||||
|
||||
DECLARE_CALLBACK( void, onConnect, (const char* idString) );
|
||||
|
||||
enum {
|
||||
ModeStop = 0,
|
||||
ModeMove,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "T3D/aiConnection.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT( AIConnection );
|
||||
|
||||
|
|
@ -159,7 +160,7 @@ ConsoleFunction(aiConnect, S32 , 2, 20, "(...)"
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleMethod(AIConnection,setMove,void,4, 4,"(string field, float value)"
|
||||
DefineConsoleMethod(AIConnection, setMove, void, (const char * field, F32 value), ,"(string field, float value)"
|
||||
"Set a field on the current move.\n\n"
|
||||
"@param field One of {'x','y','z','yaw','pitch','roll'}\n"
|
||||
"@param value Value to set field to.")
|
||||
|
|
@ -167,59 +168,59 @@ ConsoleMethod(AIConnection,setMove,void,4, 4,"(string field, float value)"
|
|||
Move move = object->getMove();
|
||||
|
||||
// Ok, a little slow for now, but this is just an example..
|
||||
if (!dStricmp(argv[2],"x"))
|
||||
move.x = mClampF(dAtof(argv[3]),-1,1);
|
||||
if (!dStricmp(field,"x"))
|
||||
move.x = mClampF(value,-1,1);
|
||||
else
|
||||
if (!dStricmp(argv[2],"y"))
|
||||
move.y = mClampF(dAtof(argv[3]),-1,1);
|
||||
if (!dStricmp(field,"y"))
|
||||
move.y = mClampF(value,-1,1);
|
||||
else
|
||||
if (!dStricmp(argv[2],"z"))
|
||||
move.z = mClampF(dAtof(argv[3]),-1,1);
|
||||
if (!dStricmp(field,"z"))
|
||||
move.z = mClampF(value,-1,1);
|
||||
else
|
||||
if (!dStricmp(argv[2],"yaw"))
|
||||
move.yaw = moveClamp(dAtof(argv[3]));
|
||||
if (!dStricmp(field,"yaw"))
|
||||
move.yaw = moveClamp(value);
|
||||
else
|
||||
if (!dStricmp(argv[2],"pitch"))
|
||||
move.pitch = moveClamp(dAtof(argv[3]));
|
||||
if (!dStricmp(field,"pitch"))
|
||||
move.pitch = moveClamp(value);
|
||||
else
|
||||
if (!dStricmp(argv[2],"roll"))
|
||||
move.roll = moveClamp(dAtof(argv[3]));
|
||||
if (!dStricmp(field,"roll"))
|
||||
move.roll = moveClamp(value);
|
||||
|
||||
//
|
||||
object->setMove(&move);
|
||||
}
|
||||
|
||||
ConsoleMethod(AIConnection,getMove,F32,3, 3,"(string field)"
|
||||
DefineConsoleMethod(AIConnection,getMove,F32, (const char * field), ,"(string field)"
|
||||
"Get the given field of a move.\n\n"
|
||||
"@param field One of {'x','y','z','yaw','pitch','roll'}\n"
|
||||
"@returns The requested field on the current move.")
|
||||
{
|
||||
const Move& move = object->getMove();
|
||||
if (!dStricmp(argv[2],"x"))
|
||||
if (!dStricmp(field,"x"))
|
||||
return move.x;
|
||||
if (!dStricmp(argv[2],"y"))
|
||||
if (!dStricmp(field,"y"))
|
||||
return move.y;
|
||||
if (!dStricmp(argv[2],"z"))
|
||||
if (!dStricmp(field,"z"))
|
||||
return move.z;
|
||||
if (!dStricmp(argv[2],"yaw"))
|
||||
if (!dStricmp(field,"yaw"))
|
||||
return move.yaw;
|
||||
if (!dStricmp(argv[2],"pitch"))
|
||||
if (!dStricmp(field,"pitch"))
|
||||
return move.pitch;
|
||||
if (!dStricmp(argv[2],"roll"))
|
||||
if (!dStricmp(field,"roll"))
|
||||
return move.roll;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ConsoleMethod(AIConnection,setFreeLook,void,3, 3,"(bool isFreeLook)"
|
||||
DefineConsoleMethod(AIConnection,setFreeLook,void,(bool isFreeLook), ,"(bool isFreeLook)"
|
||||
"Enable/disable freelook on the current move.")
|
||||
{
|
||||
Move move = object->getMove();
|
||||
move.freeLook = dAtob(argv[2]);
|
||||
move.freeLook = isFreeLook;
|
||||
object->setMove(&move);
|
||||
}
|
||||
|
||||
ConsoleMethod(AIConnection,getFreeLook,bool,2, 2,"getFreeLook()"
|
||||
DefineConsoleMethod(AIConnection, getFreeLook, bool, (), ,"getFreeLook()"
|
||||
"Is freelook on for the current move?")
|
||||
{
|
||||
return object->getMove().freeLook;
|
||||
|
|
@ -228,21 +229,20 @@ ConsoleMethod(AIConnection,getFreeLook,bool,2, 2,"getFreeLook()"
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod(AIConnection,setTrigger,void,4, 4,"(int trigger, bool set)"
|
||||
DefineConsoleMethod(AIConnection,setTrigger,void, (S32 idx, bool set), ,"(int trigger, bool set)"
|
||||
"Set a trigger.")
|
||||
{
|
||||
S32 idx = dAtoi(argv[2]);
|
||||
if (idx >= 0 && idx < MaxTriggerKeys) {
|
||||
if (idx >= 0 && idx < MaxTriggerKeys)
|
||||
{
|
||||
Move move = object->getMove();
|
||||
move.trigger[idx] = dAtob(argv[3]);
|
||||
move.trigger[idx] = set;
|
||||
object->setMove(&move);
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod(AIConnection,getTrigger,bool,4, 4,"(int trigger)"
|
||||
DefineConsoleMethod(AIConnection,getTrigger,bool, (S32 idx), ,"(int trigger)"
|
||||
"Is the given trigger set?")
|
||||
{
|
||||
S32 idx = dAtoi(argv[2]);
|
||||
if (idx >= 0 && idx < MaxTriggerKeys)
|
||||
return object->getMove().trigger[idx];
|
||||
return false;
|
||||
|
|
@ -251,7 +251,7 @@ ConsoleMethod(AIConnection,getTrigger,bool,4, 4,"(int trigger)"
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod(AIConnection,getAddress,const char*,2, 2,"")
|
||||
DefineConsoleMethod(AIConnection,getAddress,const char*,(), ,"")
|
||||
{
|
||||
// Override the netConnection method to return to indicate
|
||||
// this is an ai connection.
|
||||
|
|
|
|||
|
|
@ -1119,23 +1119,21 @@ ConsoleDocFragment _setAimObject(
|
|||
"AIPlayer",
|
||||
"void setAimObject(GameBase targetObject, Point3F offset);"
|
||||
);
|
||||
ConsoleMethod( AIPlayer, setAimObject, void, 3, 4, "( GameBase obj, [Point3F offset] )"
|
||||
|
||||
DefineConsoleMethod( AIPlayer, setAimObject, void, ( const char * objName, Point3F offset ), (Point3F::Zero), "( GameBase obj, [Point3F offset] )"
|
||||
"Sets the bot's target object. Optionally set an offset from target location."
|
||||
"@hide")
|
||||
{
|
||||
Point3F off( 0.0f, 0.0f, 0.0f );
|
||||
|
||||
// Find the target
|
||||
GameBase *targetObject;
|
||||
if( Sim::findObject( argv[2], targetObject ) )
|
||||
if( Sim::findObject( objName, targetObject ) )
|
||||
{
|
||||
if (argc == 4)
|
||||
dSscanf( argv[3], "%g %g %g", &off.x, &off.y, &off.z );
|
||||
|
||||
object->setAimObject( targetObject, off );
|
||||
object->setAimObject( targetObject, offset );
|
||||
}
|
||||
else
|
||||
object->setAimObject( 0, off );
|
||||
object->setAimObject( 0, offset );
|
||||
}
|
||||
|
||||
DefineEngineMethod( AIPlayer, getAimObject, S32, (),,
|
||||
|
|
|
|||
|
|
@ -1860,7 +1860,7 @@ DefineEngineMethod( Camera, setOffset, void, (Point3F offset), ,
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineMethod( Camera, setOrbitMode, void, (GameBase* orbitObject, TransformF orbitPoint, F32 minDistance, F32 maxDistance,
|
||||
F32 initDistance, bool ownClientObj, Point3F offset, bool locked), (false, Point3F(0.0f, 0.0f, 0.0f), false),
|
||||
F32 initDistance, bool ownClientObj, Point3F offset, bool locked), (false, Point3F::Zero, false),
|
||||
"Set the camera to orbit around the given object, or if none is given, around the given point.\n\n"
|
||||
"@param orbitObject The object to orbit around. If no object is given (0 or blank string is passed in) use the orbitPoint instead\n"
|
||||
"@param orbitPoint The point to orbit around when no object is given. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform().\n"
|
||||
|
|
@ -1883,7 +1883,7 @@ DefineEngineMethod( Camera, setOrbitMode, void, (GameBase* orbitObject, Transfor
|
|||
|
||||
DefineEngineMethod( Camera, setOrbitObject, bool, (GameBase* orbitObject, VectorF rotation, F32 minDistance,
|
||||
F32 maxDistance, F32 initDistance, bool ownClientObject, Point3F offset, bool locked),
|
||||
(false, Point3F(0.0f, 0.0f, 0.0f), false),
|
||||
(false, Point3F::Zero, false),
|
||||
"Set the camera to orbit around a given object.\n\n"
|
||||
"@param orbitObject The object to orbit around.\n"
|
||||
"@param rotation The initial camera rotation about the object in radians in the form of \"x y z\".\n"
|
||||
|
|
@ -1911,7 +1911,7 @@ DefineEngineMethod( Camera, setOrbitObject, bool, (GameBase* orbitObject, Vector
|
|||
|
||||
DefineEngineMethod( Camera, setOrbitPoint, void, (TransformF orbitPoint, F32 minDistance, F32 maxDistance, F32 initDistance,
|
||||
Point3F offset, bool locked),
|
||||
(Point3F(0.0f, 0.0f, 0.0f), false),
|
||||
(Point3F::Zero, false),
|
||||
"Set the camera to orbit around a given point.\n\n"
|
||||
"@param orbitPoint The point to orbit around. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform().\n"
|
||||
"@param minDistance The minimum distance allowed to the orbit object or point.\n"
|
||||
|
|
@ -1929,7 +1929,7 @@ DefineEngineMethod( Camera, setOrbitPoint, void, (TransformF orbitPoint, F32 min
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DefineEngineMethod( Camera, setTrackObject, bool, (GameBase* trackObject, Point3F offset), (Point3F(0.0f, 0.0f, 0.0f)),
|
||||
DefineEngineMethod( Camera, setTrackObject, bool, (GameBase* trackObject, Point3F offset), (Point3F::Zero),
|
||||
"Set the camera to track a given object.\n\n"
|
||||
"@param trackObject The object to track.\n"
|
||||
"@param offset [optional] An offset added to the camera's position. Default is no offset.\n"
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ void CameraSpline::renderTimeMap()
|
|||
|
||||
// Render the buffer
|
||||
GFX->pushWorldMatrix();
|
||||
GFX->disableShaders();
|
||||
GFX->setupGenericShaders();
|
||||
GFX->setVertexBuffer(vb);
|
||||
GFX->drawPrimitive(GFXLineStrip,0,index);
|
||||
GFX->popWorldMatrix();
|
||||
|
|
|
|||
|
|
@ -138,8 +138,17 @@ ConsoleDocClass( Explosion,
|
|||
|
||||
MRandomLCG sgRandom(0xdeadbeef);
|
||||
|
||||
//WLE - Vince - The defaults are bad, the whole point of calling this function\
|
||||
//is to determine the explosion coverage on a object. Why would you want them
|
||||
//To call this with a null for the ID? In fact, it just returns a 1f if
|
||||
//it can't find the object. Seems useless to me. Cause how can I apply
|
||||
//damage to a object that doesn't exist?
|
||||
|
||||
DefineEngineFunction(calcExplosionCoverage, F32, (Point3F pos, S32 id, U32 covMask),(Point3F(0.0f,0.0f,0.0f), NULL, NULL),
|
||||
//I could possible see a use with passing in a null covMask, but even that
|
||||
//sounds flaky because it will be 100 percent if your saying not to take
|
||||
//any thing in consideration for coverage. So I'm removing these defaults they are just bad.
|
||||
|
||||
DefineEngineFunction(calcExplosionCoverage, F32, (Point3F pos, S32 id, U32 covMask),,
|
||||
"@brief Calculates how much an explosion effects a specific object.\n\n"
|
||||
"Use this to determine how much damage to apply to objects based on their "
|
||||
"distance from the explosion's center point, and whether the explosion is "
|
||||
|
|
|
|||
|
|
@ -929,13 +929,10 @@ DefineEngineMethod(Lightning, strikeRandomPoint, void, (),,
|
|||
object->strikeRandomPoint();
|
||||
}
|
||||
|
||||
DefineEngineMethod(Lightning, strikeObject, void, (S32 id), (NULL),
|
||||
DefineEngineMethod(Lightning, strikeObject, void, (ShapeBase* pSB),,
|
||||
"Creates a LightningStrikeEvent which strikes a specific object.\n"
|
||||
"@note This method is currently unimplemented.\n" )
|
||||
{
|
||||
ShapeBase* pSB;
|
||||
|
||||
if (object->isServerObject() && Sim::findObject(id, pSB))
|
||||
object->strikeObject(pSB);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ ParticleEmitterData::ParticleEmitterData()
|
|||
blendStyle = ParticleRenderInst::BlendUndefined;
|
||||
sortParticles = false;
|
||||
renderReflection = true;
|
||||
glow = false;
|
||||
reverseOrder = false;
|
||||
textureName = 0;
|
||||
textureHandle = 0;
|
||||
|
|
@ -289,6 +290,9 @@ void ParticleEmitterData::initPersistFields()
|
|||
addField( "renderReflection", TYPEID< bool >(), Offset(renderReflection, ParticleEmitterData),
|
||||
"Controls whether particles are rendered onto reflective surfaces like water." );
|
||||
|
||||
addField("glow", TYPEID< bool >(), Offset(glow, ParticleEmitterData),
|
||||
"If true, the particles are rendered to the glow buffer as well.");
|
||||
|
||||
//@}
|
||||
|
||||
endGroup( "ParticleEmitterData" );
|
||||
|
|
@ -356,6 +360,7 @@ void ParticleEmitterData::packData(BitStream* stream)
|
|||
}
|
||||
stream->writeFlag(highResOnly);
|
||||
stream->writeFlag(renderReflection);
|
||||
stream->writeFlag(glow);
|
||||
stream->writeInt( blendStyle, 4 );
|
||||
}
|
||||
|
||||
|
|
@ -418,6 +423,7 @@ void ParticleEmitterData::unpackData(BitStream* stream)
|
|||
}
|
||||
highResOnly = stream->readFlag();
|
||||
renderReflection = stream->readFlag();
|
||||
glow = stream->readFlag();
|
||||
blendStyle = stream->readInt( 4 );
|
||||
}
|
||||
|
||||
|
|
@ -909,6 +915,8 @@ void ParticleEmitter::prepRenderImage(SceneRenderState* state)
|
|||
|
||||
ri->blendStyle = mDataBlock->blendStyle;
|
||||
|
||||
ri->glow = mDataBlock->glow;
|
||||
|
||||
// use first particle's texture unless there is an emitter texture to override it
|
||||
if (mDataBlock->textureHandle)
|
||||
ri->diffuseTex = &*(mDataBlock->textureHandle);
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ class ParticleEmitterData : public GameBaseData
|
|||
GFXTexHandle textureHandle; ///< Emitter texture handle from txrName
|
||||
bool highResOnly; ///< This particle system should not use the mixed-resolution particle rendering
|
||||
bool renderReflection; ///< Enables this emitter to render into reflection passes.
|
||||
bool glow; ///< Renders this emitter into the glow buffer.
|
||||
|
||||
bool reload();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -393,8 +393,9 @@ void ParticleEmitterNode::setEmitterDataBlock(ParticleEmitterData* data)
|
|||
|
||||
mEmitterDatablock = data;
|
||||
}
|
||||
|
||||
DefineEngineMethod(ParticleEmitterNode, setEmitterDataBlock, void, (ParticleEmitterData* emitterDatablock), (0),
|
||||
|
||||
|
||||
DefineEngineMethod(ParticleEmitterNode, setEmitterDataBlock, void, (ParticleEmitterData* emitterDatablock), (NULL),
|
||||
"Assigns the datablock for this emitter node.\n"
|
||||
"@param emitterDatablock ParticleEmitterData datablock to assign\n"
|
||||
"@tsexample\n"
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ DefineEngineMethod(Precipitation, modifyStorm, void, (F32 percentage, F32 second
|
|||
object->modifyStorm(percentage, S32(seconds * 1000.0f));
|
||||
}
|
||||
|
||||
DefineEngineMethod(Precipitation, setTurbulence, void, (F32 max, F32 speed, F32 seconds), (1.0f, 5.0f, 5.0),
|
||||
DefineEngineMethod(Precipitation, setTurbulence, void, (F32 max, F32 speed, F32 seconds), (1.0f, 5.0f, 5.0f),
|
||||
"Smoothly change the turbulence parameters over a period of time.\n"
|
||||
"@param max New #maxTurbulence value. Set to 0 to disable turbulence.\n"
|
||||
"@param speed New #turbulenceSpeed value.\n"
|
||||
|
|
@ -1666,7 +1666,7 @@ void Precipitation::renderObject(ObjectRenderInst *ri, SceneRenderState *state,
|
|||
}
|
||||
else
|
||||
{
|
||||
GFX->disableShaders();
|
||||
GFX->setupGenericShaders(GFXDevice::GSTexture);
|
||||
|
||||
// We don't support distance fade or lighting without shaders.
|
||||
GFX->setStateBlock(mDistantSB);
|
||||
|
|
@ -1799,7 +1799,7 @@ void Precipitation::renderObject(ObjectRenderInst *ri, SceneRenderState *state,
|
|||
GFX->setShaderConstBuffer(mSplashShaderConsts);
|
||||
}
|
||||
else
|
||||
GFX->disableShaders();
|
||||
GFX->setupGenericShaders(GFXDevice::GSTexture);
|
||||
|
||||
while (curr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -672,9 +672,9 @@ void Ribbon::createBuffers(SceneRenderState *state, GFXVertexBufferHandle<GFXVer
|
|||
Point3F pointA = verts[count-1].point;
|
||||
Point3F pointB = verts[0].point;
|
||||
|
||||
verts.unlock();
|
||||
pb.unlock();
|
||||
|
||||
verts.unlock();
|
||||
|
||||
Point3F diffSize = pointA - pointB;
|
||||
|
||||
Box3F objBox;
|
||||
|
|
@ -704,4 +704,4 @@ void Ribbon::createBuffers(SceneRenderState *state, GFXVertexBufferHandle<GFXVer
|
|||
}
|
||||
|
||||
mUpdateBuffers = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -388,7 +388,9 @@ F32 GameBase::getUpdatePriority(CameraScopeQuery *camInfo, U32 updateMask, S32 u
|
|||
// Weight by field of view, objects directly in front
|
||||
// will be weighted 1, objects behind will be 0
|
||||
F32 dot = mDot(pos,camInfo->orientation);
|
||||
bool inFov = dot > camInfo->cosFov;
|
||||
|
||||
bool inFov = dot > camInfo->cosFov * 1.5f;
|
||||
|
||||
F32 wFov = inFov? 1.0f: 0;
|
||||
|
||||
// Weight by linear velocity parallel to the viewing plane
|
||||
|
|
@ -406,7 +408,7 @@ F32 GameBase::getUpdatePriority(CameraScopeQuery *camInfo, U32 updateMask, S32 u
|
|||
|
||||
// Weight by interest.
|
||||
F32 wInterest;
|
||||
if (getTypeMask() & PlayerObjectType)
|
||||
if (getTypeMask() & (PlayerObjectType || VehicleObjectType ))
|
||||
wInterest = 0.75f;
|
||||
else if (getTypeMask() & ProjectileObjectType)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@
|
|||
#ifndef _DYNAMIC_CONSOLETYPES_H_
|
||||
#include "console/dynamicTypes.h"
|
||||
#endif
|
||||
#ifndef __SCENEMANAGER_H__
|
||||
#include "scene/sceneManager.h"
|
||||
#define __SCENEMANAGER_H__
|
||||
#endif
|
||||
|
||||
class NetConnection;
|
||||
class ProcessList;
|
||||
|
|
|
|||
|
|
@ -226,6 +226,8 @@ GameConnection::GameConnection()
|
|||
mAddYawToAbsRot = false;
|
||||
mAddPitchToAbsRot = false;
|
||||
|
||||
mVisibleGhostDistance = 0.0f;
|
||||
|
||||
clearDisplayDevice();
|
||||
}
|
||||
|
||||
|
|
@ -240,6 +242,16 @@ GameConnection::~GameConnection()
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void GameConnection::setVisibleGhostDistance(F32 dist)
|
||||
{
|
||||
mVisibleGhostDistance = dist;
|
||||
}
|
||||
|
||||
F32 GameConnection::getVisibleGhostDistance()
|
||||
{
|
||||
return mVisibleGhostDistance;
|
||||
}
|
||||
|
||||
bool GameConnection::canRemoteCreate()
|
||||
{
|
||||
return true;
|
||||
|
|
@ -2199,3 +2211,21 @@ DefineEngineMethod( GameConnection, getControlSchemeAbsoluteRotation, bool, (),,
|
|||
{
|
||||
return object->getControlSchemeAbsoluteRotation();
|
||||
}
|
||||
|
||||
DefineEngineMethod( GameConnection, setVisibleGhostDistance, void, (F32 dist),,
|
||||
"@brief Sets the distance that objects around it will be ghosted. If set to 0, "
|
||||
"it may be defined by the LevelInfo.\n\n"
|
||||
"@dist - is the max distance\n\n"
|
||||
)
|
||||
{
|
||||
object->setVisibleGhostDistance(dist);
|
||||
}
|
||||
|
||||
DefineEngineMethod( GameConnection, getVisibleGhostDistance, F32, (),,
|
||||
"@brief Gets the distance that objects around the connection will be ghosted.\n\n"
|
||||
|
||||
"@return S32 of distance.\n\n"
|
||||
)
|
||||
{
|
||||
return object->getVisibleGhostDistance();
|
||||
}
|
||||
|
|
@ -72,6 +72,8 @@ private:
|
|||
|
||||
U32 mMissionCRC; // crc of the current mission file from the server
|
||||
|
||||
F32 mVisibleGhostDistance;
|
||||
|
||||
private:
|
||||
U32 mLastControlRequestTime;
|
||||
S32 mDataBlockModifiedKey;
|
||||
|
|
@ -155,6 +157,9 @@ public:
|
|||
|
||||
bool canRemoteCreate();
|
||||
|
||||
void setVisibleGhostDistance(F32 dist);
|
||||
F32 getVisibleGhostDistance();
|
||||
|
||||
private:
|
||||
/// @name Connection State
|
||||
/// This data is set with setConnectArgs() and setJoinPassword(), and
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "console/engineAPI.h"
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/gameBase/gameProcess.h"
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ ClientProcessList* ClientProcessList::smClientProcessList = NULL;
|
|||
ServerProcessList* ServerProcessList::smServerProcessList = NULL;
|
||||
static U32 gNetOrderNextId = 0;
|
||||
|
||||
ConsoleFunction( dumpProcessList, void, 1, 1,
|
||||
DefineConsoleFunction( dumpProcessList, void, ( ), ,
|
||||
"Dumps all ProcessObjects in ServerProcessList and ClientProcessList to the console." )
|
||||
{
|
||||
Con::printf( "client process list:" );
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ extern void ShowInit();
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Camera and FOV info
|
||||
namespace {
|
||||
namespace CameraAndFOV{
|
||||
|
||||
const U32 MaxZoomSpeed = 2000; ///< max number of ms to reach target FOV
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ static U32 sgServerQueryIndex = 0;
|
|||
//SERVER FUNCTIONS ONLY
|
||||
ConsoleFunctionGroupBegin( Containers, "Spatial query functions. <b>Server side only!</b>");
|
||||
|
||||
ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point, float x, float y, float z)"
|
||||
DefineConsoleFunction( containerFindFirst, const char*, (U32 typeMask, Point3F origin, Point3F size), , "(int mask, Point3F point, float x, float y, float z)"
|
||||
"@brief Find objects matching the bitmask type within a box centered at point, with extents x, y, z.\n\n"
|
||||
"@returns The first object found, or an empty string if nothing was found. Thereafter, you can get more "
|
||||
"results using containerFindNext()."
|
||||
|
|
@ -120,17 +120,6 @@ ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point
|
|||
"@ingroup Game")
|
||||
{
|
||||
//find out what we're looking for
|
||||
U32 typeMask = U32(dAtoi(argv[1]));
|
||||
|
||||
//find the center of the container volume
|
||||
Point3F origin(0.0f, 0.0f, 0.0f);
|
||||
dSscanf(argv[2], "%g %g %g", &origin.x, &origin.y, &origin.z);
|
||||
|
||||
//find the box dimensions
|
||||
Point3F size(0.0f, 0.0f, 0.0f);
|
||||
size.x = mFabs(dAtof(argv[3]));
|
||||
size.y = mFabs(dAtof(argv[4]));
|
||||
size.z = mFabs(dAtof(argv[5]));
|
||||
|
||||
//build the container volume
|
||||
Box3F queryBox;
|
||||
|
|
@ -155,7 +144,7 @@ ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point
|
|||
return buff;
|
||||
}
|
||||
|
||||
ConsoleFunction( containerFindNext, const char*, 1, 1, "()"
|
||||
DefineConsoleFunction( containerFindNext, const char*, (), , "()"
|
||||
"@brief Get more results from a previous call to containerFindFirst().\n\n"
|
||||
"@note You must call containerFindFirst() to begin the search.\n"
|
||||
"@returns The next object found, or an empty string if nothing else was found.\n"
|
||||
|
|
@ -191,9 +180,9 @@ DefineEngineFunction( setDefaultFov, void, ( F32 defaultFOV ),,
|
|||
"@param defaultFOV The default field of view in degrees\n"
|
||||
"@ingroup CameraSystem")
|
||||
{
|
||||
sDefaultFov = mClampF(defaultFOV, MinCameraFov, MaxCameraFov);
|
||||
if(sCameraFov == sTargetFov)
|
||||
sTargetFov = sDefaultFov;
|
||||
CameraAndFOV::sDefaultFov = mClampF(defaultFOV, MinCameraFov, MaxCameraFov);
|
||||
if(CameraAndFOV::sCameraFov == CameraAndFOV::sTargetFov)
|
||||
CameraAndFOV::sTargetFov = CameraAndFOV::sDefaultFov;
|
||||
}
|
||||
|
||||
DefineEngineFunction( setZoomSpeed, void, ( S32 speed ),,
|
||||
|
|
@ -203,7 +192,7 @@ DefineEngineFunction( setZoomSpeed, void, ( S32 speed ),,
|
|||
"@param speed The camera's zoom speed in ms per 90deg FOV change\n"
|
||||
"@ingroup CameraSystem")
|
||||
{
|
||||
sZoomSpeed = mClamp(speed, 0, MaxZoomSpeed);
|
||||
CameraAndFOV::sZoomSpeed = mClamp(speed, 0, CameraAndFOV::MaxZoomSpeed);
|
||||
}
|
||||
|
||||
DefineEngineFunction( setFov, void, ( F32 FOV ),,
|
||||
|
|
@ -211,22 +200,22 @@ DefineEngineFunction( setFov, void, ( F32 FOV ),,
|
|||
"@param FOV The camera's new FOV in degrees\n"
|
||||
"@ingroup CameraSystem")
|
||||
{
|
||||
sTargetFov = mClampF(FOV, MinCameraFov, MaxCameraFov);
|
||||
CameraAndFOV::sTargetFov = mClampF(FOV, MinCameraFov, MaxCameraFov);
|
||||
}
|
||||
|
||||
F32 GameGetCameraFov()
|
||||
{
|
||||
return(sCameraFov);
|
||||
return(CameraAndFOV::sCameraFov);
|
||||
}
|
||||
|
||||
void GameSetCameraFov(F32 fov)
|
||||
{
|
||||
sTargetFov = sCameraFov = fov;
|
||||
CameraAndFOV::sTargetFov = CameraAndFOV::sCameraFov = fov;
|
||||
}
|
||||
|
||||
void GameSetCameraTargetFov(F32 fov)
|
||||
{
|
||||
sTargetFov = fov;
|
||||
CameraAndFOV::sTargetFov = fov;
|
||||
}
|
||||
|
||||
void GameUpdateCameraFov()
|
||||
|
|
@ -234,29 +223,29 @@ void GameUpdateCameraFov()
|
|||
F32 time = F32(Platform::getVirtualMilliseconds());
|
||||
|
||||
// need to update fov?
|
||||
if(sTargetFov != sCameraFov)
|
||||
if(CameraAndFOV::sTargetFov != CameraAndFOV::sCameraFov)
|
||||
{
|
||||
F32 delta = time - sLastCameraUpdateTime;
|
||||
F32 delta = time - CameraAndFOV::sLastCameraUpdateTime;
|
||||
|
||||
// snap zoom?
|
||||
if((sZoomSpeed == 0) || (delta <= 0.f))
|
||||
sCameraFov = sTargetFov;
|
||||
if((CameraAndFOV::sZoomSpeed == 0) || (delta <= 0.f))
|
||||
CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov;
|
||||
else
|
||||
{
|
||||
// gZoomSpeed is time in ms to zoom 90deg
|
||||
F32 step = 90.f * (delta / F32(sZoomSpeed));
|
||||
F32 step = 90.f * (delta / F32(CameraAndFOV::sZoomSpeed));
|
||||
|
||||
if(sCameraFov > sTargetFov)
|
||||
if(CameraAndFOV::sCameraFov > CameraAndFOV::sTargetFov)
|
||||
{
|
||||
sCameraFov -= step;
|
||||
if(sCameraFov < sTargetFov)
|
||||
sCameraFov = sTargetFov;
|
||||
CameraAndFOV::sCameraFov -= step;
|
||||
if(CameraAndFOV::sCameraFov < CameraAndFOV::sTargetFov)
|
||||
CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov;
|
||||
}
|
||||
else
|
||||
{
|
||||
sCameraFov += step;
|
||||
if(sCameraFov > sTargetFov)
|
||||
sCameraFov = sTargetFov;
|
||||
CameraAndFOV::sCameraFov += step;
|
||||
if(CameraAndFOV::sCameraFov > CameraAndFOV::sTargetFov)
|
||||
CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -266,23 +255,23 @@ void GameUpdateCameraFov()
|
|||
if(connection)
|
||||
{
|
||||
// check if fov is valid on control object
|
||||
if(connection->isValidControlCameraFov(sCameraFov))
|
||||
connection->setControlCameraFov(sCameraFov);
|
||||
if(connection->isValidControlCameraFov(CameraAndFOV::sCameraFov))
|
||||
connection->setControlCameraFov(CameraAndFOV::sCameraFov);
|
||||
else
|
||||
{
|
||||
// will set to the closest fov (fails only on invalid control object)
|
||||
if(connection->setControlCameraFov(sCameraFov))
|
||||
if(connection->setControlCameraFov(CameraAndFOV::sCameraFov))
|
||||
{
|
||||
F32 setFov = sCameraFov;
|
||||
F32 setFov = CameraAndFOV::sCameraFov;
|
||||
connection->getControlCameraFov(&setFov);
|
||||
sTargetFov = sCameraFov = setFov;
|
||||
CameraAndFOV::sTargetFov =CameraAndFOV::sCameraFov = setFov;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update the console variable
|
||||
sConsoleCameraFov = sCameraFov;
|
||||
sLastCameraUpdateTime = time;
|
||||
CameraAndFOV::sConsoleCameraFov = CameraAndFOV::sCameraFov;
|
||||
CameraAndFOV::sLastCameraUpdateTime = time;
|
||||
}
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -355,8 +344,8 @@ bool GameProcessCameraQuery(CameraQuery *query)
|
|||
|
||||
// Scale the normal visible distance by the performance
|
||||
// tuning scale which we never let over 1.
|
||||
sVisDistanceScale = mClampF( sVisDistanceScale, 0.01f, 1.0f );
|
||||
query->farPlane = gClientSceneGraph->getVisibleDistance() * sVisDistanceScale;
|
||||
CameraAndFOV::sVisDistanceScale = mClampF( CameraAndFOV::sVisDistanceScale, 0.01f, 1.0f );
|
||||
query->farPlane = gClientSceneGraph->getVisibleDistance() * CameraAndFOV::sVisDistanceScale;
|
||||
|
||||
// Provide some default values
|
||||
query->projectionOffset = Point2F::Zero;
|
||||
|
|
@ -432,10 +421,10 @@ static void Process3D()
|
|||
|
||||
static void RegisterGameFunctions()
|
||||
{
|
||||
Con::addVariable( "$pref::Camera::distanceScale", TypeF32, &sVisDistanceScale,
|
||||
Con::addVariable( "$pref::Camera::distanceScale", TypeF32, &CameraAndFOV::sVisDistanceScale,
|
||||
"A scale to apply to the normal visible distance, typically used for tuning performance.\n"
|
||||
"@ingroup Game");
|
||||
Con::addVariable( "$cameraFov", TypeF32, &sConsoleCameraFov,
|
||||
Con::addVariable( "$cameraFov", TypeF32, &CameraAndFOV::sConsoleCameraFov,
|
||||
"The camera's Field of View.\n\n"
|
||||
"@ingroup Game" );
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@
|
|||
#include "console/engineAPI.h"
|
||||
#include "math/mathIO.h"
|
||||
|
||||
#include "torqueConfig.h"
|
||||
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(LevelInfo);
|
||||
|
||||
|
|
@ -77,6 +79,7 @@ static SFXAmbience sDefaultAmbience;
|
|||
LevelInfo::LevelInfo()
|
||||
: mNearClip( 0.1f ),
|
||||
mVisibleDistance( 1000.0f ),
|
||||
mVisibleGhostDistance ( 0 ),
|
||||
mDecalBias( 0.0015f ),
|
||||
mCanvasClearColor( 255, 0, 255, 255 ),
|
||||
mSoundAmbience( NULL ),
|
||||
|
|
@ -113,7 +116,8 @@ void LevelInfo::initPersistFields()
|
|||
addGroup( "Visibility" );
|
||||
|
||||
addField( "nearClip", TypeF32, Offset( mNearClip, LevelInfo ), "Closest distance from the camera's position to render the world." );
|
||||
addField( "visibleDistance", TypeF32, Offset( mVisibleDistance, LevelInfo ), "Furthest distance fromt he camera's position to render the world." );
|
||||
addField( "visibleDistance", TypeF32, Offset( mVisibleDistance, LevelInfo ), "Furthest distance from the camera's position to render the world." );
|
||||
addField( "visibleGhostDistance", TypeF32, Offset( mVisibleGhostDistance, LevelInfo ), "Furthest distance from the camera's position to render players. Defaults to visibleDistance." );
|
||||
addField( "decalBias", TypeF32, Offset( mDecalBias, LevelInfo ),
|
||||
"NearPlane bias used when rendering Decal and DecalRoad. This should be tuned to the visibleDistance in your level." );
|
||||
|
||||
|
|
@ -300,6 +304,7 @@ void LevelInfo::_updateSceneGraph()
|
|||
|
||||
scene->setNearClip( mNearClip );
|
||||
scene->setVisibleDistance( mVisibleDistance );
|
||||
scene->setVisibleGhostDistance( mVisibleGhostDistance );
|
||||
|
||||
gDecalBias = mDecalBias;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
#include "sfx/sfxCommon.h"
|
||||
#endif
|
||||
|
||||
|
||||
class SFXAmbience;
|
||||
class SFXSoundscape;
|
||||
|
||||
|
|
@ -55,6 +54,8 @@ class LevelInfo : public NetObject
|
|||
|
||||
F32 mVisibleDistance;
|
||||
|
||||
F32 mVisibleGhostDistance;
|
||||
|
||||
F32 mDecalBias;
|
||||
|
||||
ColorI mCanvasClearColor;
|
||||
|
|
|
|||
|
|
@ -425,21 +425,22 @@ static ConsoleDocFragment _lbplayAnimation2(
|
|||
"LightBase",
|
||||
"void playAnimation(LightAnimData anim);"
|
||||
);
|
||||
ConsoleMethod( LightBase, playAnimation, void, 2, 3, "( [LightAnimData anim] )\t"
|
||||
|
||||
DefineConsoleMethod( LightBase, playAnimation, void, (const char * anim), (""), "( [LightAnimData anim] )\t"
|
||||
"Plays a light animation on the light. If no LightAnimData is passed the "
|
||||
"existing one is played."
|
||||
"@hide")
|
||||
{
|
||||
if ( argc == 2 )
|
||||
if ( dStrIsEmpty(anim) )
|
||||
{
|
||||
object->playAnimation();
|
||||
return;
|
||||
}
|
||||
|
||||
LightAnimData *animData;
|
||||
if ( !Sim::findObject( argv[2], animData ) )
|
||||
if ( !Sim::findObject( anim, animData ) )
|
||||
{
|
||||
Con::errorf( "LightBase::playAnimation() - Invalid LightAnimData '%s'.", (const char*)argv[2] );
|
||||
Con::errorf( "LightBase::playAnimation() - Invalid LightAnimData '%s'.", anim );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -469,7 +470,7 @@ void LightBase::playAnimation( LightAnimData *animData )
|
|||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( LightBase, pauseAnimation, void, 2, 2, "Stops the light animation." )
|
||||
DefineConsoleMethod( LightBase, pauseAnimation, void, (), , "Stops the light animation." )
|
||||
{
|
||||
object->pauseAnimation();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,8 +279,6 @@ void WayPoint::unpackUpdate(NetConnection * con, BitStream * stream)
|
|||
setHidden(stream->readFlag());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WayPoint::initPersistFields()
|
||||
{
|
||||
addGroup("Misc");
|
||||
|
|
@ -506,16 +504,16 @@ ConsoleDocFragment _SpawnSpherespawnObject1(
|
|||
"bool spawnObject(string additionalProps);"
|
||||
);
|
||||
|
||||
ConsoleMethod(SpawnSphere, spawnObject, S32, 2, 3,
|
||||
DefineConsoleMethod(SpawnSphere, spawnObject, S32, (String additionalProps), ,
|
||||
"([string additionalProps]) Spawns the object based on the SpawnSphere's "
|
||||
"class, datablock, properties, and script settings. Allows you to pass in "
|
||||
"extra properties."
|
||||
"@hide" )
|
||||
{
|
||||
String additionalProps;
|
||||
//String additionalProps;
|
||||
|
||||
if (argc == 3)
|
||||
additionalProps = (const char*)argv[2];
|
||||
//if (argc == 3)
|
||||
// additionalProps = String(argv[2]);
|
||||
|
||||
SimObject* obj = object->spawnObject(additionalProps);
|
||||
|
||||
|
|
|
|||
|
|
@ -581,7 +581,7 @@ static CameraSpline::Knot::Path resolveKnotPath(const char *arg)
|
|||
}
|
||||
|
||||
DefineEngineMethod(PathCamera, pushBack, void, (TransformF transform, F32 speed, const char* type, const char* path),
|
||||
(1.0, "Normal", "Linear"),
|
||||
(1.0f, "Normal", "Linear"),
|
||||
"@brief Adds a new knot to the back of a path camera's path.\n"
|
||||
"@param transform Transform for the new knot. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform()\n"
|
||||
"@param speed Speed setting for this knot.\n"
|
||||
|
|
@ -606,7 +606,7 @@ DefineEngineMethod(PathCamera, pushBack, void, (TransformF transform, F32 speed,
|
|||
}
|
||||
|
||||
DefineEngineMethod(PathCamera, pushFront, void, (TransformF transform, F32 speed, const char* type, const char* path),
|
||||
(1.0, "Normal", "Linear"),
|
||||
(1.0f, "Normal", "Linear"),
|
||||
"@brief Adds a new knot to the front of a path camera's path.\n"
|
||||
"@param transform Transform for the new knot. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform()\n"
|
||||
"@param speed Speed setting for this knot.\n"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "math/mathUtils.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/consoleObject.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "sim/netConnection.h"
|
||||
#include "scene/sceneRenderState.h"
|
||||
#include "scene/sceneManager.h"
|
||||
|
|
@ -237,7 +238,7 @@ void PhysicsDebrisData::unpackData(BitStream* stream)
|
|||
shapeName = stream->readSTString();
|
||||
}
|
||||
|
||||
ConsoleMethod( PhysicsDebrisData, preload, void, 2, 2,
|
||||
DefineConsoleMethod( PhysicsDebrisData, preload, void, (), ,
|
||||
"@brief Loads some information to have readily available at simulation time.\n\n"
|
||||
"Forces generation of shaders, materials, and other data used by the %PhysicsDebris object. "
|
||||
"This function should be used while a level is loading in order to shorten "
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "T3D/physics/physicsPlugin.h"
|
||||
|
||||
#include "console/console.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/simSet.h"
|
||||
#include "core/strings/stringFunctions.h"
|
||||
|
|
@ -123,55 +124,52 @@ void PhysicsPlugin::_debugDraw( SceneManager *graph, const SceneRenderState *sta
|
|||
world->onDebugDraw( state );
|
||||
}
|
||||
|
||||
ConsoleFunction( physicsPluginPresent, bool, 1, 1, "physicsPluginPresent()\n"
|
||||
DefineConsoleFunction( physicsPluginPresent, bool, (), , "physicsPluginPresent()"
|
||||
"@brief Returns true if a physics plugin exists and is initialized.\n\n"
|
||||
"@ingroup Physics" )
|
||||
{
|
||||
return PHYSICSMGR != NULL;
|
||||
}
|
||||
|
||||
ConsoleFunction( physicsInit, bool, 1, 2, "physicsInit( [string library] )" )
|
||||
DefineConsoleFunction( physicsInit, bool, (const char * library), ("default"), "physicsInit( [string library] )")
|
||||
{
|
||||
const char *library = "default";
|
||||
if ( argc > 1 )
|
||||
library = argv[1];
|
||||
|
||||
return PhysicsPlugin::activate( library );
|
||||
}
|
||||
|
||||
ConsoleFunction( physicsDestroy, void, 1, 1, "physicsDestroy()" )
|
||||
DefineConsoleFunction( physicsDestroy, void, (), , "physicsDestroy()")
|
||||
{
|
||||
if ( PHYSICSMGR )
|
||||
PHYSICSMGR->destroyPlugin();
|
||||
}
|
||||
|
||||
ConsoleFunction( physicsInitWorld, bool, 2, 2, "physicsInitWorld( String worldName )" )
|
||||
DefineConsoleFunction( physicsInitWorld, bool, (const char * worldName), , "physicsInitWorld( String worldName )")
|
||||
{
|
||||
return PHYSICSMGR && PHYSICSMGR->createWorld( (const char*)argv[1] );
|
||||
bool res = PHYSICSMGR && PHYSICSMGR->createWorld( String( worldName ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
ConsoleFunction( physicsDestroyWorld, void, 2, 2, "physicsDestroyWorld( String worldName )" )
|
||||
DefineConsoleFunction( physicsDestroyWorld, void, (const char * worldName), , "physicsDestroyWorld( String worldName )")
|
||||
{
|
||||
if ( PHYSICSMGR )
|
||||
PHYSICSMGR->destroyWorld( (const char*)argv[1] );
|
||||
PHYSICSMGR->destroyWorld( worldName );
|
||||
}
|
||||
|
||||
|
||||
// Control/query of the stop/started state
|
||||
// of the currently running simulation.
|
||||
ConsoleFunction( physicsStartSimulation, void, 2, 2, "physicsStartSimulation( String worldName )" )
|
||||
DefineConsoleFunction( physicsStartSimulation, void, (const char * worldName), , "physicsStartSimulation( String worldName )")
|
||||
{
|
||||
if ( PHYSICSMGR )
|
||||
PHYSICSMGR->enableSimulation( (const char*)argv[1], true );
|
||||
PHYSICSMGR->enableSimulation( String( worldName ), true );
|
||||
}
|
||||
|
||||
ConsoleFunction( physicsStopSimulation, void, 2, 2, "physicsStopSimulation( String worldName )" )
|
||||
DefineConsoleFunction( physicsStopSimulation, void, (const char * worldName), , "physicsStopSimulation( String worldName )")
|
||||
{
|
||||
if ( PHYSICSMGR )
|
||||
PHYSICSMGR->enableSimulation( (const char*)argv[1], false );
|
||||
PHYSICSMGR->enableSimulation( String( worldName ), false );
|
||||
}
|
||||
|
||||
ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled()" )
|
||||
DefineConsoleFunction( physicsSimulationEnabled, bool, (), , "physicsStopSimulation( String worldName )")
|
||||
{
|
||||
return PHYSICSMGR && PHYSICSMGR->isSimulationEnabled();
|
||||
}
|
||||
|
|
@ -179,14 +177,14 @@ ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled
|
|||
// Used for slowing down time on the
|
||||
// physics simulation, and for pausing/restarting
|
||||
// the simulation.
|
||||
ConsoleFunction( physicsSetTimeScale, void, 2, 2, "physicsSetTimeScale( F32 scale )" )
|
||||
DefineConsoleFunction( physicsSetTimeScale, void, (F32 scale), , "physicsSetTimeScale( F32 scale )")
|
||||
{
|
||||
if ( PHYSICSMGR )
|
||||
PHYSICSMGR->setTimeScale( argv[1] );
|
||||
PHYSICSMGR->setTimeScale( scale );
|
||||
}
|
||||
|
||||
// Get the currently set time scale.
|
||||
ConsoleFunction( physicsGetTimeScale, F32, 1, 1, "physicsGetTimeScale()" )
|
||||
DefineConsoleFunction( physicsGetTimeScale, F32, (), , "physicsGetTimeScale()")
|
||||
{
|
||||
return PHYSICSMGR && PHYSICSMGR->getTimeScale();
|
||||
}
|
||||
|
|
@ -195,7 +193,7 @@ ConsoleFunction( physicsGetTimeScale, F32, 1, 1, "physicsGetTimeScale()" )
|
|||
// physics simulation that they should store
|
||||
// their current state for later restoration,
|
||||
// such as when the editor is closed.
|
||||
ConsoleFunction( physicsStoreState, void, 1, 1, "physicsStoreState()" )
|
||||
DefineConsoleFunction( physicsStoreState, void, (), , "physicsStoreState()")
|
||||
{
|
||||
PhysicsPlugin::getPhysicsResetSignal().trigger( PhysicsResetEvent_Store );
|
||||
}
|
||||
|
|
@ -203,14 +201,14 @@ ConsoleFunction( physicsStoreState, void, 1, 1, "physicsStoreState()" )
|
|||
// Used to send a signal to objects in the
|
||||
// physics simulation that they should restore
|
||||
// their saved state, such as when the editor is opened.
|
||||
ConsoleFunction( physicsRestoreState, void, 1, 1, "physicsRestoreState()" )
|
||||
DefineConsoleFunction( physicsRestoreState, void, (), , "physicsRestoreState()")
|
||||
{
|
||||
if ( PHYSICSMGR )
|
||||
PHYSICSMGR->reset();
|
||||
}
|
||||
|
||||
ConsoleFunction( physicsDebugDraw, void, 2, 2, "physicsDebugDraw( bool enable )" )
|
||||
DefineConsoleFunction( physicsDebugDraw, void, (bool enable), , "physicsDebugDraw( bool enable )")
|
||||
{
|
||||
if ( PHYSICSMGR )
|
||||
PHYSICSMGR->enableDebugDraw( (S32)argv[1] );
|
||||
PHYSICSMGR->enableDebugDraw( enable );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,28 +20,34 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Windows WGL functions
|
||||
GL_GROUP_BEGIN(ARB_win32)
|
||||
GL_FUNCTION(wglCopyContext, BOOL, (HGLRC, HGLRC, UINT))
|
||||
GL_FUNCTION(wglCreateContext, HGLRC, (HDC))
|
||||
GL_FUNCTION(wglCreateLayerContext, HGLRC, (HDC, GLint))
|
||||
GL_FUNCTION(wglDeleteContext, BOOL, (HGLRC))
|
||||
GL_FUNCTION(wglGetCurrentContext, HGLRC, (VOID))
|
||||
GL_FUNCTION(wglGetCurrentDC, HDC, (VOID))
|
||||
GL_FUNCTION(wglGetProcAddress, PROC, (LPCSTR))
|
||||
GL_FUNCTION(wglMakeCurrent, BOOL, (HDC, HGLRC))
|
||||
GL_FUNCTION(wglShareLists, BOOL, (HGLRC, HGLRC))
|
||||
GL_FUNCTION(wglDescribeLayerPlane, BOOL, (HDC, GLint, GLint, UINT, LPLAYERPLANEDESCRIPTOR))
|
||||
GL_FUNCTION(wglSetLayerPaletteEntries, GLint, (HDC, GLint, GLint, GLint, CONST COLORREF *))
|
||||
GL_FUNCTION(wglGetLayerPaletteEntries, GLint, (HDC, GLint, GLint, GLint, COLORREF *))
|
||||
GL_FUNCTION(wglRealizeLayerPalette, BOOL, (HDC, GLint, BOOL))
|
||||
GL_FUNCTION(wglSwapLayerBuffers, BOOL, (HDC, UINT))
|
||||
#ifndef _PHYSX3_H_
|
||||
#define _PHYSX3_H_
|
||||
|
||||
// Ascii and Unicode versions
|
||||
GL_FUNCTION(wglUseFontBitmapsA, BOOL, (HDC, DWORD, DWORD, DWORD))
|
||||
GL_FUNCTION(wglUseFontOutlinesA, BOOL, (HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, GLint, LPGLYPHMETRICSFLOAT))
|
||||
GL_FUNCTION(wglUseFontBitmapsW, BOOL, (HDC, DWORD, DWORD, DWORD))
|
||||
GL_FUNCTION(wglUseFontOutlinesW, BOOL, (HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, GLint, LPGLYPHMETRICSFLOAT))
|
||||
//-------------------------------------------------------------------------
|
||||
//defines to keep PhysX happy and compiling
|
||||
#if defined(TORQUE_OS_MAC) && !defined(__APPLE__)
|
||||
#define __APPLE__
|
||||
#elif defined(TORQUE_OS_LINUX) && !defined(LINUX)
|
||||
#define LINUX
|
||||
#elif defined(TORQUE_OS_WIN) && !defined(WIN32)
|
||||
#define WIN32
|
||||
#endif
|
||||
|
||||
GL_GROUP_END()
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include <PxPhysicsAPI.h>
|
||||
#include <PxExtensionsAPI.h>
|
||||
#include <PxDefaultErrorCallback.h>
|
||||
#include <PxDefaultAllocator.h>
|
||||
#include <PxDefaultSimulationFilterShader.h>
|
||||
#include <PxDefaultCpuDispatcher.h>
|
||||
#include <PxShapeExt.h>
|
||||
#include <PxSimpleFactory.h>
|
||||
#include <PxFoundation.h>
|
||||
#include <PxController.h>
|
||||
#include <PxIO.h>
|
||||
|
||||
|
||||
extern physx::PxPhysics* gPhysics3SDK;
|
||||
|
||||
#endif // _PHYSX3_
|
||||
419
Engine/source/T3D/physics/physx3/px3Body.cpp
Normal file
419
Engine/source/T3D/physics/physx3/px3Body.cpp
Normal file
|
|
@ -0,0 +1,419 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/physics/physx3/px3Body.h"
|
||||
|
||||
#include "T3D/physics/physx3/px3.h"
|
||||
#include "T3D/physics/physx3/px3Casts.h"
|
||||
#include "T3D/physics/physx3/px3World.h"
|
||||
#include "T3D/physics/physx3/px3Collision.h"
|
||||
|
||||
#include "console/console.h"
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
|
||||
Px3Body::Px3Body() :
|
||||
mActor( NULL ),
|
||||
mMaterial( NULL ),
|
||||
mWorld( NULL ),
|
||||
mBodyFlags( 0 ),
|
||||
mIsEnabled( true ),
|
||||
mIsStatic(false)
|
||||
{
|
||||
}
|
||||
|
||||
Px3Body::~Px3Body()
|
||||
{
|
||||
_releaseActor();
|
||||
}
|
||||
|
||||
void Px3Body::_releaseActor()
|
||||
{
|
||||
if ( !mActor )
|
||||
return;
|
||||
|
||||
mWorld->releaseWriteLock();
|
||||
|
||||
mActor->userData = NULL;
|
||||
|
||||
mActor->release();
|
||||
mActor = NULL;
|
||||
mBodyFlags = 0;
|
||||
|
||||
if ( mMaterial )
|
||||
{
|
||||
mMaterial->release();
|
||||
}
|
||||
|
||||
mColShape = NULL;
|
||||
}
|
||||
|
||||
bool Px3Body::init( PhysicsCollision *shape,
|
||||
F32 mass,
|
||||
U32 bodyFlags,
|
||||
SceneObject *obj,
|
||||
PhysicsWorld *world )
|
||||
{
|
||||
AssertFatal( obj, "Px3Body::init - Got a null scene object!" );
|
||||
AssertFatal( world, "Px3Body::init - Got a null world!" );
|
||||
AssertFatal( dynamic_cast<Px3World*>( world ), "Px3Body::init - The world is the wrong type!" );
|
||||
AssertFatal( shape, "Px3Body::init - Got a null collision shape!" );
|
||||
AssertFatal( dynamic_cast<Px3Collision*>( shape ), "Px3Body::init - The collision shape is the wrong type!" );
|
||||
AssertFatal( !((Px3Collision*)shape)->getShapes().empty(), "Px3Body::init - Got empty collision shape!" );
|
||||
|
||||
// Cleanup any previous actor.
|
||||
_releaseActor();
|
||||
|
||||
mWorld = (Px3World*)world;
|
||||
mColShape = (Px3Collision*)shape;
|
||||
mBodyFlags = bodyFlags;
|
||||
|
||||
const bool isKinematic = mBodyFlags & BF_KINEMATIC;
|
||||
const bool isTrigger = mBodyFlags & BF_TRIGGER;
|
||||
const bool isDebris = mBodyFlags & BF_DEBRIS;
|
||||
|
||||
if ( isKinematic )
|
||||
{
|
||||
mActor = gPhysics3SDK->createRigidDynamic(physx::PxTransform(physx::PxIDENTITY()));
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
actor->setRigidDynamicFlag(physx::PxRigidDynamicFlag::eKINEMATIC, true);
|
||||
actor->setMass(getMax( mass, 1.0f ));
|
||||
}
|
||||
else if ( mass > 0.0f )
|
||||
{
|
||||
mActor = gPhysics3SDK->createRigidDynamic(physx::PxTransform(physx::PxIDENTITY()));
|
||||
}
|
||||
else
|
||||
{
|
||||
mActor = gPhysics3SDK->createRigidStatic(physx::PxTransform(physx::PxIDENTITY()));
|
||||
mIsStatic = true;
|
||||
}
|
||||
|
||||
mMaterial = gPhysics3SDK->createMaterial(0.6f,0.4f,0.1f);
|
||||
|
||||
// Add all the shapes.
|
||||
const Vector<Px3CollisionDesc*> &shapes = mColShape->getShapes();
|
||||
for ( U32 i=0; i < shapes.size(); i++ )
|
||||
{
|
||||
Px3CollisionDesc* desc = shapes[i];
|
||||
if( mass > 0.0f )
|
||||
{
|
||||
if(desc->pGeometry->getType() == physx::PxGeometryType::eTRIANGLEMESH)
|
||||
{
|
||||
Con::errorf("PhysX3 Dynamic Triangle Mesh is not supported.");
|
||||
}
|
||||
}
|
||||
physx::PxShape * pShape = mActor->createShape(*desc->pGeometry,*mMaterial);
|
||||
physx::PxFilterData colData;
|
||||
if(isDebris)
|
||||
colData.word0 = PX3_DEBRIS;
|
||||
else if(isTrigger)
|
||||
colData.word0 = PX3_TRIGGER;
|
||||
else
|
||||
colData.word0 = PX3_DEFAULT;
|
||||
|
||||
//set local pose - actor->createShape with a local pose is deprecated in physx 3.3
|
||||
pShape->setLocalPose(desc->pose);
|
||||
//set the skin width
|
||||
pShape->setContactOffset(0.01f);
|
||||
pShape->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE, !isTrigger);
|
||||
pShape->setFlag(physx::PxShapeFlag::eSCENE_QUERY_SHAPE,true);
|
||||
pShape->setSimulationFilterData(colData);
|
||||
pShape->setQueryFilterData(colData);
|
||||
}
|
||||
|
||||
//mass & intertia has to be set after creating the shape
|
||||
if ( mass > 0.0f )
|
||||
{
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
physx::PxRigidBodyExt::setMassAndUpdateInertia(*actor,mass);
|
||||
}
|
||||
|
||||
// This sucks, but it has to happen if we want
|
||||
// to avoid write lock errors from PhysX right now.
|
||||
mWorld->releaseWriteLock();
|
||||
|
||||
mWorld->getScene()->addActor(*mActor);
|
||||
mIsEnabled = true;
|
||||
|
||||
if ( isDebris )
|
||||
mActor->setDominanceGroup( 31 );
|
||||
|
||||
mUserData.setObject( obj );
|
||||
mUserData.setBody( this );
|
||||
mActor->userData = &mUserData;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Px3Body::setMaterial( F32 restitution,
|
||||
F32 friction,
|
||||
F32 staticFriction )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::setMaterial - The actor is null!" );
|
||||
|
||||
if ( isDynamic() )
|
||||
{
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
actor->wakeUp();
|
||||
}
|
||||
|
||||
mMaterial->setRestitution(restitution);
|
||||
mMaterial->setStaticFriction(staticFriction);
|
||||
mMaterial->setDynamicFriction(friction);
|
||||
|
||||
}
|
||||
|
||||
void Px3Body::setSleepThreshold( F32 linear, F32 angular )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::setSleepThreshold - The actor is null!" );
|
||||
|
||||
if(mIsStatic)
|
||||
return;
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
physx::PxF32 massNormalized= (linear*linear+angular*angular)/2.0f;
|
||||
actor->setSleepThreshold(massNormalized);
|
||||
}
|
||||
|
||||
void Px3Body::setDamping( F32 linear, F32 angular )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::setDamping - The actor is null!" );
|
||||
if(mIsStatic)
|
||||
return;
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
actor->setLinearDamping( linear );
|
||||
actor->setAngularDamping( angular );
|
||||
}
|
||||
|
||||
void Px3Body::getState( PhysicsState *outState )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::getState - The actor is null!" );
|
||||
AssertFatal( isDynamic(), "Px3Body::getState - This call is only for dynamics!" );
|
||||
|
||||
outState->position = px3Cast<Point3F>( mActor->getGlobalPose().p );
|
||||
outState->orientation = px3Cast<QuatF>( mActor->getGlobalPose().q );
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
outState->linVelocity = px3Cast<Point3F>( actor->getLinearVelocity() );
|
||||
outState->angVelocity = px3Cast<Point3F>( actor->getAngularVelocity() );
|
||||
outState->sleeping = actor->isSleeping();
|
||||
outState->momentum = px3Cast<Point3F>( (1.0f/actor->getMass()) * actor->getLinearVelocity() );
|
||||
|
||||
}
|
||||
|
||||
F32 Px3Body::getMass() const
|
||||
{
|
||||
AssertFatal( mActor, "PxBody::getCMassPosition - The actor is null!" );
|
||||
if(mIsStatic)
|
||||
return 0;
|
||||
|
||||
const physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
return actor->getMass();
|
||||
}
|
||||
|
||||
Point3F Px3Body::getCMassPosition() const
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::getCMassPosition - The actor is null!" );
|
||||
if(mIsStatic)
|
||||
return px3Cast<Point3F>(mActor->getGlobalPose().p);
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
physx::PxTransform pose = actor->getGlobalPose() * actor->getCMassLocalPose();
|
||||
return px3Cast<Point3F>(pose.p);
|
||||
}
|
||||
|
||||
void Px3Body::setLinVelocity( const Point3F &vel )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::setLinVelocity - The actor is null!" );
|
||||
AssertFatal( isDynamic(), "Px3Body::setLinVelocity - This call is only for dynamics!" );
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
actor->setLinearVelocity( px3Cast<physx::PxVec3>( vel ) );
|
||||
}
|
||||
|
||||
void Px3Body::setAngVelocity( const Point3F &vel )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::setAngVelocity - The actor is null!" );
|
||||
AssertFatal( isDynamic(), "Px3Body::setAngVelocity - This call is only for dynamics!" );
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
actor->setAngularVelocity(px3Cast<physx::PxVec3>( vel ) );
|
||||
}
|
||||
|
||||
Point3F Px3Body::getLinVelocity() const
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::getLinVelocity - The actor is null!" );
|
||||
AssertFatal( isDynamic(), "Px3Body::getLinVelocity - This call is only for dynamics!" );
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
return px3Cast<Point3F>( actor->getLinearVelocity() );
|
||||
}
|
||||
|
||||
Point3F Px3Body::getAngVelocity() const
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::getAngVelocity - The actor is null!" );
|
||||
AssertFatal( isDynamic(), "Px3Body::getAngVelocity - This call is only for dynamics!" );
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
return px3Cast<Point3F>( actor->getAngularVelocity() );
|
||||
}
|
||||
|
||||
void Px3Body::setSleeping( bool sleeping )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::setSleeping - The actor is null!" );
|
||||
AssertFatal( isDynamic(), "Px3Body::setSleeping - This call is only for dynamics!" );
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
if ( sleeping )
|
||||
actor->putToSleep();
|
||||
else
|
||||
actor->wakeUp();
|
||||
}
|
||||
|
||||
bool Px3Body::isDynamic() const
|
||||
{
|
||||
AssertFatal( mActor, "PxBody::isDynamic - The actor is null!" );
|
||||
return !mIsStatic && ( mBodyFlags & BF_KINEMATIC ) == 0;
|
||||
}
|
||||
|
||||
PhysicsWorld* Px3Body::getWorld()
|
||||
{
|
||||
return mWorld;
|
||||
}
|
||||
|
||||
PhysicsCollision* Px3Body::getColShape()
|
||||
{
|
||||
return mColShape;
|
||||
}
|
||||
|
||||
MatrixF& Px3Body::getTransform( MatrixF *outMatrix )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::getTransform - The actor is null!" );
|
||||
|
||||
*outMatrix = px3Cast<MatrixF>(mActor->getGlobalPose());
|
||||
return *outMatrix;
|
||||
}
|
||||
|
||||
Box3F Px3Body::getWorldBounds()
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::getTransform - The actor is null!" );
|
||||
|
||||
physx::PxBounds3 bounds;
|
||||
bounds.setEmpty();
|
||||
physx::PxBounds3 shapeBounds;
|
||||
|
||||
|
||||
U32 shapeCount = mActor->getNbShapes();
|
||||
physx::PxShape **shapes = new physx::PxShape*[shapeCount];
|
||||
mActor->getShapes(shapes, shapeCount);
|
||||
for ( U32 i = 0; i < shapeCount; i++ )
|
||||
{
|
||||
// Get the shape's bounds.
|
||||
shapeBounds = physx::PxShapeExt::getWorldBounds(*shapes[i],*mActor);
|
||||
// Combine them into the total bounds.
|
||||
bounds.include( shapeBounds );
|
||||
}
|
||||
|
||||
delete [] shapes;
|
||||
|
||||
return px3Cast<Box3F>( bounds );
|
||||
}
|
||||
|
||||
void Px3Body::setSimulationEnabled( bool enabled )
|
||||
{
|
||||
if ( mIsEnabled == enabled )
|
||||
return;
|
||||
|
||||
//Don't need to enable/disable eSIMULATION_SHAPE for trigger,it's disabled permanently
|
||||
if(mBodyFlags & BF_TRIGGER)
|
||||
return;
|
||||
|
||||
// This sucks, but it has to happen if we want
|
||||
// to avoid write lock errors from PhysX right now.
|
||||
mWorld->releaseWriteLock();
|
||||
|
||||
U32 shapeCount = mActor->getNbShapes();
|
||||
physx::PxShape **shapes = new physx::PxShape*[shapeCount];
|
||||
mActor->getShapes(shapes, shapeCount);
|
||||
for ( S32 i = 0; i < mActor->getNbShapes(); i++ )
|
||||
{
|
||||
shapes[i]->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE,!mIsEnabled);//?????
|
||||
}
|
||||
|
||||
delete [] shapes;
|
||||
}
|
||||
void Px3Body::setTransform( const MatrixF &transform )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::setTransform - The actor is null!" );
|
||||
|
||||
|
||||
// This sucks, but it has to happen if we want
|
||||
// to avoid write lock errors from PhysX right now.
|
||||
mWorld->releaseWriteLock();
|
||||
|
||||
|
||||
mActor->setGlobalPose(px3Cast<physx::PxTransform>(transform),false);
|
||||
|
||||
if(mIsStatic)
|
||||
return;
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
bool kinematic = actor->getRigidDynamicFlags() & physx::PxRigidDynamicFlag::eKINEMATIC;
|
||||
// If its dynamic we have more to do.
|
||||
if ( isDynamic() && !kinematic )
|
||||
{
|
||||
actor->setLinearVelocity( physx::PxVec3(0) );
|
||||
actor->setAngularVelocity( physx::PxVec3(0) );
|
||||
actor->wakeUp();
|
||||
}
|
||||
}
|
||||
|
||||
void Px3Body::applyCorrection( const MatrixF &transform )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::applyCorrection - The actor is null!" );
|
||||
AssertFatal( isDynamic(), "Px3Body::applyCorrection - This call is only for dynamics!" );
|
||||
|
||||
// This sucks, but it has to happen if we want
|
||||
// to avoid write lock errors from PhysX right now.
|
||||
mWorld->releaseWriteLock();
|
||||
|
||||
mActor->setGlobalPose( px3Cast<physx::PxTransform>(transform) );
|
||||
}
|
||||
|
||||
void Px3Body::applyImpulse( const Point3F &origin, const Point3F &force )
|
||||
{
|
||||
AssertFatal( mActor, "Px3Body::applyImpulse - The actor is null!" );
|
||||
|
||||
// This sucks, but it has to happen if we want
|
||||
// to avoid write lock errors from PhysX right now.
|
||||
mWorld->releaseWriteLock();
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
if ( mIsEnabled && isDynamic() )
|
||||
physx::PxRigidBodyExt::addForceAtPos(*actor,px3Cast<physx::PxVec3>(force),
|
||||
px3Cast<physx::PxVec3>(origin),
|
||||
physx::PxForceMode::eIMPULSE);
|
||||
|
||||
}
|
||||
|
||||
122
Engine/source/T3D/physics/physx3/px3Body.h
Normal file
122
Engine/source/T3D/physics/physx3/px3Body.h
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _PX3BODY_H_
|
||||
#define _PX3BODY_H_
|
||||
|
||||
#ifndef _T3D_PHYSICS_PHYSICSBODY_H_
|
||||
#include "T3D/physics/physicsBody.h"
|
||||
#endif
|
||||
#ifndef _PHYSICS_PHYSICSUSERDATA_H_
|
||||
#include "T3D/physics/physicsUserData.h"
|
||||
#endif
|
||||
#ifndef _REFBASE_H_
|
||||
#include "core/util/refBase.h"
|
||||
#endif
|
||||
#ifndef _MMATRIX_H_
|
||||
#include "math/mMatrix.h"
|
||||
#endif
|
||||
|
||||
class Px3World;
|
||||
class Px3Collision;
|
||||
struct Px3CollisionDesc;
|
||||
|
||||
namespace physx{
|
||||
class PxRigidActor;
|
||||
class PxMaterial;
|
||||
class PxShape;
|
||||
}
|
||||
|
||||
|
||||
class Px3Body : public PhysicsBody
|
||||
{
|
||||
protected:
|
||||
|
||||
/// The physics world we are in.
|
||||
Px3World *mWorld;
|
||||
|
||||
/// The physics actor.
|
||||
physx::PxRigidActor *mActor;
|
||||
|
||||
/// The unshared local material used on all the
|
||||
/// shapes on this actor.
|
||||
physx::PxMaterial *mMaterial;
|
||||
|
||||
/// We hold the collision reference as it contains
|
||||
/// allocated objects that we own and must free.
|
||||
StrongRefPtr<Px3Collision> mColShape;
|
||||
|
||||
///
|
||||
MatrixF mInternalTransform;
|
||||
|
||||
/// The body flags set at creation time.
|
||||
U32 mBodyFlags;
|
||||
|
||||
/// Is true if this body is enabled and active
|
||||
/// in the simulation of the scene.
|
||||
bool mIsEnabled;
|
||||
bool mIsStatic;
|
||||
|
||||
///
|
||||
void _releaseActor();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Px3Body();
|
||||
virtual ~Px3Body();
|
||||
|
||||
// PhysicsObject
|
||||
virtual PhysicsWorld* getWorld();
|
||||
virtual void setTransform( const MatrixF &xfm );
|
||||
virtual MatrixF& getTransform( MatrixF *outMatrix );
|
||||
virtual Box3F getWorldBounds();
|
||||
virtual void setSimulationEnabled( bool enabled );
|
||||
virtual bool isSimulationEnabled() { return mIsEnabled; }
|
||||
|
||||
// PhysicsBody
|
||||
virtual bool init( PhysicsCollision *shape,
|
||||
F32 mass,
|
||||
U32 bodyFlags,
|
||||
SceneObject *obj,
|
||||
PhysicsWorld *world );
|
||||
|
||||
virtual bool isDynamic() const;
|
||||
virtual PhysicsCollision* getColShape();
|
||||
virtual void setSleepThreshold( F32 linear, F32 angular );
|
||||
virtual void setDamping( F32 linear, F32 angular );
|
||||
virtual void getState( PhysicsState *outState );
|
||||
virtual F32 getMass() const;
|
||||
virtual Point3F getCMassPosition() const;
|
||||
virtual void setLinVelocity( const Point3F &vel );
|
||||
virtual void setAngVelocity( const Point3F &vel );
|
||||
virtual Point3F getLinVelocity() const;
|
||||
virtual Point3F getAngVelocity() const;
|
||||
virtual void setSleeping( bool sleeping );
|
||||
virtual void setMaterial( F32 restitution,
|
||||
F32 friction,
|
||||
F32 staticFriction );
|
||||
virtual void applyCorrection( const MatrixF &xfm );
|
||||
virtual void applyImpulse( const Point3F &origin, const Point3F &force );
|
||||
};
|
||||
|
||||
#endif // _PX3BODY_H_
|
||||
137
Engine/source/T3D/physics/physx3/px3Casts.h
Normal file
137
Engine/source/T3D/physics/physx3/px3Casts.h
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _PX3CASTS_H_
|
||||
#define _PX3CASTS_H_
|
||||
|
||||
#ifndef _MPOINT3_H_
|
||||
#include "math/mPoint3.h"
|
||||
#endif
|
||||
#ifndef _MMATRIX_H_
|
||||
#include "math/mMatrix.h"
|
||||
#endif
|
||||
#ifndef _MBOX_H_
|
||||
#include "math/mBox.h"
|
||||
#endif
|
||||
#ifndef _MQUAT_H_
|
||||
#include "math/mQuat.h"
|
||||
#endif
|
||||
#ifndef _MTRANSFORM_H_
|
||||
#include "math/mTransform.h"
|
||||
#endif
|
||||
|
||||
|
||||
template <class T, class F> inline T px3Cast( const F &from );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
template<>
|
||||
inline Point3F px3Cast( const physx::PxVec3 &vec )
|
||||
{
|
||||
return Point3F( vec.x, vec.y, vec.z );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline physx::PxVec3 px3Cast( const Point3F &point )
|
||||
{
|
||||
return physx::PxVec3( point.x, point.y, point.z );
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
template<>
|
||||
inline QuatF px3Cast( const physx::PxQuat &quat )
|
||||
{
|
||||
/// The Torque quat has the opposite winding order.
|
||||
return QuatF( -quat.x, -quat.y, -quat.z, quat.w );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline physx::PxQuat px3Cast( const QuatF &quat )
|
||||
{
|
||||
/// The Torque quat has the opposite winding order.
|
||||
physx::PxQuat result( -quat.x, -quat.y, -quat.z, quat.w );
|
||||
return result;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
template<>
|
||||
inline physx::PxExtendedVec3 px3Cast( const Point3F &point )
|
||||
{
|
||||
return physx::PxExtendedVec3( point.x, point.y, point.z );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Point3F px3Cast( const physx::PxExtendedVec3 &xvec )
|
||||
{
|
||||
return Point3F( xvec.x, xvec.y, xvec.z );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
template<>
|
||||
inline physx::PxBounds3 px3Cast( const Box3F &box )
|
||||
{
|
||||
physx::PxBounds3 bounds(px3Cast<physx::PxVec3>(box.minExtents),
|
||||
px3Cast<physx::PxVec3>(box.maxExtents));
|
||||
return bounds;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Box3F px3Cast( const physx::PxBounds3 &bounds )
|
||||
{
|
||||
return Box3F( bounds.minimum.x,
|
||||
bounds.minimum.y,
|
||||
bounds.minimum.z,
|
||||
bounds.maximum.x,
|
||||
bounds.maximum.y,
|
||||
bounds.maximum.z );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
template<>
|
||||
inline physx::PxTransform px3Cast( const MatrixF &xfm )
|
||||
{
|
||||
physx::PxTransform out;
|
||||
QuatF q;
|
||||
q.set(xfm);
|
||||
out.q = px3Cast<physx::PxQuat>(q);
|
||||
out.p = px3Cast<physx::PxVec3>(xfm.getPosition());
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline TransformF px3Cast(const physx::PxTransform &xfm)
|
||||
{
|
||||
TransformF out(px3Cast<Point3F>(xfm.p),AngAxisF(px3Cast<QuatF>(xfm.q)));
|
||||
return out;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline MatrixF px3Cast( const physx::PxTransform &xfm )
|
||||
{
|
||||
MatrixF out;
|
||||
TransformF t = px3Cast<TransformF>(xfm);
|
||||
out = t.getMatrix();
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif //_PX3CASTS_H_
|
||||
217
Engine/source/T3D/physics/physx3/px3Collision.cpp
Normal file
217
Engine/source/T3D/physics/physx3/px3Collision.cpp
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/physics/physx3/px3Collision.h"
|
||||
|
||||
#include "math/mPoint3.h"
|
||||
#include "math/mMatrix.h"
|
||||
#include "T3D/physics/physx3/px3.h"
|
||||
#include "T3D/physics/physx3/px3Casts.h"
|
||||
#include "T3D/physics/physx3/px3World.h"
|
||||
#include "T3D/physics/physx3/px3Stream.h"
|
||||
|
||||
|
||||
Px3Collision::Px3Collision()
|
||||
{
|
||||
}
|
||||
|
||||
Px3Collision::~Px3Collision()
|
||||
{
|
||||
|
||||
for ( U32 i=0; i < mColShapes.size(); i++ )
|
||||
{
|
||||
Px3CollisionDesc *desc = mColShapes[i];
|
||||
delete desc->pGeometry;
|
||||
// Delete the descriptor.
|
||||
delete desc;
|
||||
}
|
||||
|
||||
mColShapes.clear();
|
||||
}
|
||||
|
||||
void Px3Collision::addPlane( const PlaneF &plane )
|
||||
{
|
||||
physx::PxVec3 pos = px3Cast<physx::PxVec3>(plane.getPosition());
|
||||
Px3CollisionDesc *desc = new Px3CollisionDesc;
|
||||
desc->pGeometry = new physx::PxPlaneGeometry();
|
||||
desc->pose = physx::PxTransform(pos, physx::PxQuat(physx::PxHalfPi, physx::PxVec3(0.0f, -1.0f, 0.0f)));
|
||||
mColShapes.push_back(desc);
|
||||
}
|
||||
|
||||
void Px3Collision::addBox( const Point3F &halfWidth,const MatrixF &localXfm )
|
||||
{
|
||||
Px3CollisionDesc *desc = new Px3CollisionDesc;
|
||||
desc->pGeometry = new physx::PxBoxGeometry(px3Cast<physx::PxVec3>(halfWidth));
|
||||
desc->pose = px3Cast<physx::PxTransform>(localXfm);
|
||||
mColShapes.push_back(desc);
|
||||
}
|
||||
|
||||
void Px3Collision::addSphere( F32 radius,
|
||||
const MatrixF &localXfm )
|
||||
{
|
||||
Px3CollisionDesc *desc = new Px3CollisionDesc;
|
||||
desc->pGeometry = new physx::PxSphereGeometry(radius);
|
||||
desc->pose = px3Cast<physx::PxTransform>(localXfm);
|
||||
mColShapes.push_back(desc);
|
||||
}
|
||||
|
||||
void Px3Collision::addCapsule( F32 radius,
|
||||
F32 height,
|
||||
const MatrixF &localXfm )
|
||||
{
|
||||
Px3CollisionDesc *desc = new Px3CollisionDesc;
|
||||
desc->pGeometry = new physx::PxCapsuleGeometry(radius,height*0.5);//uses half height
|
||||
desc->pose = px3Cast<physx::PxTransform>(localXfm);
|
||||
mColShapes.push_back(desc);
|
||||
}
|
||||
|
||||
bool Px3Collision::addConvex( const Point3F *points,
|
||||
U32 count,
|
||||
const MatrixF &localXfm )
|
||||
{
|
||||
physx::PxCooking *cooking = Px3World::getCooking();
|
||||
physx::PxConvexMeshDesc convexDesc;
|
||||
convexDesc.points.data = points;
|
||||
convexDesc.points.stride = sizeof(Point3F);
|
||||
convexDesc.points.count = count;
|
||||
convexDesc.flags = physx::PxConvexFlag::eFLIPNORMALS|physx::PxConvexFlag::eCOMPUTE_CONVEX | physx::PxConvexFlag::eINFLATE_CONVEX;
|
||||
|
||||
Px3MemOutStream stream;
|
||||
if(!cooking->cookConvexMesh(convexDesc,stream))
|
||||
return false;
|
||||
|
||||
physx::PxConvexMesh* convexMesh;
|
||||
Px3MemInStream in(stream.getData(), stream.getSize());
|
||||
convexMesh = gPhysics3SDK->createConvexMesh(in);
|
||||
|
||||
Px3CollisionDesc *desc = new Px3CollisionDesc;
|
||||
physx::PxVec3 scale = px3Cast<physx::PxVec3>(localXfm.getScale());
|
||||
physx::PxQuat rotation = px3Cast<physx::PxQuat>(QuatF(localXfm));
|
||||
physx::PxMeshScale meshScale(scale,rotation);
|
||||
desc->pGeometry = new physx::PxConvexMeshGeometry(convexMesh,meshScale);
|
||||
desc->pose = px3Cast<physx::PxTransform>(localXfm);
|
||||
mColShapes.push_back(desc);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Px3Collision::addTriangleMesh( const Point3F *vert,
|
||||
U32 vertCount,
|
||||
const U32 *index,
|
||||
U32 triCount,
|
||||
const MatrixF &localXfm )
|
||||
{
|
||||
physx::PxCooking *cooking = Px3World::getCooking();
|
||||
physx::PxTriangleMeshDesc meshDesc;
|
||||
meshDesc.points.count = vertCount;
|
||||
meshDesc.points.data = vert;
|
||||
meshDesc.points.stride = sizeof(Point3F);
|
||||
|
||||
meshDesc.triangles.count = triCount;
|
||||
meshDesc.triangles.data = index;
|
||||
meshDesc.triangles.stride = 3*sizeof(U32);
|
||||
meshDesc.flags = physx::PxMeshFlag::eFLIPNORMALS;
|
||||
|
||||
Px3MemOutStream stream;
|
||||
if(!cooking->cookTriangleMesh(meshDesc,stream))
|
||||
return false;
|
||||
|
||||
physx::PxTriangleMesh *mesh;
|
||||
Px3MemInStream in(stream.getData(), stream.getSize());
|
||||
mesh = gPhysics3SDK->createTriangleMesh(in);
|
||||
|
||||
Px3CollisionDesc *desc = new Px3CollisionDesc;
|
||||
desc->pGeometry = new physx::PxTriangleMeshGeometry(mesh);
|
||||
desc->pose = px3Cast<physx::PxTransform>(localXfm);
|
||||
mColShapes.push_back(desc);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Px3Collision::addHeightfield( const U16 *heights,
|
||||
const bool *holes,
|
||||
U32 blockSize,
|
||||
F32 metersPerSample,
|
||||
const MatrixF &localXfm )
|
||||
{
|
||||
const F32 heightScale = 0.03125f;
|
||||
physx::PxHeightFieldSample* samples = (physx::PxHeightFieldSample*) new physx::PxHeightFieldSample[blockSize*blockSize];
|
||||
memset(samples,0,blockSize*blockSize*sizeof(physx::PxHeightFieldSample));
|
||||
|
||||
physx::PxHeightFieldDesc heightFieldDesc;
|
||||
heightFieldDesc.nbColumns = blockSize;
|
||||
heightFieldDesc.nbRows = blockSize;
|
||||
heightFieldDesc.thickness = -10.f;
|
||||
heightFieldDesc.convexEdgeThreshold = 0;
|
||||
heightFieldDesc.format = physx::PxHeightFieldFormat::eS16_TM;
|
||||
heightFieldDesc.samples.data = samples;
|
||||
heightFieldDesc.samples.stride = sizeof(physx::PxHeightFieldSample);
|
||||
|
||||
physx::PxU8 *currentByte = (physx::PxU8*)heightFieldDesc.samples.data;
|
||||
for ( U32 row = 0; row < blockSize; row++ )
|
||||
{
|
||||
const U32 tess = ( row + 1 ) % 2;
|
||||
|
||||
for ( U32 column = 0; column < blockSize; column++ )
|
||||
{
|
||||
physx::PxHeightFieldSample *currentSample = (physx::PxHeightFieldSample*)currentByte;
|
||||
|
||||
U32 index = ( blockSize - row - 1 ) + ( column * blockSize );
|
||||
currentSample->height = (physx::PxI16)heights[ index ];
|
||||
|
||||
|
||||
if ( holes && holes[ getMax( (S32)index - 1, 0 ) ] ) // row index for holes adjusted so PhysX collision shape better matches rendered terrain
|
||||
{
|
||||
currentSample->materialIndex0 = physx::PxHeightFieldMaterial::eHOLE;
|
||||
currentSample->materialIndex1 = physx::PxHeightFieldMaterial::eHOLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSample->materialIndex0 = 0;
|
||||
currentSample->materialIndex1 = 0;
|
||||
}
|
||||
|
||||
int flag = ( column + tess ) % 2;
|
||||
if(flag)
|
||||
currentSample->clearTessFlag();
|
||||
else
|
||||
currentSample->setTessFlag();
|
||||
|
||||
currentByte += heightFieldDesc.samples.stride;
|
||||
}
|
||||
}
|
||||
|
||||
physx::PxHeightField * hf = gPhysics3SDK->createHeightField(heightFieldDesc);
|
||||
physx::PxHeightFieldGeometry *geom = new physx::PxHeightFieldGeometry(hf,physx::PxMeshGeometryFlags(),heightScale,metersPerSample,metersPerSample);
|
||||
|
||||
physx::PxTransform pose= physx::PxTransform(physx::PxQuat(Float_HalfPi, physx::PxVec3(1, 0, 0 )));
|
||||
physx::PxTransform pose1= physx::PxTransform(physx::PxQuat(Float_Pi, physx::PxVec3(0, 0, 1 )));
|
||||
physx::PxTransform pose2 = pose1 * pose;
|
||||
pose2.p = physx::PxVec3(( blockSize - 1 ) * metersPerSample, 0, 0 );
|
||||
Px3CollisionDesc *desc = new Px3CollisionDesc;
|
||||
desc->pGeometry = geom;
|
||||
desc->pose = pose2;
|
||||
|
||||
mColShapes.push_back(desc);
|
||||
|
||||
SAFE_DELETE(samples);
|
||||
return true;
|
||||
}
|
||||
87
Engine/source/T3D/physics/physx3/px3Collision.h
Normal file
87
Engine/source/T3D/physics/physx3/px3Collision.h
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _PX3COLLISION_H_
|
||||
#define _PX3COLLISION_H_
|
||||
|
||||
#ifndef _T3D_PHYSICS_PHYSICSCOLLISION_H_
|
||||
#include "T3D/physics/physicsCollision.h"
|
||||
#endif
|
||||
#ifndef _TVECTOR_H_
|
||||
#include "core/util/tVector.h"
|
||||
#endif
|
||||
#ifndef _MMATRIX_H_
|
||||
#include "math/mMatrix.h"
|
||||
#endif
|
||||
|
||||
#include <foundation/PxTransform.h>
|
||||
|
||||
//forward declare
|
||||
namespace physx{class PxGeometry;}
|
||||
|
||||
|
||||
struct Px3CollisionDesc
|
||||
{
|
||||
physx::PxGeometry *pGeometry;
|
||||
physx::PxTransform pose;
|
||||
};
|
||||
|
||||
class Px3Collision : public PhysicsCollision
|
||||
{
|
||||
typedef Vector<Px3CollisionDesc*> Px3CollisionList;
|
||||
protected:
|
||||
/// The collision representation.
|
||||
Px3CollisionList mColShapes;
|
||||
|
||||
public:
|
||||
|
||||
Px3Collision();
|
||||
virtual ~Px3Collision();
|
||||
|
||||
/// Return the PhysX shape descriptions.
|
||||
const Px3CollisionList& getShapes() const { return mColShapes; }
|
||||
|
||||
// PhysicsCollision
|
||||
virtual void addPlane( const PlaneF &plane );
|
||||
virtual void addBox( const Point3F &halfWidth,
|
||||
const MatrixF &localXfm );
|
||||
virtual void addSphere( F32 radius,
|
||||
const MatrixF &localXfm );
|
||||
virtual void addCapsule( F32 radius,
|
||||
F32 height,
|
||||
const MatrixF &localXfm );
|
||||
virtual bool addConvex( const Point3F *points,
|
||||
U32 count,
|
||||
const MatrixF &localXfm );
|
||||
virtual bool addTriangleMesh( const Point3F *vert,
|
||||
U32 vertCount,
|
||||
const U32 *index,
|
||||
U32 triCount,
|
||||
const MatrixF &localXfm );
|
||||
virtual bool addHeightfield( const U16 *heights,
|
||||
const bool *holes,
|
||||
U32 blockSize,
|
||||
F32 metersPerSample,
|
||||
const MatrixF &localXfm );
|
||||
};
|
||||
|
||||
#endif // _PX3COLLISION_H_
|
||||
331
Engine/source/T3D/physics/physx3/px3Player.cpp
Normal file
331
Engine/source/T3D/physics/physx3/px3Player.cpp
Normal file
|
|
@ -0,0 +1,331 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/physics/physx3/px3Player.h"
|
||||
#include "T3D/physics/physicsPlugin.h"
|
||||
#include "T3D/physics/physx3/px3World.h"
|
||||
#include "T3D/physics/physx3/px3Casts.h"
|
||||
#include "T3D/physics/physx3/px3Utils.h"
|
||||
#include "collision/collision.h"
|
||||
|
||||
|
||||
Px3Player::Px3Player()
|
||||
: PhysicsPlayer(),
|
||||
mController( NULL ),
|
||||
mWorld( NULL ),
|
||||
mObject( NULL ),
|
||||
mSkinWidth( 0.05f ),
|
||||
mOriginOffset( 0.0f ),
|
||||
mElapsed(0)
|
||||
{
|
||||
PHYSICSMGR->getPhysicsResetSignal().notify( this, &Px3Player::_onPhysicsReset );
|
||||
}
|
||||
|
||||
Px3Player::~Px3Player()
|
||||
{
|
||||
_releaseController();
|
||||
PHYSICSMGR->getPhysicsResetSignal().remove( this, &Px3Player::_onPhysicsReset );
|
||||
}
|
||||
|
||||
void Px3Player::_releaseController()
|
||||
{
|
||||
if ( mController )
|
||||
{
|
||||
mController->getActor()->userData = NULL;
|
||||
mWorld->getStaticChangedSignal().remove( this, &Px3Player::_onStaticChanged );
|
||||
mController->release();
|
||||
}
|
||||
}
|
||||
|
||||
void Px3Player::init( const char *type,
|
||||
const Point3F &size,
|
||||
F32 runSurfaceCos,
|
||||
F32 stepHeight,
|
||||
SceneObject *obj,
|
||||
PhysicsWorld *world )
|
||||
{
|
||||
AssertFatal( obj, "Px3Player::init - Got a null scene object!" );
|
||||
AssertFatal( world, "Px3Player::init - Got a null world!" );
|
||||
AssertFatal( dynamic_cast<Px3World*>( world ), "Px3Player::init - The world is the wrong type!" );
|
||||
|
||||
// Cleanup any previous controller.
|
||||
_releaseController();
|
||||
|
||||
mObject = obj;
|
||||
mWorld = (Px3World*)world;
|
||||
mOriginOffset = size.z * 0.5f;
|
||||
|
||||
physx::PxCapsuleControllerDesc desc;
|
||||
desc.contactOffset = mSkinWidth;
|
||||
desc.radius = getMax( size.x, size.y ) * 0.5f;
|
||||
desc.radius -= mSkinWidth;
|
||||
desc.height = size.z - ( desc.radius * 2.0f );
|
||||
desc.height -= mSkinWidth * 2.0f;
|
||||
desc.climbingMode = physx::PxCapsuleClimbingMode::eCONSTRAINED;
|
||||
desc.position.set( 0, 0, 0 );
|
||||
desc.upDirection = physx::PxVec3(0,0,1);
|
||||
desc.reportCallback = this;
|
||||
desc.slopeLimit = runSurfaceCos;
|
||||
desc.stepOffset = stepHeight;
|
||||
desc.behaviorCallback = NULL;
|
||||
desc.material = gPhysics3SDK->createMaterial(0.1f, 0.1f, 0.2f);
|
||||
|
||||
mController = mWorld->createController( desc );
|
||||
|
||||
mWorld->getStaticChangedSignal().notify( this, &Px3Player::_onStaticChanged );
|
||||
physx::PxRigidDynamic *kineActor = mController->getActor();
|
||||
|
||||
//player only has one shape
|
||||
physx::PxShape *shape = px3GetFirstShape(kineActor);
|
||||
physx::PxFilterData colData;
|
||||
colData.word0 = PX3_PLAYER;
|
||||
shape->setSimulationFilterData(colData);
|
||||
shape->setQueryFilterData(colData);
|
||||
|
||||
//store geometry for later use in findContact calls
|
||||
shape->getCapsuleGeometry(mGeometry);
|
||||
|
||||
mUserData.setObject( obj );
|
||||
kineActor->userData = &mUserData;
|
||||
|
||||
}
|
||||
|
||||
void Px3Player::_onStaticChanged()
|
||||
{
|
||||
if(mController)
|
||||
mController->invalidateCache();
|
||||
}
|
||||
|
||||
void Px3Player::_onPhysicsReset( PhysicsResetEvent reset )
|
||||
{
|
||||
if(mController)
|
||||
mController->invalidateCache();
|
||||
}
|
||||
|
||||
Point3F Px3Player::move( const VectorF &disp, CollisionList &outCol )
|
||||
{
|
||||
AssertFatal( mController, "Px3Player::move - The controller is null!" );
|
||||
|
||||
// Return the last position if the simulation is stopped.
|
||||
//
|
||||
// See PxPlayer::_onPhysicsReset
|
||||
if ( !mWorld->isEnabled() )
|
||||
{
|
||||
Point3F newPos = px3Cast<Point3F>( mController->getPosition() );
|
||||
newPos.z -= mOriginOffset;
|
||||
return newPos;
|
||||
}
|
||||
|
||||
mWorld->releaseWriteLock();
|
||||
|
||||
mCollisionList = &outCol;
|
||||
|
||||
physx::PxVec3 dispNx( disp.x, disp.y, disp.z );
|
||||
if (mIsZero(disp.z))
|
||||
dispNx.z = 0.0f;
|
||||
|
||||
U32 groups = 0xffffffff;
|
||||
groups &= ~( PX3_TRIGGER ); // No trigger shapes!
|
||||
groups &= ~( PX3_DEBRIS);
|
||||
physx::PxControllerFilters filter;
|
||||
physx::PxFilterData data;
|
||||
data.word0=groups;
|
||||
filter.mFilterData = &data;
|
||||
filter.mFilterFlags = physx::PxSceneQueryFilterFlags(physx::PxControllerFlag::eCOLLISION_DOWN|physx::PxControllerFlag::eCOLLISION_SIDES|physx::PxControllerFlag::eCOLLISION_UP);
|
||||
|
||||
mController->move( dispNx,0.0001f,0, filter );
|
||||
|
||||
Point3F newPos = px3Cast<Point3F>( mController->getPosition() );
|
||||
newPos.z -= mOriginOffset;
|
||||
|
||||
mCollisionList = NULL;
|
||||
|
||||
return newPos;
|
||||
}
|
||||
|
||||
void Px3Player::onShapeHit( const physx::PxControllerShapeHit& hit )
|
||||
{
|
||||
if (!mCollisionList || mCollisionList->getCount() >= CollisionList::MaxCollisions)
|
||||
return;
|
||||
|
||||
physx::PxRigidActor *actor = hit.actor;
|
||||
PhysicsUserData *userData = PhysicsUserData::cast( actor->userData );
|
||||
|
||||
// Fill out the Collision
|
||||
// structure for use later.
|
||||
Collision &col = mCollisionList->increment();
|
||||
dMemset( &col, 0, sizeof( col ) );
|
||||
|
||||
col.normal = px3Cast<Point3F>( hit.worldNormal );
|
||||
col.point = px3Cast<Point3F>( hit.worldPos );
|
||||
col.distance = hit.length;
|
||||
if ( userData )
|
||||
col.object = userData->getObject();
|
||||
|
||||
if (mIsZero(hit.dir.z))
|
||||
{
|
||||
if (col.normal.z > 0.0f)
|
||||
{
|
||||
col.normal.z = 0.0f;
|
||||
col.normal.normalizeSafe();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
col.normal.set(0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Px3Player::onControllerHit( const physx::PxControllersHit& hit )
|
||||
{
|
||||
if (!mCollisionList || mCollisionList->getCount() >= CollisionList::MaxCollisions)
|
||||
return;
|
||||
|
||||
physx::PxRigidActor *actor = hit.other->getActor();
|
||||
PhysicsUserData *userData = PhysicsUserData::cast( actor->userData );
|
||||
|
||||
// For controller-to-controller hit we don't have an actual hit point, so all
|
||||
// we can do is set the hit object.
|
||||
Collision &col = mCollisionList->increment();
|
||||
dMemset( &col, 0, sizeof( col ) );
|
||||
if ( userData )
|
||||
col.object = userData->getObject();
|
||||
|
||||
}
|
||||
|
||||
void Px3Player::findContact( SceneObject **contactObject,
|
||||
VectorF *contactNormal,
|
||||
Vector<SceneObject*> *outOverlapObjects ) const
|
||||
{
|
||||
// Calculate the sweep motion...
|
||||
F32 halfCapSize = mOriginOffset;
|
||||
F32 halfSmallCapSize = halfCapSize * 0.8f;
|
||||
F32 diff = halfCapSize - halfSmallCapSize;
|
||||
|
||||
F32 distance = diff + mSkinWidth + 0.01f;
|
||||
physx::PxVec3 dir(0,0,-1);
|
||||
|
||||
physx::PxScene *scene = mWorld->getScene();
|
||||
physx::PxHitFlags hitFlags(physx::PxHitFlag::eDEFAULT);
|
||||
physx::PxQueryFilterData filterData(physx::PxQueryFlag::eDYNAMIC|physx::PxQueryFlag::eSTATIC);
|
||||
filterData.data.word0 = PX3_DEFAULT;
|
||||
physx::PxSweepHit sweepHit;
|
||||
physx::PxRigidDynamic *actor= mController->getActor();
|
||||
physx::PxU32 shapeIndex;
|
||||
|
||||
bool hit = physx::PxRigidBodyExt::linearSweepSingle(*actor,*scene,dir,distance,hitFlags,sweepHit,shapeIndex,filterData);
|
||||
if ( hit )
|
||||
{
|
||||
PhysicsUserData *data = PhysicsUserData::cast( sweepHit.actor->userData);
|
||||
if ( data )
|
||||
{
|
||||
*contactObject = data->getObject();
|
||||
*contactNormal = px3Cast<Point3F>( sweepHit.normal );
|
||||
}
|
||||
}
|
||||
|
||||
// Check for overlapped objects ( triggers )
|
||||
|
||||
if ( !outOverlapObjects )
|
||||
return;
|
||||
|
||||
filterData.data.word0 = PX3_TRIGGER;
|
||||
|
||||
const physx::PxU32 bufferSize = 10;
|
||||
physx::PxOverlapBufferN<bufferSize> hitBuffer;
|
||||
hit = scene->overlap(mGeometry,actor->getGlobalPose(),hitBuffer,filterData);
|
||||
if(hit)
|
||||
{
|
||||
for ( U32 i = 0; i < hitBuffer.nbTouches; i++ )
|
||||
{
|
||||
PhysicsUserData *data = PhysicsUserData::cast( hitBuffer.touches[i].actor->userData );
|
||||
if ( data )
|
||||
outOverlapObjects->push_back( data->getObject() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Px3Player::enableCollision()
|
||||
{
|
||||
AssertFatal( mController, "Px3Player::enableCollision - The controller is null!" );
|
||||
|
||||
mWorld->releaseWriteLock();
|
||||
px3GetFirstShape(mController->getActor())->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE,true);
|
||||
}
|
||||
|
||||
void Px3Player::disableCollision()
|
||||
{
|
||||
AssertFatal( mController, "Px3Player::disableCollision - The controller is null!" );
|
||||
|
||||
mWorld->releaseWriteLock();
|
||||
px3GetFirstShape(mController->getActor())->setFlag(physx::PxShapeFlag::eSIMULATION_SHAPE,false);
|
||||
}
|
||||
|
||||
PhysicsWorld* Px3Player::getWorld()
|
||||
{
|
||||
return mWorld;
|
||||
}
|
||||
|
||||
void Px3Player::setTransform( const MatrixF &transform )
|
||||
{
|
||||
AssertFatal( mController, "Px3Player::setTransform - The controller is null!" );
|
||||
|
||||
mWorld->releaseWriteLock();
|
||||
|
||||
Point3F newPos = transform.getPosition();
|
||||
newPos.z += mOriginOffset;
|
||||
|
||||
const Point3F &curPos = px3Cast<Point3F>(mController->getPosition());
|
||||
|
||||
if ( !(newPos - curPos ).isZero() )
|
||||
mController->setPosition( px3Cast<physx::PxExtendedVec3>(newPos) );
|
||||
}
|
||||
|
||||
MatrixF& Px3Player::getTransform( MatrixF *outMatrix )
|
||||
{
|
||||
AssertFatal( mController, "Px3Player::getTransform - The controller is null!" );
|
||||
|
||||
Point3F newPos = px3Cast<Point3F>( mController->getPosition() );
|
||||
newPos.z -= mOriginOffset;
|
||||
outMatrix->setPosition( newPos );
|
||||
|
||||
return *outMatrix;
|
||||
}
|
||||
|
||||
void Px3Player::setScale( const Point3F &scale )
|
||||
{
|
||||
//Ignored
|
||||
}
|
||||
|
||||
Box3F Px3Player::getWorldBounds()
|
||||
{
|
||||
physx::PxBounds3 bounds;
|
||||
physx::PxRigidDynamic *actor = mController->getActor();
|
||||
physx::PxShape *shape = px3GetFirstShape(actor);
|
||||
bounds = physx::PxShapeExt::getWorldBounds(*shape,*actor);
|
||||
return px3Cast<Box3F>( bounds );
|
||||
}
|
||||
|
||||
104
Engine/source/T3D/physics/physx3/px3Player.h
Normal file
104
Engine/source/T3D/physics/physx3/px3Player.h
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _PX3PLAYER_H
|
||||
#define _PX3PLAYER_H
|
||||
|
||||
#ifndef _PHYSX3_H_
|
||||
#include "T3D/physics/physx3/px3.h"
|
||||
#endif
|
||||
#ifndef _T3D_PHYSICS_PHYSICSPLAYER_H_
|
||||
#include "T3D/physics/physicsPlayer.h"
|
||||
#endif
|
||||
#ifndef _T3D_PHYSICSCOMMON_H_
|
||||
#include "T3D/physics/physicsCommon.h"
|
||||
#endif
|
||||
|
||||
class Px3World;
|
||||
|
||||
class Px3Player : public PhysicsPlayer, public physx::PxUserControllerHitReport
|
||||
{
|
||||
protected:
|
||||
|
||||
physx::PxController *mController;
|
||||
physx::PxCapsuleGeometry mGeometry;
|
||||
F32 mSkinWidth;
|
||||
|
||||
Px3World *mWorld;
|
||||
|
||||
SceneObject *mObject;
|
||||
|
||||
/// Used to get collision info out of the
|
||||
/// PxUserControllerHitReport callbacks.
|
||||
CollisionList *mCollisionList;
|
||||
|
||||
///
|
||||
F32 mOriginOffset;
|
||||
|
||||
///
|
||||
F32 mStepHeight;
|
||||
U32 mElapsed;
|
||||
///
|
||||
void _releaseController();
|
||||
|
||||
|
||||
virtual void onShapeHit( const physx::PxControllerShapeHit &hit );
|
||||
virtual void onControllerHit( const physx::PxControllersHit &hit );
|
||||
virtual void onObstacleHit(const physx::PxControllerObstacleHit &){}
|
||||
|
||||
void _findContact( SceneObject **contactObject, VectorF *contactNormal ) const;
|
||||
|
||||
void _onPhysicsReset( PhysicsResetEvent reset );
|
||||
|
||||
void _onStaticChanged();
|
||||
|
||||
public:
|
||||
|
||||
Px3Player();
|
||||
virtual ~Px3Player();
|
||||
|
||||
// PhysicsObject
|
||||
virtual PhysicsWorld* getWorld();
|
||||
virtual void setTransform( const MatrixF &transform );
|
||||
virtual MatrixF& getTransform( MatrixF *outMatrix );
|
||||
virtual void setScale( const Point3F &scale );
|
||||
virtual Box3F getWorldBounds();
|
||||
virtual void setSimulationEnabled( bool enabled ) {}
|
||||
virtual bool isSimulationEnabled() { return true; }
|
||||
|
||||
// PhysicsPlayer
|
||||
virtual void init( const char *type,
|
||||
const Point3F &size,
|
||||
F32 runSurfaceCos,
|
||||
F32 stepHeight,
|
||||
SceneObject *obj,
|
||||
PhysicsWorld *world );
|
||||
virtual Point3F move( const VectorF &displacement, CollisionList &outCol );
|
||||
virtual void findContact( SceneObject **contactObject, VectorF *contactNormal, Vector<SceneObject*> *outOverlapObjects ) const;
|
||||
virtual bool testSpacials( const Point3F &nPos, const Point3F &nSize ) const { return true; }
|
||||
virtual void setSpacials( const Point3F &nPos, const Point3F &nSize ) {}
|
||||
virtual void enableCollision();
|
||||
virtual void disableCollision();
|
||||
};
|
||||
|
||||
|
||||
#endif // _PX3PLAYER_H_
|
||||
226
Engine/source/T3D/physics/physx3/px3Plugin.cpp
Normal file
226
Engine/source/T3D/physics/physx3/px3Plugin.cpp
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "T3D/physics/physx3/px3World.h"
|
||||
#include "T3D/physics/physx3/px3Plugin.h"
|
||||
#include "T3D/physics/physx3/px3Collision.h"
|
||||
#include "T3D/physics/physx3/px3Body.h"
|
||||
#include "T3D/physics/physx3/px3Player.h"
|
||||
|
||||
#include "T3D/physics/physicsShape.h"
|
||||
#include "T3D/gameBase/gameProcess.h"
|
||||
#include "core/util/tNamedFactory.h"
|
||||
|
||||
|
||||
AFTER_MODULE_INIT( Sim )
|
||||
{
|
||||
NamedFactory<PhysicsPlugin>::add( "PhysX3", &Px3Plugin::create );
|
||||
|
||||
#if defined(TORQUE_OS_WIN) || defined(TORQUE_OS_XBOX) || defined(TORQUE_OS_XENON)
|
||||
NamedFactory<PhysicsPlugin>::add( "default", &Px3Plugin::create );
|
||||
#endif
|
||||
}
|
||||
|
||||
PhysicsPlugin* Px3Plugin::create()
|
||||
{
|
||||
// Only create the plugin if it hasn't been set up AND
|
||||
// the PhysX world is successfully initialized.
|
||||
bool success = Px3World::restartSDK( false );
|
||||
if ( success )
|
||||
return new Px3Plugin();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Px3Plugin::Px3Plugin()
|
||||
{
|
||||
}
|
||||
|
||||
Px3Plugin::~Px3Plugin()
|
||||
{
|
||||
}
|
||||
|
||||
void Px3Plugin::destroyPlugin()
|
||||
{
|
||||
// Cleanup any worlds that are still kicking.
|
||||
Map<StringNoCase, PhysicsWorld*>::Iterator iter = mPhysicsWorldLookup.begin();
|
||||
for ( ; iter != mPhysicsWorldLookup.end(); iter++ )
|
||||
{
|
||||
iter->value->destroyWorld();
|
||||
delete iter->value;
|
||||
}
|
||||
mPhysicsWorldLookup.clear();
|
||||
|
||||
Px3World::restartSDK( true );
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
void Px3Plugin::reset()
|
||||
{
|
||||
// First delete all the cleanup objects.
|
||||
if ( getPhysicsCleanup() )
|
||||
getPhysicsCleanup()->deleteAllObjects();
|
||||
|
||||
getPhysicsResetSignal().trigger( PhysicsResetEvent_Restore );
|
||||
|
||||
// Now let each world reset itself.
|
||||
Map<StringNoCase, PhysicsWorld*>::Iterator iter = mPhysicsWorldLookup.begin();
|
||||
for ( ; iter != mPhysicsWorldLookup.end(); iter++ )
|
||||
iter->value->reset();
|
||||
}
|
||||
|
||||
PhysicsCollision* Px3Plugin::createCollision()
|
||||
{
|
||||
return new Px3Collision();
|
||||
}
|
||||
|
||||
PhysicsBody* Px3Plugin::createBody()
|
||||
{
|
||||
return new Px3Body();
|
||||
}
|
||||
|
||||
PhysicsPlayer* Px3Plugin::createPlayer()
|
||||
{
|
||||
return new Px3Player();
|
||||
}
|
||||
|
||||
bool Px3Plugin::isSimulationEnabled() const
|
||||
{
|
||||
bool ret = false;
|
||||
Px3World *world = static_cast<Px3World*>( getWorld( smClientWorldName ) );
|
||||
if ( world )
|
||||
{
|
||||
ret = world->isEnabled();
|
||||
return ret;
|
||||
}
|
||||
|
||||
world = static_cast<Px3World*>( getWorld( smServerWorldName ) );
|
||||
if ( world )
|
||||
{
|
||||
ret = world->isEnabled();
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Px3Plugin::enableSimulation( const String &worldName, bool enable )
|
||||
{
|
||||
Px3World *world = static_cast<Px3World*>( getWorld( worldName ) );
|
||||
if ( world )
|
||||
world->setEnabled( enable );
|
||||
}
|
||||
|
||||
void Px3Plugin::setTimeScale( const F32 timeScale )
|
||||
{
|
||||
// Grab both the client and
|
||||
// server worlds and set their time
|
||||
// scales to the passed value.
|
||||
Px3World *world = static_cast<Px3World*>( getWorld( smClientWorldName ) );
|
||||
if ( world )
|
||||
world->setEditorTimeScale( timeScale );
|
||||
|
||||
world = static_cast<Px3World*>( getWorld( smServerWorldName ) );
|
||||
if ( world )
|
||||
world->setEditorTimeScale( timeScale );
|
||||
}
|
||||
|
||||
const F32 Px3Plugin::getTimeScale() const
|
||||
{
|
||||
// Grab both the client and
|
||||
// server worlds and call
|
||||
// setEnabled( true ) on them.
|
||||
Px3World *world = static_cast<Px3World*>( getWorld( smClientWorldName ) );
|
||||
if ( !world )
|
||||
{
|
||||
world = static_cast<Px3World*>( getWorld( smServerWorldName ) );
|
||||
if ( !world )
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
return world->getEditorTimeScale();
|
||||
}
|
||||
|
||||
bool Px3Plugin::createWorld( const String &worldName )
|
||||
{
|
||||
Map<StringNoCase, PhysicsWorld*>::Iterator iter = mPhysicsWorldLookup.find( worldName );
|
||||
PhysicsWorld *world = NULL;
|
||||
|
||||
iter != mPhysicsWorldLookup.end() ? world = (*iter).value : world = NULL;
|
||||
|
||||
if ( world )
|
||||
{
|
||||
Con::errorf( "Px3Plugin::createWorld - %s world already exists!", worldName.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
world = new Px3World();
|
||||
|
||||
if ( worldName.equal( smClientWorldName, String::NoCase ) )
|
||||
world->initWorld( false, ClientProcessList::get() );
|
||||
else
|
||||
world->initWorld( true, ServerProcessList::get() );
|
||||
|
||||
mPhysicsWorldLookup.insert( worldName, world );
|
||||
|
||||
return world != NULL;
|
||||
}
|
||||
|
||||
void Px3Plugin::destroyWorld( const String &worldName )
|
||||
{
|
||||
Map<StringNoCase, PhysicsWorld*>::Iterator iter = mPhysicsWorldLookup.find( worldName );
|
||||
if ( iter == mPhysicsWorldLookup.end() )
|
||||
return;
|
||||
|
||||
PhysicsWorld *world = (*iter).value;
|
||||
world->destroyWorld();
|
||||
delete world;
|
||||
|
||||
mPhysicsWorldLookup.erase( iter );
|
||||
}
|
||||
|
||||
PhysicsWorld* Px3Plugin::getWorld( const String &worldName ) const
|
||||
{
|
||||
if ( mPhysicsWorldLookup.isEmpty() )
|
||||
return NULL;
|
||||
|
||||
Map<StringNoCase, PhysicsWorld*>::ConstIterator iter = mPhysicsWorldLookup.find( worldName );
|
||||
|
||||
return iter != mPhysicsWorldLookup.end() ? (*iter).value : NULL;
|
||||
}
|
||||
|
||||
PhysicsWorld* Px3Plugin::getWorld() const
|
||||
{
|
||||
if ( mPhysicsWorldLookup.size() == 0 )
|
||||
return NULL;
|
||||
|
||||
Map<StringNoCase, PhysicsWorld*>::ConstIterator iter = mPhysicsWorldLookup.begin();
|
||||
return iter->value;
|
||||
}
|
||||
|
||||
U32 Px3Plugin::getWorldCount() const
|
||||
{
|
||||
return mPhysicsWorldLookup.size();
|
||||
}
|
||||
59
Engine/source/T3D/physics/physx3/px3Plugin.h
Normal file
59
Engine/source/T3D/physics/physx3/px3Plugin.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _PX3PLUGIN_H_
|
||||
#define _PX3PLUGIN_H_
|
||||
|
||||
#ifndef _T3D_PHYSICS_PHYSICSPLUGIN_H_
|
||||
#include "T3D/physics/physicsPlugin.h"
|
||||
#endif
|
||||
|
||||
class Px3ClothShape;
|
||||
|
||||
class Px3Plugin : public PhysicsPlugin
|
||||
{
|
||||
public:
|
||||
|
||||
Px3Plugin();
|
||||
~Px3Plugin();
|
||||
|
||||
/// Create function for factory.
|
||||
static PhysicsPlugin* create();
|
||||
|
||||
// PhysicsPlugin
|
||||
virtual void destroyPlugin();
|
||||
virtual void reset();
|
||||
virtual PhysicsCollision* createCollision();
|
||||
virtual PhysicsBody* createBody();
|
||||
virtual PhysicsPlayer* createPlayer();
|
||||
virtual bool isSimulationEnabled() const;
|
||||
virtual void enableSimulation( const String &worldName, bool enable );
|
||||
virtual void setTimeScale( const F32 timeScale );
|
||||
virtual const F32 getTimeScale() const;
|
||||
virtual bool createWorld( const String &worldName );
|
||||
virtual void destroyWorld( const String &worldName );
|
||||
virtual PhysicsWorld* getWorld( const String &worldName ) const;
|
||||
virtual PhysicsWorld* getWorld() const;
|
||||
virtual U32 getWorldCount() const;
|
||||
};
|
||||
|
||||
#endif // _PX3PLUGIN_H_
|
||||
92
Engine/source/T3D/physics/physx3/px3Stream.cpp
Normal file
92
Engine/source/T3D/physics/physx3/px3Stream.cpp
Normal 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/physics/physx3/px3Stream.h"
|
||||
|
||||
#include "console/console.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "core/strings/stringFunctions.h"
|
||||
|
||||
|
||||
Px3MemOutStream::Px3MemOutStream() : mMemStream(1024)
|
||||
{
|
||||
}
|
||||
|
||||
Px3MemOutStream::~Px3MemOutStream()
|
||||
{
|
||||
}
|
||||
|
||||
physx::PxU32 Px3MemOutStream::write(const void *src, physx::PxU32 count)
|
||||
{
|
||||
physx::PxU32 out=0;
|
||||
if(!mMemStream.write(count,src))
|
||||
return out;
|
||||
|
||||
out = count;
|
||||
return out;
|
||||
}
|
||||
|
||||
Px3MemInStream::Px3MemInStream(physx::PxU8* data, physx::PxU32 length):mMemStream(length,data)
|
||||
{
|
||||
}
|
||||
|
||||
physx::PxU32 Px3MemInStream::read(void* dest, physx::PxU32 count)
|
||||
{
|
||||
physx::PxU32 read =0;
|
||||
if(!mMemStream.read(count,dest))
|
||||
return read;
|
||||
|
||||
read = count;
|
||||
return read;
|
||||
}
|
||||
|
||||
void Px3MemInStream::seek(physx::PxU32 pos)
|
||||
{
|
||||
mMemStream.setPosition(pos);
|
||||
}
|
||||
|
||||
physx::PxU32 Px3MemInStream::getLength() const
|
||||
{
|
||||
return mMemStream.getStreamSize();
|
||||
}
|
||||
|
||||
physx::PxU32 Px3MemInStream::tell() const
|
||||
{
|
||||
return mMemStream.getPosition();
|
||||
}
|
||||
|
||||
Px3ConsoleStream::Px3ConsoleStream()
|
||||
{
|
||||
}
|
||||
|
||||
Px3ConsoleStream::~Px3ConsoleStream()
|
||||
{
|
||||
}
|
||||
|
||||
void Px3ConsoleStream::reportError( physx::PxErrorCode code, const char *message, const char* file, int line )
|
||||
{
|
||||
UTF8 info[1024];
|
||||
dSprintf( info, 1024, "File: %s\nLine: %d\n%s", file, line, message );
|
||||
Platform::AlertOK( "PhysX Error", info );
|
||||
// Con::printf( "PhysX Error:\n %s(%d) : %s\n", file, line, message );
|
||||
}
|
||||
77
Engine/source/T3D/physics/physx3/px3Stream.h
Normal file
77
Engine/source/T3D/physics/physx3/px3Stream.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _PX3STREAM_H_
|
||||
#define _PX3STREAM_H_
|
||||
|
||||
#ifndef _PHYSX3_H_
|
||||
#include "T3D/physics/physx3/px3.h"
|
||||
#endif
|
||||
#ifndef _MEMSTREAM_H_
|
||||
#include "core/stream/memStream.h"
|
||||
#endif
|
||||
|
||||
|
||||
class Px3MemOutStream : public physx::PxOutputStream
|
||||
{
|
||||
public:
|
||||
|
||||
Px3MemOutStream();
|
||||
virtual ~Px3MemOutStream();
|
||||
|
||||
void resetPosition();
|
||||
|
||||
virtual physx::PxU32 write(const void *src, physx::PxU32 count);
|
||||
physx::PxU32 getSize() const {return mMemStream.getStreamSize();}
|
||||
physx::PxU8* getData() const {return (physx::PxU8*)mMemStream.getBuffer();}
|
||||
|
||||
protected:
|
||||
|
||||
mutable MemStream mMemStream;
|
||||
};
|
||||
|
||||
class Px3MemInStream: public physx::PxInputData
|
||||
{
|
||||
public:
|
||||
Px3MemInStream(physx::PxU8* data, physx::PxU32 length);
|
||||
virtual physx::PxU32 read(void* dest, physx::PxU32 count);
|
||||
physx::PxU32 getLength() const;
|
||||
virtual void seek(physx::PxU32 pos);
|
||||
virtual physx::PxU32 tell() const;
|
||||
protected:
|
||||
mutable MemStream mMemStream;
|
||||
|
||||
};
|
||||
|
||||
class Px3ConsoleStream : public physx::PxDefaultErrorCallback
|
||||
{
|
||||
protected:
|
||||
|
||||
virtual void reportError( physx::PxErrorCode code, const char *message, const char* file, int line );
|
||||
|
||||
public:
|
||||
|
||||
Px3ConsoleStream();
|
||||
virtual ~Px3ConsoleStream();
|
||||
};
|
||||
|
||||
#endif // _PX3STREAM_H_
|
||||
32
Engine/source/T3D/physics/physx3/px3Utils.cpp
Normal file
32
Engine/source/T3D/physics/physx3/px3Utils.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/physics/physx3/px3Utils.h"
|
||||
#include "T3D/physics/physx3/px3.h"
|
||||
|
||||
physx::PxShape* px3GetFirstShape(physx::PxRigidActor *actor)
|
||||
{
|
||||
physx::PxShape *shapes[1];
|
||||
actor->getShapes(shapes, 1);
|
||||
return shapes[0];
|
||||
}
|
||||
34
Engine/source/T3D/physics/physx3/px3Utils.h
Normal file
34
Engine/source/T3D/physics/physx3/px3Utils.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _PX3UTILS_H_
|
||||
#define _PX3UTILS_H_
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxRigidActor;
|
||||
class PxShape;
|
||||
}
|
||||
|
||||
extern physx::PxShape* px3GetFirstShape(physx::PxRigidActor *actor);
|
||||
|
||||
#endif // _PX3UTILS_H_
|
||||
568
Engine/source/T3D/physics/physx3/px3World.cpp
Normal file
568
Engine/source/T3D/physics/physx3/px3World.cpp
Normal file
|
|
@ -0,0 +1,568 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "T3D/physics/physx3/px3World.h"
|
||||
|
||||
#include "T3D/physics/physx3/px3.h"
|
||||
#include "T3D/physics/physx3/px3Plugin.h"
|
||||
#include "T3D/physics/physx3/px3Casts.h"
|
||||
#include "T3D/physics/physx3/px3Stream.h"
|
||||
#include "T3D/physics/physicsUserData.h"
|
||||
|
||||
#include "console/engineAPI.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
#include "platform/profiler.h"
|
||||
#include "sim/netConnection.h"
|
||||
#include "console/console.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "core/util/safeDelete.h"
|
||||
#include "collision/collision.h"
|
||||
#include "T3D/gameBase/gameProcess.h"
|
||||
#include "gfx/sim/debugDraw.h"
|
||||
#include "gfx/primBuilder.h"
|
||||
|
||||
|
||||
physx::PxPhysics* gPhysics3SDK = NULL;
|
||||
physx::PxCooking* Px3World::smCooking = NULL;
|
||||
physx::PxFoundation* Px3World::smFoundation = NULL;
|
||||
physx::PxProfileZoneManager* Px3World::smProfileZoneManager = NULL;
|
||||
physx::PxDefaultCpuDispatcher* Px3World::smCpuDispatcher=NULL;
|
||||
Px3ConsoleStream* Px3World::smErrorCallback = NULL;
|
||||
physx::PxVisualDebuggerConnection* Px3World::smPvdConnection=NULL;
|
||||
physx::PxDefaultAllocator Px3World::smMemoryAlloc;
|
||||
//Physics timing
|
||||
F32 Px3World::smPhysicsStepTime = 1.0f/(F32)TickMs;
|
||||
U32 Px3World::smPhysicsMaxIterations = 4;
|
||||
|
||||
Px3World::Px3World(): mScene( NULL ),
|
||||
mProcessList( NULL ),
|
||||
mIsSimulating( false ),
|
||||
mErrorReport( false ),
|
||||
mTickCount( 0 ),
|
||||
mIsEnabled( false ),
|
||||
mEditorTimeScale( 1.0f ),
|
||||
mAccumulator( 0 ),
|
||||
mControllerManager( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
Px3World::~Px3World()
|
||||
{
|
||||
}
|
||||
|
||||
physx::PxCooking *Px3World::getCooking()
|
||||
{
|
||||
return smCooking;
|
||||
}
|
||||
|
||||
void Px3World::setTiming(F32 stepTime,U32 maxIterations)
|
||||
{
|
||||
smPhysicsStepTime = stepTime;
|
||||
smPhysicsMaxIterations = maxIterations;
|
||||
}
|
||||
|
||||
bool Px3World::restartSDK( bool destroyOnly, Px3World *clientWorld, Px3World *serverWorld)
|
||||
{
|
||||
// If either the client or the server still exist
|
||||
// then we cannot reset the SDK.
|
||||
if ( clientWorld || serverWorld )
|
||||
return false;
|
||||
|
||||
if(smPvdConnection)
|
||||
smPvdConnection->release();
|
||||
|
||||
if(smCooking)
|
||||
smCooking->release();
|
||||
|
||||
if(smCpuDispatcher)
|
||||
smCpuDispatcher->release();
|
||||
|
||||
// Destroy the existing SDK.
|
||||
if ( gPhysics3SDK )
|
||||
{
|
||||
PxCloseExtensions();
|
||||
gPhysics3SDK->release();
|
||||
}
|
||||
|
||||
if(smErrorCallback)
|
||||
{
|
||||
SAFE_DELETE(smErrorCallback);
|
||||
}
|
||||
|
||||
if(smFoundation)
|
||||
{
|
||||
smFoundation->release();
|
||||
SAFE_DELETE(smErrorCallback);
|
||||
}
|
||||
|
||||
// If we're not supposed to restart... return.
|
||||
if ( destroyOnly )
|
||||
return true;
|
||||
|
||||
bool memTrack = false;
|
||||
#ifdef TORQUE_DEBUG
|
||||
memTrack = true;
|
||||
#endif
|
||||
|
||||
smErrorCallback = new Px3ConsoleStream;
|
||||
smFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, smMemoryAlloc, *smErrorCallback);
|
||||
smProfileZoneManager = &physx::PxProfileZoneManager::createProfileZoneManager(smFoundation);
|
||||
gPhysics3SDK = PxCreatePhysics(PX_PHYSICS_VERSION, *smFoundation, physx::PxTolerancesScale(),memTrack,smProfileZoneManager);
|
||||
|
||||
if ( !gPhysics3SDK )
|
||||
{
|
||||
Con::errorf( "PhysX3 failed to initialize!" );
|
||||
Platform::messageBox( Con::getVariable( "$appName" ),
|
||||
avar("PhysX3 could not be started!\r\n"),
|
||||
MBOk, MIStop );
|
||||
Platform::forceShutdown( -1 );
|
||||
|
||||
// We shouldn't get here, but this shuts up
|
||||
// source diagnostic tools.
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!PxInitExtensions(*gPhysics3SDK))
|
||||
{
|
||||
Con::errorf( "PhysX3 failed to initialize extensions!" );
|
||||
Platform::messageBox( Con::getVariable( "$appName" ),
|
||||
avar("PhysX3 could not be started!\r\n"),
|
||||
MBOk, MIStop );
|
||||
Platform::forceShutdown( -1 );
|
||||
return false;
|
||||
}
|
||||
|
||||
smCooking = PxCreateCooking(PX_PHYSICS_VERSION, *smFoundation, physx::PxCookingParams(physx::PxTolerancesScale()));
|
||||
if(!smCooking)
|
||||
{
|
||||
Con::errorf( "PhysX3 failed to initialize cooking!" );
|
||||
Platform::messageBox( Con::getVariable( "$appName" ),
|
||||
avar("PhysX3 could not be started!\r\n"),
|
||||
MBOk, MIStop );
|
||||
Platform::forceShutdown( -1 );
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
physx::PxVisualDebuggerConnectionFlags connectionFlags(physx::PxVisualDebuggerExt::getAllConnectionFlags());
|
||||
smPvdConnection = physx::PxVisualDebuggerExt::createConnection(gPhysics3SDK->getPvdConnectionManager(),
|
||||
"localhost", 5425, 100, connectionFlags);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Px3World::destroyWorld()
|
||||
{
|
||||
getPhysicsResults();
|
||||
|
||||
// Release the tick processing signals.
|
||||
if ( mProcessList )
|
||||
{
|
||||
mProcessList->preTickSignal().remove( this, &Px3World::getPhysicsResults );
|
||||
mProcessList->postTickSignal().remove( this, &Px3World::tickPhysics );
|
||||
mProcessList = NULL;
|
||||
}
|
||||
|
||||
if(mControllerManager)
|
||||
{
|
||||
mControllerManager->release();
|
||||
mControllerManager = NULL;
|
||||
}
|
||||
|
||||
// Destroy the scene.
|
||||
if ( mScene )
|
||||
{
|
||||
// Release the scene.
|
||||
mScene->release();
|
||||
mScene = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool Px3World::initWorld( bool isServer, ProcessList *processList )
|
||||
{
|
||||
if ( !gPhysics3SDK )
|
||||
{
|
||||
Con::errorf( "Physx3World::init - PhysXSDK not initialized!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
mIsServer = isServer;
|
||||
|
||||
physx::PxSceneDesc sceneDesc(gPhysics3SDK->getTolerancesScale());
|
||||
|
||||
sceneDesc.gravity = px3Cast<physx::PxVec3>(mGravity);
|
||||
sceneDesc.userData = this;
|
||||
if(!sceneDesc.cpuDispatcher)
|
||||
{
|
||||
//Create shared cpu dispatcher
|
||||
if(!smCpuDispatcher)
|
||||
smCpuDispatcher = physx::PxDefaultCpuDispatcherCreate(PHYSICSMGR->getThreadCount());
|
||||
|
||||
sceneDesc.cpuDispatcher = smCpuDispatcher;
|
||||
Con::printf("PhysX3 using Cpu: %d workers", smCpuDispatcher->getWorkerCount());
|
||||
}
|
||||
|
||||
|
||||
sceneDesc.flags |= physx::PxSceneFlag::eENABLE_CCD;
|
||||
sceneDesc.flags |= physx::PxSceneFlag::eENABLE_ACTIVETRANSFORMS;
|
||||
sceneDesc.filterShader = physx::PxDefaultSimulationFilterShader;
|
||||
|
||||
mScene = gPhysics3SDK->createScene(sceneDesc);
|
||||
|
||||
physx::PxDominanceGroupPair debrisDominance( 0.0f, 1.0f );
|
||||
mScene->setDominanceGroupPair(0,31,debrisDominance);
|
||||
|
||||
mControllerManager = PxCreateControllerManager(*mScene);
|
||||
|
||||
AssertFatal( processList, "Px3World::init() - We need a process list to create the world!" );
|
||||
mProcessList = processList;
|
||||
mProcessList->preTickSignal().notify( this, &Px3World::getPhysicsResults );
|
||||
mProcessList->postTickSignal().notify( this, &Px3World::tickPhysics, 1000.0f );
|
||||
|
||||
return true;
|
||||
}
|
||||
// Most of this borrowed from bullet physics library, see btDiscreteDynamicsWorld.cpp
|
||||
bool Px3World::_simulate(const F32 dt)
|
||||
{
|
||||
int numSimulationSubSteps = 0;
|
||||
//fixed timestep with interpolation
|
||||
mAccumulator += dt;
|
||||
if (mAccumulator >= smPhysicsStepTime)
|
||||
{
|
||||
numSimulationSubSteps = int(mAccumulator / smPhysicsStepTime);
|
||||
mAccumulator -= numSimulationSubSteps * smPhysicsStepTime;
|
||||
}
|
||||
if (numSimulationSubSteps)
|
||||
{
|
||||
//clamp the number of substeps, to prevent simulation grinding spiralling down to a halt
|
||||
int clampedSimulationSteps = (numSimulationSubSteps > smPhysicsMaxIterations)? smPhysicsMaxIterations : numSimulationSubSteps;
|
||||
|
||||
for (int i=0;i<clampedSimulationSteps;i++)
|
||||
{
|
||||
mScene->fetchResults(true);
|
||||
mScene->simulate(smPhysicsStepTime);
|
||||
}
|
||||
}
|
||||
|
||||
mIsSimulating = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Px3World::tickPhysics( U32 elapsedMs )
|
||||
{
|
||||
if ( !mScene || !mIsEnabled )
|
||||
return;
|
||||
|
||||
// Did we forget to call getPhysicsResults somewhere?
|
||||
AssertFatal( !mIsSimulating, "PhysX3World::tickPhysics() - Already simulating!" );
|
||||
|
||||
// The elapsed time should be non-zero and
|
||||
// a multiple of TickMs!
|
||||
AssertFatal( elapsedMs != 0 &&
|
||||
( elapsedMs % TickMs ) == 0 , "PhysX3World::tickPhysics() - Got bad elapsed time!" );
|
||||
|
||||
PROFILE_SCOPE(Px3World_TickPhysics);
|
||||
|
||||
// Convert it to seconds.
|
||||
const F32 elapsedSec = (F32)elapsedMs * 0.001f;
|
||||
mIsSimulating = _simulate(elapsedSec * mEditorTimeScale);
|
||||
|
||||
//Con::printf( "%s PhysX3World::tickPhysics!", mIsServer ? "Client" : "Server" );
|
||||
}
|
||||
|
||||
void Px3World::getPhysicsResults()
|
||||
{
|
||||
if ( !mScene || !mIsSimulating )
|
||||
return;
|
||||
|
||||
PROFILE_SCOPE(Px3World_GetPhysicsResults);
|
||||
|
||||
// Get results from scene.
|
||||
mScene->fetchResults(true);
|
||||
mIsSimulating = false;
|
||||
mTickCount++;
|
||||
|
||||
// Con::printf( "%s PhysXWorld::getPhysicsResults!", this == smClientWorld ? "Client" : "Server" );
|
||||
}
|
||||
|
||||
void Px3World::releaseWriteLocks()
|
||||
{
|
||||
Px3World *world = dynamic_cast<Px3World*>( PHYSICSMGR->getWorld( "server" ) );
|
||||
|
||||
if ( world )
|
||||
world->releaseWriteLock();
|
||||
|
||||
world = dynamic_cast<Px3World*>( PHYSICSMGR->getWorld( "client" ) );
|
||||
|
||||
if ( world )
|
||||
world->releaseWriteLock();
|
||||
}
|
||||
|
||||
void Px3World::releaseWriteLock()
|
||||
{
|
||||
if ( !mScene || !mIsSimulating )
|
||||
return;
|
||||
|
||||
PROFILE_SCOPE(PxWorld_ReleaseWriteLock);
|
||||
|
||||
// We use checkResults here to release the write lock
|
||||
// but we do not change the simulation flag or increment
|
||||
// the tick count... we may have gotten results, but the
|
||||
// simulation hasn't really ticked!
|
||||
mScene->checkResults( true );
|
||||
//AssertFatal( mScene->isWritable(), "PhysX3World::releaseWriteLock() - We should have been writable now!" );
|
||||
}
|
||||
|
||||
bool Px3World::castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo *ri, const Point3F &impulse )
|
||||
{
|
||||
|
||||
physx::PxVec3 orig = px3Cast<physx::PxVec3>( startPnt );
|
||||
physx::PxVec3 dir = px3Cast<physx::PxVec3>( endPnt - startPnt );
|
||||
physx::PxF32 maxDist = dir.magnitude();
|
||||
dir.normalize();
|
||||
|
||||
U32 groups = 0xffffffff;
|
||||
groups &= ~( PX3_TRIGGER ); // No trigger shapes!
|
||||
|
||||
physx::PxHitFlags outFlags(physx::PxHitFlag::eDISTANCE | physx::PxHitFlag::eIMPACT | physx::PxHitFlag::eNORMAL);
|
||||
physx::PxQueryFilterData filterData(physx::PxQueryFlag::eSTATIC|physx::PxQueryFlag::eDYNAMIC);
|
||||
filterData.data.word0 = groups;
|
||||
physx::PxRaycastBuffer buf;
|
||||
|
||||
if(!mScene->raycast(orig,dir,maxDist,buf,outFlags,filterData))
|
||||
return false;
|
||||
if(!buf.hasBlock)
|
||||
return false;
|
||||
|
||||
const physx::PxRaycastHit hit = buf.block;
|
||||
physx::PxRigidActor *actor = hit.actor;
|
||||
PhysicsUserData *userData = PhysicsUserData::cast( actor->userData );
|
||||
|
||||
if ( ri )
|
||||
{
|
||||
ri->object = ( userData != NULL ) ? userData->getObject() : NULL;
|
||||
|
||||
if ( ri->object == NULL )
|
||||
|
||||
ri->distance = hit.distance;
|
||||
ri->normal = px3Cast<Point3F>( hit.normal );
|
||||
ri->point = px3Cast<Point3F>( hit.position );
|
||||
ri->t = maxDist / hit.distance;
|
||||
}
|
||||
|
||||
if ( impulse.isZero() ||
|
||||
!actor->isRigidDynamic() ||
|
||||
actor->is<physx::PxRigidDynamic>()->getRigidDynamicFlags() & physx::PxRigidDynamicFlag::eKINEMATIC )
|
||||
return true;
|
||||
|
||||
physx::PxRigidBody *body = actor->is<physx::PxRigidBody>();
|
||||
physx::PxVec3 force = px3Cast<physx::PxVec3>( impulse );
|
||||
physx::PxRigidBodyExt::addForceAtPos(*body,force,hit.position,physx::PxForceMode::eIMPULSE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PhysicsBody* Px3World::castRay( const Point3F &start, const Point3F &end, U32 bodyTypes )
|
||||
{
|
||||
physx::PxVec3 orig = px3Cast<physx::PxVec3>( start );
|
||||
physx::PxVec3 dir = px3Cast<physx::PxVec3>( end - start );
|
||||
physx::PxF32 maxDist = dir.magnitude();
|
||||
dir.normalize();
|
||||
|
||||
U32 groups = 0xFFFFFFFF;
|
||||
if ( !( bodyTypes & BT_Player ) )
|
||||
groups &= ~( PX3_PLAYER );
|
||||
|
||||
// TODO: For now always skip triggers and debris,
|
||||
// but we should consider how game specifc this API
|
||||
// should be in the future.
|
||||
groups &= ~( PX3_TRIGGER ); // triggers
|
||||
groups &= ~( PX3_DEBRIS ); // debris
|
||||
|
||||
physx::PxHitFlags outFlags(physx::PxHitFlag::eDISTANCE | physx::PxHitFlag::eIMPACT | physx::PxHitFlag::eNORMAL);
|
||||
physx::PxQueryFilterData filterData;
|
||||
if(bodyTypes & BT_Static)
|
||||
filterData.flags |= physx::PxQueryFlag::eSTATIC;
|
||||
if(bodyTypes & BT_Dynamic)
|
||||
filterData.flags |= physx::PxQueryFlag::eDYNAMIC;
|
||||
|
||||
filterData.data.word0 = groups;
|
||||
physx::PxRaycastBuffer buf;
|
||||
|
||||
if( !mScene->raycast(orig,dir,maxDist,buf,outFlags,filterData) )
|
||||
return NULL;
|
||||
if(!buf.hasBlock)
|
||||
return NULL;
|
||||
|
||||
physx::PxRigidActor *actor = buf.block.actor;
|
||||
PhysicsUserData *userData = PhysicsUserData::cast( actor->userData );
|
||||
if( !userData )
|
||||
return NULL;
|
||||
|
||||
return userData->getBody();
|
||||
}
|
||||
|
||||
void Px3World::explosion( const Point3F &pos, F32 radius, F32 forceMagnitude )
|
||||
{
|
||||
physx::PxVec3 nxPos = px3Cast<physx::PxVec3>( pos );
|
||||
const physx::PxU32 bufferSize = 10;
|
||||
physx::PxSphereGeometry worldSphere(radius);
|
||||
physx::PxTransform pose(nxPos);
|
||||
physx::PxOverlapBufferN<bufferSize> buffer;
|
||||
|
||||
if(!mScene->overlap(worldSphere,pose,buffer))
|
||||
return;
|
||||
|
||||
for ( physx::PxU32 i = 0; i < buffer.nbTouches; i++ )
|
||||
{
|
||||
physx::PxRigidActor *actor = buffer.touches[i].actor;
|
||||
|
||||
bool dynamic = actor->isRigidDynamic();
|
||||
|
||||
if ( !dynamic )
|
||||
continue;
|
||||
|
||||
bool kinematic = actor->is<physx::PxRigidDynamic>()->getRigidDynamicFlags() & physx::PxRigidDynamicFlag::eKINEMATIC;
|
||||
|
||||
if ( kinematic )
|
||||
continue;
|
||||
|
||||
physx::PxVec3 force = actor->getGlobalPose().p - nxPos;
|
||||
force.normalize();
|
||||
force *= forceMagnitude;
|
||||
|
||||
physx::PxRigidBody *body = actor->is<physx::PxRigidBody>();
|
||||
physx::PxRigidBodyExt::addForceAtPos(*body,force,nxPos,physx::PxForceMode::eIMPULSE);
|
||||
}
|
||||
}
|
||||
|
||||
void Px3World::setEnabled( bool enabled )
|
||||
{
|
||||
mIsEnabled = enabled;
|
||||
|
||||
if ( !mIsEnabled )
|
||||
getPhysicsResults();
|
||||
}
|
||||
|
||||
physx::PxController* Px3World::createController( physx::PxControllerDesc &desc )
|
||||
{
|
||||
if ( !mScene )
|
||||
return NULL;
|
||||
|
||||
// We need the writelock!
|
||||
releaseWriteLock();
|
||||
physx::PxController* pController = mControllerManager->createController(desc);
|
||||
AssertFatal( pController, "Px3World::createController - Got a null!" );
|
||||
return pController;
|
||||
}
|
||||
|
||||
static ColorI getDebugColor( physx::PxU32 packed )
|
||||
{
|
||||
ColorI col;
|
||||
col.blue = (packed)&0xff;
|
||||
col.green = (packed>>8)&0xff;
|
||||
col.red = (packed>>16)&0xff;
|
||||
col.alpha = 255;
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
void Px3World::onDebugDraw( const SceneRenderState *state )
|
||||
{
|
||||
if ( !mScene )
|
||||
return;
|
||||
|
||||
mScene->setVisualizationParameter(physx::PxVisualizationParameter::eSCALE,1.0f);
|
||||
mScene->setVisualizationParameter(physx::PxVisualizationParameter::eBODY_AXES,1.0f);
|
||||
mScene->setVisualizationParameter(physx::PxVisualizationParameter::eCOLLISION_SHAPES,1.0f);
|
||||
|
||||
const physx::PxRenderBuffer *renderBuffer = &mScene->getRenderBuffer();
|
||||
|
||||
if(!renderBuffer)
|
||||
return;
|
||||
|
||||
// Render points
|
||||
{
|
||||
physx::PxU32 numPoints = renderBuffer->getNbPoints();
|
||||
const physx::PxDebugPoint *points = renderBuffer->getPoints();
|
||||
|
||||
PrimBuild::begin( GFXPointList, numPoints );
|
||||
|
||||
while ( numPoints-- )
|
||||
{
|
||||
PrimBuild::color( getDebugColor(points->color) );
|
||||
PrimBuild::vertex3fv(px3Cast<Point3F>(points->pos));
|
||||
points++;
|
||||
}
|
||||
|
||||
PrimBuild::end();
|
||||
}
|
||||
|
||||
// Render lines
|
||||
{
|
||||
physx::PxU32 numLines = renderBuffer->getNbLines();
|
||||
const physx::PxDebugLine *lines = renderBuffer->getLines();
|
||||
|
||||
PrimBuild::begin( GFXLineList, numLines * 2 );
|
||||
|
||||
while ( numLines-- )
|
||||
{
|
||||
PrimBuild::color( getDebugColor( lines->color0 ) );
|
||||
PrimBuild::vertex3fv( px3Cast<Point3F>(lines->pos0));
|
||||
PrimBuild::color( getDebugColor( lines->color1 ) );
|
||||
PrimBuild::vertex3fv( px3Cast<Point3F>(lines->pos1));
|
||||
lines++;
|
||||
}
|
||||
|
||||
PrimBuild::end();
|
||||
}
|
||||
|
||||
// Render triangles
|
||||
{
|
||||
physx::PxU32 numTris = renderBuffer->getNbTriangles();
|
||||
const physx::PxDebugTriangle *triangles = renderBuffer->getTriangles();
|
||||
|
||||
PrimBuild::begin( GFXTriangleList, numTris * 3 );
|
||||
|
||||
while ( numTris-- )
|
||||
{
|
||||
PrimBuild::color( getDebugColor( triangles->color0 ) );
|
||||
PrimBuild::vertex3fv( px3Cast<Point3F>(triangles->pos0) );
|
||||
PrimBuild::color( getDebugColor( triangles->color1 ) );
|
||||
PrimBuild::vertex3fv( px3Cast<Point3F>(triangles->pos1));
|
||||
PrimBuild::color( getDebugColor( triangles->color2 ) );
|
||||
PrimBuild::vertex3fv( px3Cast<Point3F>(triangles->pos2) );
|
||||
triangles++;
|
||||
}
|
||||
|
||||
PrimBuild::end();
|
||||
}
|
||||
|
||||
}
|
||||
//set simulation timing via script
|
||||
DefineEngineFunction( physx3SetSimulationTiming, void, ( F32 stepTime, U32 maxSteps ),, "Set simulation timing of the PhysX 3 plugin" )
|
||||
{
|
||||
Px3World::setTiming(stepTime,maxSteps);
|
||||
}
|
||||
106
Engine/source/T3D/physics/physx3/px3World.h
Normal file
106
Engine/source/T3D/physics/physx3/px3World.h
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _PX3WORLD_H_
|
||||
#define _PX3WORLD_H_
|
||||
|
||||
#ifndef _T3D_PHYSICS_PHYSICSWORLD_H_
|
||||
#include "T3D/physics/physicsWorld.h"
|
||||
#endif
|
||||
#ifndef _MMATH_H_
|
||||
#include "math/mMath.h"
|
||||
#endif
|
||||
#ifndef _PHYSX3_H_
|
||||
#include "T3D/physics/physx3/px3.h"
|
||||
#endif
|
||||
#ifndef _TVECTOR_H_
|
||||
#include "core/util/tVector.h"
|
||||
#endif
|
||||
|
||||
class Px3ConsoleStream;
|
||||
class Px3ContactReporter;
|
||||
class FixedStepper;
|
||||
|
||||
enum Px3CollisionGroup
|
||||
{
|
||||
PX3_DEFAULT = BIT(0),
|
||||
PX3_PLAYER = BIT(1),
|
||||
PX3_DEBRIS = BIT(2),
|
||||
PX3_TRIGGER = BIT(3),
|
||||
};
|
||||
|
||||
class Px3World : public PhysicsWorld
|
||||
{
|
||||
protected:
|
||||
|
||||
physx::PxScene* mScene;
|
||||
bool mIsEnabled;
|
||||
bool mIsSimulating;
|
||||
bool mIsServer;
|
||||
U32 mTickCount;
|
||||
ProcessList *mProcessList;
|
||||
F32 mEditorTimeScale;
|
||||
bool mErrorReport;
|
||||
physx::PxControllerManager* mControllerManager;
|
||||
static Px3ConsoleStream *smErrorCallback;
|
||||
static physx::PxDefaultAllocator smMemoryAlloc;
|
||||
static physx::PxFoundation* smFoundation;
|
||||
static physx::PxCooking *smCooking;
|
||||
static physx::PxProfileZoneManager* smProfileZoneManager;
|
||||
static physx::PxDefaultCpuDispatcher* smCpuDispatcher;
|
||||
static physx::PxVisualDebuggerConnection* smPvdConnection;
|
||||
static F32 smPhysicsStepTime;
|
||||
static U32 smPhysicsMaxIterations;
|
||||
F32 mAccumulator;
|
||||
bool _simulate(const F32 dt);
|
||||
|
||||
public:
|
||||
|
||||
Px3World();
|
||||
virtual ~Px3World();
|
||||
|
||||
virtual bool initWorld( bool isServer, ProcessList *processList );
|
||||
virtual void destroyWorld();
|
||||
virtual void onDebugDraw( const SceneRenderState *state );
|
||||
virtual void reset() {}
|
||||
virtual bool castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo *ri, const Point3F &impulse );
|
||||
virtual PhysicsBody* castRay( const Point3F &start, const Point3F &end, U32 bodyTypes = BT_All );
|
||||
virtual void explosion( const Point3F &pos, F32 radius, F32 forceMagnitude );
|
||||
virtual bool isEnabled() const { return mIsEnabled; }
|
||||
physx::PxScene* getScene(){ return mScene;}
|
||||
void setEnabled( bool enabled );
|
||||
U32 getTick() { return mTickCount; }
|
||||
void tickPhysics( U32 elapsedMs );
|
||||
void getPhysicsResults();
|
||||
void setEditorTimeScale( F32 timeScale ) { mEditorTimeScale = timeScale; }
|
||||
const F32 getEditorTimeScale() const { return mEditorTimeScale; }
|
||||
void releaseWriteLock();
|
||||
bool isServer(){return mIsServer;}
|
||||
physx::PxController* createController( physx::PxControllerDesc &desc );
|
||||
//static
|
||||
static bool restartSDK( bool destroyOnly = false, Px3World *clientWorld = NULL, Px3World *serverWorld = NULL );
|
||||
static void releaseWriteLocks();
|
||||
static physx::PxCooking *getCooking();
|
||||
static void setTiming(F32 stepTime,U32 maxIterations);
|
||||
};
|
||||
|
||||
#endif // _PX3WORLD_H_
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
#include "console/simBase.h"
|
||||
#include "console/console.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "T3D/gameBase/moveManager.h"
|
||||
#include "ts/tsShapeInstance.h"
|
||||
#include "T3D/staticShape.h"
|
||||
|
|
@ -317,15 +318,15 @@ void StaticShape::unpackUpdate(NetConnection *connection, BitStream *bstream)
|
|||
// This appears to be legacy T2 stuff
|
||||
// Marked internal, as this is flagged to be deleted
|
||||
// [8/1/2010 mperry]
|
||||
ConsoleMethod( StaticShape, setPoweredState, void, 3, 3, "(bool isPowered)"
|
||||
DefineConsoleMethod( StaticShape, setPoweredState, void, (bool isPowered), , "(bool isPowered)"
|
||||
"@internal")
|
||||
{
|
||||
if(!object->isServerObject())
|
||||
return;
|
||||
object->setPowered(dAtob(argv[2]));
|
||||
object->setPowered(isPowered);
|
||||
}
|
||||
|
||||
ConsoleMethod( StaticShape, getPoweredState, bool, 2, 2, "@internal")
|
||||
DefineConsoleMethod( StaticShape, getPoweredState, bool, (), , "@internal")
|
||||
{
|
||||
if(!object->isServerObject())
|
||||
return(false);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include "materials/materialFeatureData.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "T3D/accumulationVolume.h"
|
||||
|
||||
using namespace Torque;
|
||||
|
||||
|
|
@ -111,6 +112,11 @@ TSStatic::TSStatic()
|
|||
mMeshCulling = false;
|
||||
mUseOriginSort = false;
|
||||
|
||||
mUseAlphaFade = false;
|
||||
mAlphaFadeStart = 100.0f;
|
||||
mAlphaFadeEnd = 150.0f;
|
||||
mInvertAlphaFade = false;
|
||||
mAlphaFade = 1.0f;
|
||||
mPhysicsRep = NULL;
|
||||
|
||||
mCollisionType = CollisionMesh;
|
||||
|
|
@ -192,6 +198,13 @@ void TSStatic::initPersistFields()
|
|||
|
||||
endGroup("Collision");
|
||||
|
||||
addGroup( "AlphaFade" );
|
||||
addField( "alphaFadeEnable", TypeBool, Offset(mUseAlphaFade, TSStatic), "Turn on/off Alpha Fade" );
|
||||
addField( "alphaFadeStart", TypeF32, Offset(mAlphaFadeStart, TSStatic), "Distance of start Alpha Fade" );
|
||||
addField( "alphaFadeEnd", TypeF32, Offset(mAlphaFadeEnd, TSStatic), "Distance of end Alpha Fade" );
|
||||
addField( "alphaFadeInverse", TypeBool, Offset(mInvertAlphaFade, TSStatic), "Invert Alpha Fade's Start & End Distance" );
|
||||
endGroup( "AlphaFade" );
|
||||
|
||||
addGroup("Debug");
|
||||
|
||||
addField( "renderNormals", TypeF32, Offset( mRenderNormalScalar, TSStatic ),
|
||||
|
|
@ -281,6 +294,13 @@ bool TSStatic::onAdd()
|
|||
|
||||
_updateShouldTick();
|
||||
|
||||
// Accumulation
|
||||
if ( isClientObject() && mShapeInstance )
|
||||
{
|
||||
if ( mShapeInstance->hasAccumulation() )
|
||||
AccumulationVolume::addObject(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -391,6 +411,13 @@ void TSStatic::onRemove()
|
|||
{
|
||||
SAFE_DELETE( mPhysicsRep );
|
||||
|
||||
// Accumulation
|
||||
if ( isClientObject() && mShapeInstance )
|
||||
{
|
||||
if ( mShapeInstance->hasAccumulation() )
|
||||
AccumulationVolume::removeObject(this);
|
||||
}
|
||||
|
||||
mConvexList->nukeList();
|
||||
|
||||
removeFromScene();
|
||||
|
|
@ -502,6 +529,36 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
|||
if (dist < 0.01f)
|
||||
dist = 0.01f;
|
||||
|
||||
if (mUseAlphaFade)
|
||||
{
|
||||
mAlphaFade = 1.0f;
|
||||
if ((mAlphaFadeStart < mAlphaFadeEnd) && mAlphaFadeStart > 0.1f)
|
||||
{
|
||||
if (mInvertAlphaFade)
|
||||
{
|
||||
if (dist <= mAlphaFadeStart)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (dist < mAlphaFadeEnd)
|
||||
{
|
||||
mAlphaFade = ((dist - mAlphaFadeStart) / (mAlphaFadeEnd - mAlphaFadeStart));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dist >= mAlphaFadeEnd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (dist > mAlphaFadeStart)
|
||||
{
|
||||
mAlphaFade -= ((dist - mAlphaFadeStart) / (mAlphaFadeEnd - mAlphaFadeStart));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
|
||||
|
||||
if ( mForceDetail == -1 )
|
||||
|
|
@ -520,6 +577,9 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
|||
rdata.setFadeOverride( 1.0f );
|
||||
rdata.setOriginSort( mUseOriginSort );
|
||||
|
||||
// Acculumation
|
||||
rdata.setAccuTex(mAccuTex);
|
||||
|
||||
// If we have submesh culling enabled then prepare
|
||||
// the object space frustum to pass to the shape.
|
||||
Frustum culler;
|
||||
|
|
@ -545,6 +605,19 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
|||
GFX->setWorldMatrix( mat );
|
||||
|
||||
mShapeInstance->animate();
|
||||
if(mShapeInstance)
|
||||
{
|
||||
if (mUseAlphaFade)
|
||||
{
|
||||
mShapeInstance->setAlphaAlways(mAlphaFade);
|
||||
S32 s = mShapeInstance->mMeshObjects.size();
|
||||
|
||||
for(S32 x = 0; x < s; x++)
|
||||
{
|
||||
mShapeInstance->mMeshObjects[x].visible = mAlphaFade;
|
||||
}
|
||||
}
|
||||
}
|
||||
mShapeInstance->render( rdata );
|
||||
|
||||
if ( mRenderNormalScalar > 0 )
|
||||
|
|
@ -594,6 +667,13 @@ void TSStatic::setTransform(const MatrixF & mat)
|
|||
if ( mPhysicsRep )
|
||||
mPhysicsRep->setTransform( mat );
|
||||
|
||||
// Accumulation
|
||||
if ( isClientObject() && mShapeInstance )
|
||||
{
|
||||
if ( mShapeInstance->hasAccumulation() )
|
||||
AccumulationVolume::updateObject(this);
|
||||
}
|
||||
|
||||
// Since this is a static it's render transform changes 1
|
||||
// to 1 with it's collision transform... no interpolation.
|
||||
setRenderTransform(mat);
|
||||
|
|
@ -625,6 +705,13 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
|||
|
||||
stream->writeFlag( mPlayAmbient );
|
||||
|
||||
if ( stream->writeFlag(mUseAlphaFade) )
|
||||
{
|
||||
stream->write(mAlphaFadeStart);
|
||||
stream->write(mAlphaFadeEnd);
|
||||
stream->write(mInvertAlphaFade);
|
||||
}
|
||||
|
||||
if ( mLightPlugin )
|
||||
retMask |= mLightPlugin->packUpdate(this, AdvancedStaticOptionsMask, con, mask, stream);
|
||||
|
||||
|
|
@ -682,6 +769,14 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
|
||||
mPlayAmbient = stream->readFlag();
|
||||
|
||||
mUseAlphaFade = stream->readFlag();
|
||||
if (mUseAlphaFade)
|
||||
{
|
||||
stream->read(&mAlphaFadeStart);
|
||||
stream->read(&mAlphaFadeEnd);
|
||||
stream->read(&mInvertAlphaFade);
|
||||
}
|
||||
|
||||
if ( mLightPlugin )
|
||||
{
|
||||
mLightPlugin->unpackUpdate(this, con, stream);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,13 @@ class TSStatic : public SceneObject
|
|||
};
|
||||
|
||||
public:
|
||||
void setAlphaFade(bool enable, F32 start, F32 end, bool inverse)
|
||||
{
|
||||
mUseAlphaFade = enable;
|
||||
mAlphaFadeStart = start;
|
||||
mAlphaFadeEnd = end;
|
||||
mInvertAlphaFade = inverse;
|
||||
}
|
||||
|
||||
/// The different types of mesh data types
|
||||
enum MeshType
|
||||
|
|
@ -108,6 +115,11 @@ public:
|
|||
};
|
||||
|
||||
protected:
|
||||
bool mUseAlphaFade;
|
||||
F32 mAlphaFadeStart;
|
||||
F32 mAlphaFadeEnd;
|
||||
F32 mAlphaFade;
|
||||
bool mInvertAlphaFade;
|
||||
|
||||
bool onAdd();
|
||||
void onRemove();
|
||||
|
|
|
|||
|
|
@ -892,7 +892,7 @@ void AITurretShape::_trackTarget(F32 dt)
|
|||
//if (pitch > M_PI_F)
|
||||
// pitch = -(pitch - M_2PI_F);
|
||||
|
||||
Point3F rot(pitch, 0.0f, -yaw);
|
||||
Point3F rot(-pitch, 0.0f, yaw);
|
||||
|
||||
// If we have a rotation rate make sure we follow it
|
||||
if (mHeadingRate > 0)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "console/simBase.h"
|
||||
#include "console/console.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "gui/controls/guiMLTextCtrl.h"
|
||||
#ifdef TORQUE_TGB_ONLY
|
||||
#include "T2D/oldModel/networking/t2dGameConnection.h"
|
||||
|
|
@ -57,22 +58,22 @@ bool gEditingMission = false;
|
|||
|
||||
ConsoleFunctionGroupBegin( InputManagement, "Functions that let you deal with input from scripts" );
|
||||
|
||||
ConsoleFunction( deactivateDirectInput, void, 1, 1, "()"
|
||||
DefineConsoleFunction( deactivateDirectInput, void, (), ,
|
||||
"()"
|
||||
"@brief Disables DirectInput.\n\n"
|
||||
"Also deactivates any connected joysticks.\n\n"
|
||||
"@ingroup Input" )
|
||||
{
|
||||
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
|
||||
if ( Input::isActive() )
|
||||
Input::deactivate();
|
||||
}
|
||||
|
||||
ConsoleFunction( activateDirectInput, void, 1, 1,"()"
|
||||
DefineConsoleFunction( activateDirectInput, void, (), ,
|
||||
"()"
|
||||
"@brief Activates DirectInput.\n\n"
|
||||
"Also activates any connected joysticks."
|
||||
"@ingroup Input")
|
||||
{
|
||||
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
|
||||
if ( !Input::isActive() )
|
||||
Input::activate();
|
||||
}
|
||||
|
|
@ -81,11 +82,8 @@ ConsoleFunctionGroupEnd( InputManagement );
|
|||
//--------------------------------------------------------------------------
|
||||
|
||||
static const U32 MaxPlayerNameLength = 16;
|
||||
ConsoleFunction( strToPlayerName, const char*, 2, 2, "strToPlayerName( string )" )
|
||||
DefineConsoleFunction( strToPlayerName, const char*, (const char* ptr ), , "strToPlayerName(string);" )
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
|
||||
const char* ptr = argv[1];
|
||||
|
||||
// Strip leading spaces and underscores:
|
||||
while ( *ptr == ' ' || *ptr == '_' )
|
||||
|
|
@ -140,16 +138,16 @@ ConsoleFunction( strToPlayerName, const char*, 2, 2, "strToPlayerName( string )"
|
|||
|
||||
ConsoleFunctionGroupBegin( Platform , "General platform functions.");
|
||||
|
||||
ConsoleFunction( lockMouse, void, 2, 2, "(bool isLocked)"
|
||||
DefineConsoleFunction( lockMouse, void, (bool isLocked ), , "(bool isLocked)"
|
||||
"@brief Lock or unlock the mouse to the window.\n\n"
|
||||
"When true, prevents the mouse from leaving the bounds of the game window.\n\n"
|
||||
"@ingroup Input")
|
||||
{
|
||||
Platform::setWindowLocked(dAtob(argv[1]));
|
||||
Platform::setWindowLocked(isLocked);
|
||||
}
|
||||
|
||||
|
||||
ConsoleFunction( setNetPort, bool, 2, 3, "(int port, bool bind=true)"
|
||||
DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int port, bool bind=true)"
|
||||
"@brief Set the network port for the game to use.\n\n"
|
||||
|
||||
"@param port The port to use.\n"
|
||||
|
|
@ -161,37 +159,34 @@ ConsoleFunction( setNetPort, bool, 2, 3, "(int port, bool bind=true)"
|
|||
"If you don't have firewall tunneling tech you can set this to false to avoid the prompt.\n\n"
|
||||
"@ingroup Networking")
|
||||
{
|
||||
bool bind = true;
|
||||
if (argc == 3)
|
||||
bind = dAtob(argv[2]);
|
||||
return Net::openPort(dAtoi(argv[1]), bind);
|
||||
return Net::openPort((S32)port, bind);
|
||||
}
|
||||
|
||||
ConsoleFunction( closeNetPort, void, 1, 1, "()"
|
||||
DefineConsoleFunction( closeNetPort, void, (), , "()"
|
||||
"@brief Closes the current network port\n\n"
|
||||
"@ingroup Networking")
|
||||
{
|
||||
Net::closePort();
|
||||
}
|
||||
|
||||
ConsoleFunction( saveJournal, void, 2, 2, "(string filename)"
|
||||
DefineConsoleFunction( saveJournal, void, (const char * filename), , "(string filename)"
|
||||
"Save the journal to the specified file.\n\n"
|
||||
"@ingroup Platform")
|
||||
{
|
||||
Journal::Record(argv[1]);
|
||||
Journal::Record(filename);
|
||||
}
|
||||
|
||||
ConsoleFunction( playJournal, void, 2, 3, "(string filename)"
|
||||
DefineConsoleFunction( playJournal, void, (const char * filename), , "(string filename)"
|
||||
"@brief Begin playback of a journal from a specified field.\n\n"
|
||||
"@param filename Name and path of file journal file\n"
|
||||
"@ingroup Platform")
|
||||
{
|
||||
// CodeReview - BJG 4/24/2007 - The break flag needs to be wired back in.
|
||||
// bool jBreak = (argc > 2)? dAtob(argv[2]): false;
|
||||
Journal::Play(argv[1]);
|
||||
Journal::Play(filename);
|
||||
}
|
||||
|
||||
ConsoleFunction( getSimTime, S32, 1, 1, "()"
|
||||
DefineConsoleFunction( getSimTime, S32, (), , "()"
|
||||
"Return the current sim time in milliseconds.\n\n"
|
||||
"@brief Sim time is time since the game started.\n\n"
|
||||
"@ingroup Platform")
|
||||
|
|
@ -199,7 +194,7 @@ ConsoleFunction( getSimTime, S32, 1, 1, "()"
|
|||
return Sim::getCurrentTime();
|
||||
}
|
||||
|
||||
ConsoleFunction( getRealTime, S32, 1, 1, "()"
|
||||
DefineConsoleFunction( getRealTime, S32, (), , "()"
|
||||
"@brief Return the current real time in milliseconds.\n\n"
|
||||
"Real time is platform defined; typically time since the computer booted.\n\n"
|
||||
"@ingroup Platform")
|
||||
|
|
|
|||
|
|
@ -207,10 +207,6 @@ struct ServerFilter
|
|||
Favorites = 3,
|
||||
};
|
||||
|
||||
Type type;
|
||||
char* gameType;
|
||||
char* missionType;
|
||||
|
||||
enum // Query Flags
|
||||
{
|
||||
OnlineQuery = 0, // Authenticated with master
|
||||
|
|
@ -226,17 +222,21 @@ struct ServerFilter
|
|||
CurrentVersion = BIT(7),
|
||||
NotXenon = BIT(6)
|
||||
};
|
||||
|
||||
|
||||
//Rearranging the fields according to their sizes
|
||||
char* gameType;
|
||||
char* missionType;
|
||||
U8 queryFlags;
|
||||
U8 minPlayers;
|
||||
U8 maxPlayers;
|
||||
U8 maxBots;
|
||||
U8 filterFlags;
|
||||
U8 buddyCount;
|
||||
U16 minCPU;
|
||||
U32 regionMask;
|
||||
U32 maxPing;
|
||||
U8 filterFlags;
|
||||
U16 minCPU;
|
||||
U8 buddyCount;
|
||||
U32* buddyList;
|
||||
Type type;
|
||||
|
||||
ServerFilter()
|
||||
{
|
||||
|
|
@ -410,25 +410,20 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( queryAllServers, void, 12, 12, "queryAllServers(...);" )
|
||||
DefineConsoleFunction( queryAllServers
|
||||
, void, ( U32 lanPort
|
||||
, U32 flags
|
||||
, const char * gameType
|
||||
, const char * missionType
|
||||
, U32 minPlayers
|
||||
, U32 maxPlayers
|
||||
, U32 maxBots
|
||||
, U32 regionMask
|
||||
, U32 maxPing
|
||||
, U32 minCPU
|
||||
, U32 filterFlags )
|
||||
, , "queryAllServers(...);" )
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
|
||||
U32 lanPort = dAtoi(argv[1]);
|
||||
U8 flags = dAtoi(argv[2]);
|
||||
|
||||
// It's not a good idea to hold onto args, recursive calls to
|
||||
// console exec will trash them.
|
||||
char* gameType = dStrdup(argv[3]);
|
||||
char* missionType = dStrdup(argv[4]);
|
||||
|
||||
U8 minPlayers = dAtoi(argv[5]);
|
||||
U8 maxPlayers = dAtoi(argv[6]);
|
||||
U8 maxBots = dAtoi(argv[7]);
|
||||
U32 regionMask = dAtoi(argv[8]);
|
||||
U32 maxPing = dAtoi(argv[9]);
|
||||
U16 minCPU = dAtoi(argv[10]);
|
||||
U8 filterFlags = dAtoi(argv[11]);
|
||||
U32 buddyList = 0;
|
||||
|
||||
clearServerList();
|
||||
|
|
@ -437,37 +432,32 @@ ConsoleFunction( queryAllServers, void, 12, 12, "queryAllServers(...);" )
|
|||
maxBots,regionMask,maxPing,minCPU,filterFlags,0,&buddyList);
|
||||
|
||||
queryLanServers(lanPort, flags, gameType, missionType, minPlayers, maxPlayers, maxBots,
|
||||
regionMask, maxPing, minCPU, filterFlags);
|
||||
regionMask, maxPing, minCPU, filterFlags);
|
||||
dFree(gameType);
|
||||
dFree(missionType);
|
||||
|
||||
}
|
||||
ConsoleFunction( queryLanServers, void, 12, 12, "queryLanServers(...);" )
|
||||
|
||||
DefineConsoleFunction( queryLanServers
|
||||
, void, ( U32 lanPort
|
||||
, U32 flags
|
||||
, const char * gameType
|
||||
, const char * missionType
|
||||
, U32 minPlayers
|
||||
, U32 maxPlayers
|
||||
, U32 maxBots
|
||||
, U32 regionMask
|
||||
, U32 maxPing
|
||||
, U32 minCPU
|
||||
, U32 filterFlags )
|
||||
, , "queryLanServers(...);" )
|
||||
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
|
||||
U32 lanPort = dAtoi(argv[1]);
|
||||
U8 flags = dAtoi(argv[2]);
|
||||
|
||||
// It's not a good idea to hold onto args, recursive calls to
|
||||
// console exec will trash them.
|
||||
char* gameType = dStrdup(argv[3]);
|
||||
char* missionType = dStrdup(argv[4]);
|
||||
|
||||
U8 minPlayers = dAtoi(argv[5]);
|
||||
U8 maxPlayers = dAtoi(argv[6]);
|
||||
U8 maxBots = dAtoi(argv[7]);
|
||||
U32 regionMask = dAtoi(argv[8]);
|
||||
U32 maxPing = dAtoi(argv[9]);
|
||||
U16 minCPU = dAtoi(argv[10]);
|
||||
U8 filterFlags = dAtoi(argv[11]);
|
||||
|
||||
clearServerList();
|
||||
queryLanServers(lanPort, flags, gameType, missionType, minPlayers, maxPlayers, maxBots,
|
||||
regionMask, maxPing, minCPU, filterFlags);
|
||||
regionMask, maxPing, minCPU, filterFlags);
|
||||
|
||||
dFree(gameType);
|
||||
dFree(missionType);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -550,24 +540,20 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
|
|||
processMasterServerQuery( gPingSession );
|
||||
}
|
||||
|
||||
ConsoleFunction( queryMasterServer, void, 11, 11, "queryMasterServer(...);" )
|
||||
DefineConsoleFunction( queryMasterServer
|
||||
, void, ( U32 lanPort
|
||||
, U32 flags
|
||||
, const char * gameType
|
||||
, const char * missionType
|
||||
, U32 minPlayers
|
||||
, U32 maxPlayers
|
||||
, U32 maxBots
|
||||
, U32 regionMask
|
||||
, U32 maxPing
|
||||
, U32 minCPU
|
||||
, U32 filterFlags )
|
||||
, , "queryMasterServer(...);" )
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
|
||||
U8 flags = dAtoi(argv[1]);
|
||||
|
||||
// It's not a good idea to hold onto args, recursive calls to
|
||||
// console exec will trash them.
|
||||
char* gameType = dStrdup(argv[2]);
|
||||
char* missionType = dStrdup(argv[3]);
|
||||
|
||||
U8 minPlayers = dAtoi(argv[4]);
|
||||
U8 maxPlayers = dAtoi(argv[5]);
|
||||
U8 maxBots = dAtoi(argv[6]);
|
||||
U32 regionMask = dAtoi(argv[7]);
|
||||
U32 maxPing = dAtoi(argv[8]);
|
||||
U16 minCPU = dAtoi(argv[9]);
|
||||
U8 filterFlags = dAtoi(argv[10]);
|
||||
U32 buddyList = 0;
|
||||
|
||||
clearServerList();
|
||||
|
|
@ -580,17 +566,11 @@ ConsoleFunction( queryMasterServer, void, 11, 11, "queryMasterServer(...);" )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( querySingleServer, void, 3, 3, "querySingleServer(address, flags);" )
|
||||
DefineConsoleFunction( querySingleServer
|
||||
, void, ( const char* addrText, U8 flags )
|
||||
, (0), "querySingleServer(address, flags);" )
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
|
||||
NetAddress addr;
|
||||
char* addrText;
|
||||
|
||||
addrText = dStrdup(argv[1]);
|
||||
U8 flags = dAtoi(argv[2]);
|
||||
|
||||
|
||||
Net::stringToAddress( addrText, &addr );
|
||||
querySingleServer(&addr,flags);
|
||||
}
|
||||
|
|
@ -672,9 +652,8 @@ void cancelServerQuery()
|
|||
}
|
||||
}
|
||||
|
||||
ConsoleFunction( cancelServerQuery, void, 1, 1, "cancelServerQuery()" )
|
||||
DefineConsoleFunction( cancelServerQuery, void, (), , "cancelServerQuery();" )
|
||||
{
|
||||
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
|
||||
cancelServerQuery();
|
||||
}
|
||||
|
||||
|
|
@ -701,43 +680,36 @@ void stopServerQuery()
|
|||
}
|
||||
}
|
||||
|
||||
ConsoleFunction( stopServerQuery, void, 1, 1, "stopServerQuery()" )
|
||||
DefineConsoleFunction( stopServerQuery, void, (), , "stopServerQuery();" )
|
||||
{
|
||||
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
|
||||
stopServerQuery();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction(startHeartbeat, void, 1, 1, "startHeartbeat()")
|
||||
DefineConsoleFunction( startHeartbeat, void, (), , "startHeartbeat();" )
|
||||
{
|
||||
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
|
||||
|
||||
if (validateAuthenticatedServer()) {
|
||||
gHeartbeatSeq++;
|
||||
processHeartbeat(gHeartbeatSeq); // thump-thump...
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleFunction(stopHeartbeat, void, 1, 1, "stopHeartbeat();")
|
||||
DefineConsoleFunction( stopHeartbeat, void, (), , "stopHeartbeat();" )
|
||||
{
|
||||
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
|
||||
gHeartbeatSeq++;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( getServerCount, int, 1, 1, "getServerCount();" )
|
||||
DefineConsoleFunction( getServerCount, int, (), , "getServerCount();" )
|
||||
{
|
||||
TORQUE_UNUSED(argv); TORQUE_UNUSED(argc);
|
||||
return gServerList.size();
|
||||
}
|
||||
|
||||
ConsoleFunction( setServerInfo, bool, 2, 2, "setServerInfo(index);" )
|
||||
DefineConsoleFunction( setServerInfo, bool, (U32 index), , "setServerInfo(index);" )
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
U32 index = dAtoi(argv[1]);
|
||||
if (index >= 0 && index < gServerList.size()) {
|
||||
if (index < gServerList.size()) {
|
||||
ServerInfo& info = gServerList[index];
|
||||
|
||||
char addrString[256];
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "platform/platform.h"
|
||||
#include "app/version.h"
|
||||
#include "console/console.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
static const U32 csgVersionNumber = TORQUE_GAME_ENGINE;
|
||||
static const U32 appVersionNumber = TORQUE_APP_VERSION;
|
||||
|
|
@ -91,44 +92,44 @@ const char* getCompileTimeString()
|
|||
|
||||
ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." );
|
||||
|
||||
ConsoleFunction( getVersionNumber, S32, 1, 1, "Get the version of the engine build, as a string.\n\n"
|
||||
DefineConsoleFunction( getVersionNumber, S32, (), , "Get the version of the engine build, as a string.\n\n"
|
||||
"@ingroup Debugging")
|
||||
{
|
||||
return getVersionNumber();
|
||||
}
|
||||
|
||||
ConsoleFunction( getAppVersionNumber, S32, 1, 1, "Get the version of the application build, as a string.\n\n"
|
||||
DefineConsoleFunction( getAppVersionNumber, S32, (), , "Get the version of the application build, as a string.\n\n"
|
||||
"@ingroup Debugging")
|
||||
{
|
||||
return getAppVersionNumber();
|
||||
}
|
||||
|
||||
|
||||
ConsoleFunction( getVersionString, const char*, 1, 1, "Get the version of the engine build, as a human readable string.\n\n"
|
||||
DefineConsoleFunction( getVersionString, const char*, (), , "Get the version of the engine build, as a human readable string.\n\n"
|
||||
"@ingroup Debugging")
|
||||
{
|
||||
return getVersionString();
|
||||
}
|
||||
|
||||
ConsoleFunction( getAppVersionString, const char*, 1, 1, "Get the version of the aplication, as a human readable string.\n\n"
|
||||
DefineConsoleFunction( getAppVersionString, const char*, (), , "Get the version of the aplication build, as a human readable string.\n\n"
|
||||
"@ingroup Debugging")
|
||||
{
|
||||
return getAppVersionString();
|
||||
}
|
||||
|
||||
ConsoleFunction( getEngineName, const char*, 1, 1, "Get the name of the engine product that this is running from, as a string.\n\n"
|
||||
DefineConsoleFunction( getEngineName, const char*, (), , "Get the name of the engine product that this is running from, as a string.\n\n"
|
||||
"@ingroup Debugging")
|
||||
{
|
||||
return getEngineProductString();
|
||||
}
|
||||
|
||||
ConsoleFunction( getCompileTimeString, const char*, 1, 1, "Get the time of compilation.\n\n"
|
||||
DefineConsoleFunction( getCompileTimeString, const char*, (), , "Get the time of compilation.\n\n"
|
||||
"@ingroup Debugging")
|
||||
{
|
||||
return getCompileTimeString();
|
||||
}
|
||||
|
||||
ConsoleFunction( getBuildString, const char*, 1, 1, "Get the type of build, \"Debug\" or \"Release\".\n\n"
|
||||
DefineConsoleFunction( getBuildString, const char*, (), , "Get the type of build, \"Debug\" or \"Release\".\n\n"
|
||||
"@ingroup Debugging")
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
|
|
@ -140,7 +141,7 @@ ConsoleFunction( getBuildString, const char*, 1, 1, "Get the type of build, \"De
|
|||
|
||||
ConsoleFunctionGroupEnd( CompileInformation );
|
||||
|
||||
ConsoleFunction(isDemo, bool, 1, 1, "")
|
||||
DefineConsoleFunction( isDemo, bool, (), , "")
|
||||
{
|
||||
#ifdef TORQUE_DEMO
|
||||
return true;
|
||||
|
|
@ -149,7 +150,7 @@ ConsoleFunction(isDemo, bool, 1, 1, "")
|
|||
#endif
|
||||
}
|
||||
|
||||
ConsoleFunction(isWebDemo, bool, 1, 1, "")
|
||||
DefineConsoleFunction( isWebDemo, bool, (), , "")
|
||||
{
|
||||
#ifdef TORQUE_DEMO
|
||||
return Platform::getWebDeployment();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "platform/platform.h"
|
||||
#include "console/compiler.h"
|
||||
#include "console/consoleInternal.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "core/util/tDictionary.h"
|
||||
#include "core/strings/stringFunctions.h"
|
||||
#include "app/mainLoop.h"
|
||||
|
|
@ -458,20 +459,16 @@ extern "C" {
|
|||
// By default, it is marked as secure by the web plugins and then can be called from
|
||||
// Javascript on the web page to ensure that function calls across the language
|
||||
// boundry are working with arguments and return values
|
||||
ConsoleFunction(testJavaScriptBridge, const char *, 4, 4, "testBridge(arg1, arg2, arg3)")
|
||||
DefineConsoleFunction( testJavaScriptBridge, const char *, (const char* arg1, const char* arg2, const char* arg3), , "testBridge(arg1, arg2, arg3)")
|
||||
{
|
||||
S32 failed = 0;
|
||||
if(argc != 4)
|
||||
failed = 1;
|
||||
else
|
||||
{
|
||||
if (dStrcmp(argv[1],"one"))
|
||||
if (dStrcmp(arg1,"one"))
|
||||
failed = 2;
|
||||
if (dStrcmp(argv[2],"two"))
|
||||
if (dStrcmp(arg2,"two"))
|
||||
failed = 2;
|
||||
if (dStrcmp(argv[3],"three"))
|
||||
if (dStrcmp(arg3,"three"))
|
||||
failed = 2;
|
||||
}
|
||||
|
||||
|
||||
//attempt to call from TorqueScript -> JavaScript
|
||||
const char* jret = Con::evaluate("JS::bridgeCallback(\"one\",\"two\",\"three\");");
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "console/consoleTypes.h"
|
||||
#include "component/simComponent.h"
|
||||
#include "core/stream/stream.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
SimComponent::SimComponent() : mOwner( NULL )
|
||||
{
|
||||
|
|
@ -404,17 +405,16 @@ ConsoleMethod( SimComponent, removeComponents, bool, 3, 64, "%obj.removeComponen
|
|||
return true;
|
||||
}
|
||||
|
||||
ConsoleMethod( SimComponent, getComponentCount, S32, 2, 2, "() Get the current component count\n"
|
||||
DefineConsoleMethod( SimComponent, getComponentCount, S32, (), , "() Get the current component count\n"
|
||||
"@return The number of components in the list as an integer")
|
||||
{
|
||||
return object->getComponentCount();
|
||||
}
|
||||
|
||||
ConsoleMethod( SimComponent, getComponent, S32, 3, 3, "(idx) Get the component corresponding to the given index.\n"
|
||||
DefineConsoleMethod( SimComponent, getComponent, S32, (S32 idx), , "(idx) Get the component corresponding to the given index.\n"
|
||||
"@param idx An integer index value corresponding to the desired component.\n"
|
||||
"@return The id of the component at the given index as an integer")
|
||||
{
|
||||
S32 idx = dAtoi(argv[2]);
|
||||
if(idx < 0 || idx >= object->getComponentCount())
|
||||
{
|
||||
Con::errorf("SimComponent::getComponent - Invalid index %d", idx);
|
||||
|
|
@ -425,27 +425,27 @@ ConsoleMethod( SimComponent, getComponent, S32, 3, 3, "(idx) Get the component c
|
|||
return c ? c->getId() : 0;
|
||||
}
|
||||
|
||||
ConsoleMethod(SimComponent, setEnabled, void, 3, 3, "(enabled) Sets or unsets the enabled flag\n"
|
||||
DefineConsoleMethod(SimComponent, setEnabled, void, (bool enabled), , "(enabled) Sets or unsets the enabled flag\n"
|
||||
"@param enabled Boolean value\n"
|
||||
"@return No return value")
|
||||
{
|
||||
object->setEnabled(dAtob(argv[2]));
|
||||
object->setEnabled(enabled);
|
||||
}
|
||||
|
||||
ConsoleMethod(SimComponent, isEnabled, bool, 2, 2, "() Check whether SimComponent is currently enabled\n"
|
||||
DefineConsoleMethod(SimComponent, isEnabled, bool, (), , "() Check whether SimComponent is currently enabled\n"
|
||||
"@return true if enabled and false if not")
|
||||
{
|
||||
return object->isEnabled();
|
||||
}
|
||||
|
||||
ConsoleMethod(SimComponent, setIsTemplate, void, 3, 3, "(template) Sets or unsets the template flag\n"
|
||||
DefineConsoleMethod(SimComponent, setIsTemplate, void, (bool templateFlag), , "(template) Sets or unsets the template flag\n"
|
||||
"@param template Boolean value\n"
|
||||
"@return No return value")
|
||||
{
|
||||
object->setIsTemplate(dAtob(argv[2]));
|
||||
object->setIsTemplate(templateFlag);
|
||||
}
|
||||
|
||||
ConsoleMethod(SimComponent, getIsTemplate, bool, 2, 2, "() Check whether SimComponent is currently a template\n"
|
||||
DefineConsoleMethod(SimComponent, getIsTemplate, bool, (), , "() Check whether SimComponent is currently a template\n"
|
||||
"@return true if is a template and false if not")
|
||||
{
|
||||
return object->getIsTemplate();
|
||||
|
|
|
|||
|
|
@ -571,21 +571,22 @@ DefineEngineMethod( SimXMLDocument, attribute, const char*, ( const char* attrib
|
|||
}
|
||||
|
||||
// These two methods don't make a lot of sense the way TS works. Leaving them in for backwards-compatibility.
|
||||
ConsoleMethod( SimXMLDocument, attributeF32, F32, 3, 3, "(string attributeName)"
|
||||
DefineConsoleMethod( SimXMLDocument, attributeF32, F32, (const char * attributeName), , "(string attributeName)"
|
||||
"@brief Get float attribute from the current Element on the stack.\n\n"
|
||||
"@param attributeName Name of attribute to retrieve.\n"
|
||||
"@return The value of the given attribute in the form of a float.\n"
|
||||
"@deprecated Use attribute().")
|
||||
{
|
||||
return dAtof( object->attribute( argv[2] ) );
|
||||
return dAtof( object->attribute( attributeName ) );
|
||||
}
|
||||
ConsoleMethod(SimXMLDocument, attributeS32, S32, 3, 3, "(string attributeName)"
|
||||
|
||||
DefineConsoleMethod(SimXMLDocument, attributeS32, S32, (const char * attributeName), , "(string attributeName)"
|
||||
"@brief Get int attribute from the current Element on the stack.\n\n"
|
||||
"@param attributeName Name of attribute to retrieve.\n"
|
||||
"@return The value of the given attribute in the form of an integer.\n"
|
||||
"@deprecated Use attribute().")
|
||||
{
|
||||
return dAtoi( object->attribute( argv[2] ) );
|
||||
return dAtoi( object->attribute( attributeName ) );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -470,11 +470,11 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
|
|||
dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer),
|
||||
"%s(", thisFunctionName);
|
||||
}
|
||||
for (i = 0; i < wantedArgc; i++)
|
||||
for(i = 0; i < wantedArgc; i++)
|
||||
{
|
||||
dStrcat(traceBuffer, argv[i + 1]);
|
||||
if (i != wantedArgc - 1)
|
||||
dStrcat(traceBuffer, ", ");
|
||||
dStrcat(traceBuffer, argv[i+1]);
|
||||
if(i != wantedArgc - 1)
|
||||
dStrcat(traceBuffer, ", ");
|
||||
}
|
||||
dStrcat(traceBuffer, ")");
|
||||
Con::printf("%s", traceBuffer);
|
||||
|
|
@ -533,9 +533,16 @@ ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thi
|
|||
}
|
||||
}
|
||||
|
||||
// Reset the console stack frame which at this point will contain
|
||||
// either nothing or argv[] which we just copied
|
||||
CSTK.resetFrame();
|
||||
bool doResetValueStack = !gEvalState.mResetLocked;
|
||||
gEvalState.mResetLocked = true;
|
||||
|
||||
if (gEvalState.mShouldReset)
|
||||
{
|
||||
// Ensure all stacks are clean in case anything became unbalanced during the previous execution
|
||||
STR.clearFrames();
|
||||
CSTK.clearFrames();
|
||||
gEvalState.mShouldReset = false;
|
||||
}
|
||||
|
||||
// Grab the state of the telenet debugger here once
|
||||
// so that the push and pop frames are always balanced.
|
||||
|
|
@ -1817,7 +1824,7 @@ breakContinue:
|
|||
ConsoleValueRef ret;
|
||||
if(nsEntry->mFunctionOffset)
|
||||
ret = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage);
|
||||
|
||||
|
||||
STR.popFrame();
|
||||
// Functions are assumed to return strings, so look ahead to see if we can skip the conversion
|
||||
if(code[ip] == OP_STR_TO_UINT)
|
||||
|
|
@ -1837,7 +1844,7 @@ breakContinue:
|
|||
}
|
||||
else
|
||||
STR.setStringValue((const char*)ret);
|
||||
|
||||
|
||||
// This will clear everything including returnValue
|
||||
CSTK.popFrame();
|
||||
STR.clearFunctionOffset();
|
||||
|
|
@ -2219,15 +2226,7 @@ execFinished:
|
|||
Con::printf("%s", traceBuffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete[] globalStrings;
|
||||
globalStringsMaxLen = 0;
|
||||
|
||||
delete[] globalFloats;
|
||||
globalStrings = NULL;
|
||||
globalFloats = NULL;
|
||||
}
|
||||
smCurrentCodeBlock = saveCodeBlock;
|
||||
if(saveCodeBlock && saveCodeBlock->name)
|
||||
{
|
||||
|
|
@ -2235,6 +2234,13 @@ execFinished:
|
|||
Con::gCurrentRoot = saveCodeBlock->modPath;
|
||||
}
|
||||
|
||||
// Mark the reset flag for the next run if we've finished execution
|
||||
if (doResetValueStack)
|
||||
{
|
||||
gEvalState.mShouldReset = true;
|
||||
gEvalState.mResetLocked = false;
|
||||
}
|
||||
|
||||
decRefCount();
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ bool useTimestamp = false;
|
|||
|
||||
ConsoleFunctionGroupBegin( Clipboard, "Miscellaneous functions to control the clipboard and clear the console.");
|
||||
|
||||
ConsoleFunction( cls, void, 1, 1, "()"
|
||||
DefineConsoleFunction( cls, void, (), , "()"
|
||||
"@brief Clears the console output.\n\n"
|
||||
"@ingroup Console")
|
||||
{
|
||||
|
|
@ -285,18 +285,18 @@ ConsoleFunction( cls, void, 1, 1, "()"
|
|||
consoleLog.setSize(0);
|
||||
};
|
||||
|
||||
ConsoleFunction( getClipboard, const char*, 1, 1, "()"
|
||||
DefineConsoleFunction( getClipboard, const char*, (), , "()"
|
||||
"@brief Get text from the clipboard.\n\n"
|
||||
"@internal")
|
||||
{
|
||||
return Platform::getClipboard();
|
||||
};
|
||||
|
||||
ConsoleFunction( setClipboard, bool, 2, 2, "(string text)"
|
||||
DefineConsoleFunction( setClipboard, bool, (const char* text), , "(string text)"
|
||||
"@brief Set the system clipboard.\n\n"
|
||||
"@internal")
|
||||
{
|
||||
return Platform::setClipboard(argv[1]);
|
||||
return Platform::setClipboard(text);
|
||||
};
|
||||
|
||||
ConsoleFunctionGroupEnd( Clipboard );
|
||||
|
|
|
|||
|
|
@ -1179,7 +1179,7 @@ static bool isInSet(char c, const char *set)
|
|||
return false;
|
||||
}
|
||||
|
||||
ConsoleFunction( nextToken, const char *, 4, 4, "( string str, string token, string delimiters ) "
|
||||
DefineConsoleFunction( nextToken, const char*, ( const char* str1, const char* token, const char* delim), , "( string str, string token, string delimiters ) "
|
||||
"Tokenize a string using a set of delimiting characters.\n"
|
||||
"This function first skips all leading charaters in @a str that are contained in @a delimiters. "
|
||||
"From that position, it then scans for the next character in @a str that is contained in @a delimiters and stores all characters "
|
||||
|
|
@ -1207,13 +1207,11 @@ ConsoleFunction( nextToken, const char *, 4, 4, "( string str, string token, str
|
|||
"@endtsexample\n\n"
|
||||
"@ingroup Strings" )
|
||||
{
|
||||
char buffer[4096];
|
||||
dStrncpy(buffer, argv[1], 4096);
|
||||
char buffer[4096];
|
||||
dStrncpy(buffer, str1, 4096);
|
||||
char *str = buffer;
|
||||
const char *token = argv[2];
|
||||
const char *delim = argv[3];
|
||||
|
||||
if( str )
|
||||
if( str[0] )
|
||||
{
|
||||
// skip over any characters that are a member of delim
|
||||
// no need for special '\0' check since it can never be in delim
|
||||
|
|
@ -1242,8 +1240,9 @@ ConsoleFunction( nextToken, const char *, 4, 4, "( string str, string token, str
|
|||
str++;
|
||||
}
|
||||
|
||||
char *ret = Con::getReturnBuffer(dStrlen(str)+1);
|
||||
dStrncpy(ret, str, dStrlen(str)+1);
|
||||
U32 returnLen = dStrlen(str)+1;
|
||||
char *ret = Con::getReturnBuffer(returnLen);
|
||||
dStrncpy(ret, str, returnLen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1289,7 +1288,7 @@ DefineEngineFunction( detag, const char*, ( const char* str ),,
|
|||
return str;
|
||||
}
|
||||
|
||||
ConsoleFunction(getTag, const char *, 2, 2, "(string textTagString)"
|
||||
DefineConsoleFunction( getTag, const char*, ( const char* textTagString ), , "( string textTagString ) "
|
||||
"@brief Extracts the tag from a tagged string\n\n"
|
||||
|
||||
"Should only be used within the context of a function that receives a tagged "
|
||||
|
|
@ -1303,26 +1302,24 @@ ConsoleFunction(getTag, const char *, 2, 2, "(string textTagString)"
|
|||
"@see detag()\n"
|
||||
"@ingroup Networking")
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
if(argv[1][0] == StringTagPrefixByte)
|
||||
if(textTagString[0] == StringTagPrefixByte)
|
||||
{
|
||||
const char *arg = argv[1];
|
||||
const char * space = dStrchr(argv[1], ' ');
|
||||
const char * space = dStrchr(textTagString, ' ');
|
||||
|
||||
U32 len;
|
||||
U64 len;
|
||||
if(space)
|
||||
len = space - arg;
|
||||
len = space - textTagString;
|
||||
else
|
||||
len = dStrlen(arg) + 1;
|
||||
len = dStrlen(textTagString) + 1;
|
||||
|
||||
char * ret = Con::getReturnBuffer(len);
|
||||
dStrncpy(ret, arg + 1, len - 1);
|
||||
dStrncpy(ret, textTagString + 1, len - 1);
|
||||
ret[len - 1] = 0;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
else
|
||||
return(argv[1]);
|
||||
return(textTagString);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1512,13 +1509,12 @@ DefineConsoleFunction( quit, void, ( ),,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TORQUE_DEMO_PURCHASE
|
||||
ConsoleFunction( realQuit, void, 1, 1, "" )
|
||||
|
||||
DefineConsoleFunction( realQuit, void, (), , "")
|
||||
{
|
||||
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
|
||||
Platform::postQuitMessage(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -2185,87 +2181,86 @@ DefineEngineFunction( exec, bool, ( const char* fileName, bool noCalls, bool jou
|
|||
return ret;
|
||||
}
|
||||
|
||||
ConsoleFunction(eval, const char *, 2, 2, "eval(consoleString)")
|
||||
DefineConsoleFunction( eval, const char*, ( const char* consoleString ), , "eval(consoleString)" )
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
return Con::evaluate(argv[1], false, NULL);
|
||||
return Con::evaluate(consoleString, false, NULL);
|
||||
}
|
||||
|
||||
ConsoleFunction(getVariable, const char *, 2, 2, "(string varName)\n"
|
||||
DefineConsoleFunction( getVariable, const char*, ( const char* varName ), , "(string varName)\n"
|
||||
"@brief Returns the value of the named variable or an empty string if not found.\n\n"
|
||||
"@varName Name of the variable to search for\n"
|
||||
"@return Value contained by varName, \"\" if the variable does not exist\n"
|
||||
"@ingroup Scripting")
|
||||
{
|
||||
return Con::getVariable(argv[1]);
|
||||
return Con::getVariable(varName);
|
||||
}
|
||||
|
||||
ConsoleFunction(setVariable, void, 3, 3, "(string varName, string value)\n"
|
||||
DefineConsoleFunction( setVariable, void, ( const char* varName, const char* value ), , "(string varName, string value)\n"
|
||||
"@brief Sets the value of the named variable.\n\n"
|
||||
"@param varName Name of the variable to locate\n"
|
||||
"@param value New value of the variable\n"
|
||||
"@return True if variable was successfully found and set\n"
|
||||
"@ingroup Scripting")
|
||||
{
|
||||
return Con::setVariable(argv[1], argv[2]);
|
||||
return Con::setVariable(varName, value);
|
||||
}
|
||||
|
||||
ConsoleFunction(isFunction, bool, 2, 2, "(string funcName)"
|
||||
DefineConsoleFunction( isFunction, bool, ( const char* funcName ), , "(string funcName)"
|
||||
"@brief Determines if a function exists or not\n\n"
|
||||
"@param funcName String containing name of the function\n"
|
||||
"@return True if the function exists, false if not\n"
|
||||
"@ingroup Scripting")
|
||||
{
|
||||
return Con::isFunction(argv[1]);
|
||||
return Con::isFunction(funcName);
|
||||
}
|
||||
|
||||
ConsoleFunction(getFunctionPackage, const char*, 2, 2, "(string funcName)"
|
||||
DefineConsoleFunction( getFunctionPackage, const char*, ( const char* funcName ), , "(string funcName)"
|
||||
"@brief Provides the name of the package the function belongs to\n\n"
|
||||
"@param funcName String containing name of the function\n"
|
||||
"@return The name of the function's package\n"
|
||||
"@ingroup Packages")
|
||||
{
|
||||
Namespace::Entry* nse = Namespace::global()->lookup( StringTable->insert( argv[1] ) );
|
||||
Namespace::Entry* nse = Namespace::global()->lookup( StringTable->insert( funcName ) );
|
||||
if( !nse )
|
||||
return "";
|
||||
|
||||
return nse->mPackage;
|
||||
}
|
||||
|
||||
ConsoleFunction(isMethod, bool, 3, 3, "(string namespace, string method)"
|
||||
DefineConsoleFunction( isMethod, bool, ( const char* nameSpace, const char* method ), , "(string namespace, string method)"
|
||||
"@brief Determines if a class/namespace method exists\n\n"
|
||||
"@param namespace Class or namespace, such as Player\n"
|
||||
"@param method Name of the function to search for\n"
|
||||
"@return True if the method exists, false if not\n"
|
||||
"@ingroup Scripting\n")
|
||||
{
|
||||
Namespace* ns = Namespace::find( StringTable->insert( argv[1] ) );
|
||||
Namespace::Entry* nse = ns->lookup( StringTable->insert( argv[2] ) );
|
||||
Namespace* ns = Namespace::find( StringTable->insert( nameSpace ) );
|
||||
Namespace::Entry* nse = ns->lookup( StringTable->insert( method ) );
|
||||
if( !nse )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ConsoleFunction(getMethodPackage, const char*, 3, 3, "(string namespace, string method)"
|
||||
DefineConsoleFunction( getMethodPackage, const char*, ( const char* nameSpace, const char* method ), , "(string namespace, string method)"
|
||||
"@brief Provides the name of the package the method belongs to\n\n"
|
||||
"@param namespace Class or namespace, such as Player\n"
|
||||
"@param method Name of the funciton to search for\n"
|
||||
"@return The name of the method's package\n"
|
||||
"@ingroup Packages")
|
||||
{
|
||||
Namespace* ns = Namespace::find( StringTable->insert( argv[1] ) );
|
||||
Namespace* ns = Namespace::find( StringTable->insert( nameSpace ) );
|
||||
if( !ns )
|
||||
return "";
|
||||
|
||||
Namespace::Entry* nse = ns->lookup( StringTable->insert( argv[2] ) );
|
||||
Namespace::Entry* nse = ns->lookup( StringTable->insert( method ) );
|
||||
if( !nse )
|
||||
return "";
|
||||
|
||||
return nse->mPackage;
|
||||
}
|
||||
|
||||
ConsoleFunction(isDefined, bool, 2, 3, "(string varName)"
|
||||
DefineConsoleFunction( isDefined, bool, ( const char* varName, const char* varValue ), ("") , "(string varName)"
|
||||
"@brief Determines if a variable exists and contains a value\n"
|
||||
"@param varName Name of the variable to search for\n"
|
||||
"@return True if the variable was defined in script, false if not\n"
|
||||
|
|
@ -2274,13 +2269,13 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)"
|
|||
"@endtsexample\n\n"
|
||||
"@ingroup Scripting")
|
||||
{
|
||||
if(dStrlen(argv[1]) == 0)
|
||||
if(dStrIsEmpty(varName))
|
||||
{
|
||||
Con::errorf("isDefined() - did you forget to put quotes around the variable name?");
|
||||
return false;
|
||||
}
|
||||
|
||||
StringTableEntry name = StringTable->insert(argv[1]);
|
||||
StringTableEntry name = StringTable->insert(varName);
|
||||
|
||||
// Deal with <var>.<value>
|
||||
if (dStrchr(name, '.'))
|
||||
|
|
@ -2331,7 +2326,7 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)"
|
|||
|
||||
if (!value)
|
||||
{
|
||||
obj->setDataField(valName, 0, argv[2]);
|
||||
obj->setDataField(valName, 0, varValue);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2350,8 +2345,10 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)"
|
|||
{
|
||||
if (dStrlen(value) > 0)
|
||||
return true;
|
||||
else if (argc > 2)
|
||||
obj->setDataField(valName, 0, argv[2]);
|
||||
else if (!dStrIsEmpty(varValue))
|
||||
{
|
||||
obj->setDataField(valName, 0, varValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2365,8 +2362,10 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)"
|
|||
|
||||
if (ent)
|
||||
return true;
|
||||
else if (argc > 2)
|
||||
gEvalState.getCurrentFrame().setVariable(name, argv[2]);
|
||||
else if (!dStrIsEmpty(varValue))
|
||||
{
|
||||
gEvalState.getCurrentFrame().setVariable(name, varValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
Con::errorf("%s() - no local variable frame.", __FUNCTION__);
|
||||
|
|
@ -2378,16 +2377,20 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)"
|
|||
|
||||
if (ent)
|
||||
return true;
|
||||
else if (argc > 2)
|
||||
gEvalState.globalVars.setVariable(name, argv[2]);
|
||||
else if (!dStrIsEmpty(varValue))
|
||||
{
|
||||
gEvalState.globalVars.setVariable(name, varValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is it an object?
|
||||
if (dStrcmp(argv[1], "0") && dStrcmp(argv[1], "") && (Sim::findObject(argv[1]) != NULL))
|
||||
if (dStrcmp(varName, "0") && dStrcmp(varName, "") && (Sim::findObject(varName) != NULL))
|
||||
return true;
|
||||
else if (argc > 2)
|
||||
Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, (const char*)argv[1]);
|
||||
else if (!dStrIsEmpty(varValue))
|
||||
{
|
||||
Con::errorf("%s() - can't assign a value to a variable of the form \"%s\"", __FUNCTION__, varValue);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -2395,39 +2398,39 @@ ConsoleFunction(isDefined, bool, 2, 3, "(string varName)"
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( isCurrentScriptToolScript, bool, 1, 1,
|
||||
"() Returns true if the calling script is a tools script.\n"
|
||||
DefineConsoleFunction( isCurrentScriptToolScript, bool, (), , "()"
|
||||
"Returns true if the calling script is a tools script.\n"
|
||||
"@hide")
|
||||
{
|
||||
return Con::isCurrentScriptToolScript();
|
||||
}
|
||||
|
||||
ConsoleFunction(getModNameFromPath, const char *, 2, 2, "(string path)"
|
||||
DefineConsoleFunction( getModNameFromPath, const char *, ( const char* path ), , "(string path)"
|
||||
"@brief Attempts to extract a mod directory from path. Returns empty string on failure.\n\n"
|
||||
"@param File path of mod folder\n"
|
||||
"@note This is no longer relevant in Torque 3D (which does not use mod folders), should be deprecated\n"
|
||||
"@internal")
|
||||
{
|
||||
StringTableEntry modPath = Con::getModNameFromPath(argv[1]);
|
||||
StringTableEntry modPath = Con::getModNameFromPath(path);
|
||||
return modPath ? modPath : "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction( pushInstantGroup, void, 1, 2, "([group])"
|
||||
DefineConsoleFunction( pushInstantGroup, void, ( String group ),("") , "([group])"
|
||||
"@brief Pushes the current $instantGroup on a stack "
|
||||
"and sets it to the given value (or clears it).\n\n"
|
||||
"@note Currently only used for editors\n"
|
||||
"@ingroup Editors\n"
|
||||
"@internal")
|
||||
{
|
||||
if( argc > 1 )
|
||||
Con::pushInstantGroup( (const char*)argv[ 1 ] );
|
||||
if( group.size() > 0 )
|
||||
Con::pushInstantGroup( group );
|
||||
else
|
||||
Con::pushInstantGroup();
|
||||
}
|
||||
|
||||
ConsoleFunction( popInstantGroup, void, 1, 1, "()"
|
||||
DefineConsoleFunction( popInstantGroup, void, (), , "()"
|
||||
"@brief Pop and restore the last setting of $instantGroup off the stack.\n\n"
|
||||
"@note Currently only used for editors\n\n"
|
||||
"@ingroup Editors\n"
|
||||
|
|
@ -2438,11 +2441,11 @@ ConsoleFunction( popInstantGroup, void, 1, 1, "()"
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleFunction(getPrefsPath, const char *, 1, 2, "([relativeFileName])"
|
||||
DefineConsoleFunction( getPrefsPath, const char *, ( const char* relativeFileName ), (""), "([relativeFileName])"
|
||||
"@note Appears to be useless in Torque 3D, should be deprecated\n"
|
||||
"@internal")
|
||||
{
|
||||
const char *filename = Platform::getPrefsPath(argc > 1 ? (const char*)argv[1] : NULL);
|
||||
const char *filename = Platform::getPrefsPath(relativeFileName);
|
||||
if(filename == NULL || *filename == 0)
|
||||
return "";
|
||||
|
||||
|
|
|
|||
|
|
@ -796,6 +796,8 @@ ExprEvalState::ExprEvalState()
|
|||
currentVariable = NULL;
|
||||
mStackDepth = 0;
|
||||
stack.reserve( 64 );
|
||||
mShouldReset = false;
|
||||
mResetLocked = false;
|
||||
}
|
||||
|
||||
ExprEvalState::~ExprEvalState()
|
||||
|
|
|
|||
|
|
@ -468,6 +468,8 @@ public:
|
|||
bool traceOn;
|
||||
|
||||
U32 mStackDepth;
|
||||
bool mShouldReset; ///< Designates if the value stack should be reset
|
||||
bool mResetLocked; ///< mShouldReset will be set at the end
|
||||
|
||||
ExprEvalState();
|
||||
~ExprEvalState();
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ void ConsoleLogger::log( const char *consoleLine )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( ConsoleLogger, attach, bool, 2, 2, "() Attaches the logger to the console and begins writing to file"
|
||||
DefineConsoleMethod( ConsoleLogger, attach, bool, (), , "() Attaches the logger to the console and begins writing to file"
|
||||
"@tsexample\n"
|
||||
"// Create the logger\n"
|
||||
"// Will automatically start writing to testLogging.txt with normal priority\n"
|
||||
|
|
@ -247,7 +247,7 @@ ConsoleMethod( ConsoleLogger, attach, bool, 2, 2, "() Attaches the logger to the
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( ConsoleLogger, detach, bool, 2, 2, "() Detaches the logger from the console and stops writing to file"
|
||||
DefineConsoleMethod( ConsoleLogger, detach, bool, (), , "() Detaches the logger from the console and stops writing to file"
|
||||
"@tsexample\n"
|
||||
"// Create the logger\n"
|
||||
"// Will automatically start writing to testLogging.txt with normal priority\n"
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "console/consoleInternal.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "console/consoleObject.h"
|
||||
#include "console/SimXMLDocument.h"
|
||||
|
||||
|
|
@ -313,7 +314,7 @@ namespace Con {
|
|||
}; // namespace Con
|
||||
|
||||
|
||||
ConsoleFunction(consoleExportXML, const char*, 1, 1, "Exports console definition XML representation")
|
||||
DefineConsoleFunction( consoleExportXML, const char*, (), ,"Exports console definition XML representation" )
|
||||
{
|
||||
Con::XMLExport xmlExport;
|
||||
String xml;
|
||||
|
|
|
|||
|
|
@ -245,6 +245,19 @@ struct EngineUnmarshallData< F32 >
|
|||
}
|
||||
};
|
||||
template<>
|
||||
struct EngineUnmarshallData< U8 >
|
||||
{
|
||||
U8 operator()( ConsoleValueRef &ref ) const
|
||||
{
|
||||
return (U8)((S32)ref);
|
||||
}
|
||||
|
||||
U8 operator()( const char* str ) const
|
||||
{
|
||||
return dAtoui( str );
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct EngineUnmarshallData< const char* >
|
||||
{
|
||||
const char* operator()( const char* str ) const
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "core/strings/stringUnit.h"
|
||||
#include "console/fieldBrushObject.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
// Prefix added to dynamic-fields when they're used to store any copied static-fields when peristing.
|
||||
#define INTERNAL_FIELD_PREFIX "_fieldBrush_"
|
||||
|
|
@ -122,12 +123,12 @@ static char* suppressSpaces(const char* in_pname)
|
|||
//-----------------------------------------------------------------------------
|
||||
// Query Groups.
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleMethod(FieldBrushObject, queryGroups, const char*, 3, 3, "(simObject) Query available static-field groups for selected object./\n"
|
||||
DefineConsoleMethod(FieldBrushObject, queryGroups, const char*, (const char* simObjName), , "(simObject) Query available static-field groups for selected object./\n"
|
||||
"@param simObject Object to query static-field groups on.\n"
|
||||
"@return Space-seperated static-field group list.")
|
||||
{
|
||||
// Fetch selected object.
|
||||
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( argv[2] ) );
|
||||
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) );
|
||||
|
||||
// Valid object?
|
||||
if ( pSimObject == NULL )
|
||||
|
|
@ -190,13 +191,13 @@ ConsoleMethod(FieldBrushObject, queryGroups, const char*, 3, 3, "(simObject) Que
|
|||
//-----------------------------------------------------------------------------
|
||||
// Query Fields.
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleMethod(FieldBrushObject, queryFields, const char*, 3, 4, "(simObject, [groupList]) Query available static-fields for selected object./\n"
|
||||
DefineConsoleMethod(FieldBrushObject, queryFields, const char*, (const char* simObjName, const char* groupList), (""), "(simObject, [groupList]) Query available static-fields for selected object./\n"
|
||||
"@param simObject Object to query static-fields on.\n"
|
||||
"@param groupList groups to filter static-fields against.\n"
|
||||
"@return Space-seperated static-field list.")
|
||||
{
|
||||
// Fetch selected object.
|
||||
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( argv[2] ) );
|
||||
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) );
|
||||
|
||||
// Valid object?
|
||||
if ( pSimObject == NULL )
|
||||
|
|
@ -215,7 +216,7 @@ ConsoleMethod(FieldBrushObject, queryFields, const char*, 3, 4, "(simObject, [gr
|
|||
const AbstractClassRep::FieldList& staticFields = pSimObject->getFieldList();
|
||||
|
||||
// Did we specify a groups list?
|
||||
if ( argc < 4 )
|
||||
if ( dStrIsEmpty(groupList) )
|
||||
{
|
||||
// No, so return all fields...
|
||||
|
||||
|
|
@ -263,7 +264,6 @@ ConsoleMethod(FieldBrushObject, queryFields, const char*, 3, 4, "(simObject, [gr
|
|||
// Group List.
|
||||
Vector<StringTableEntry> groups;
|
||||
// Yes, so fetch group list.
|
||||
const char* groupList = argv[3];
|
||||
// Yes, so calculate group Count.
|
||||
const U32 groupCount = StringUnit::getUnitCount( groupList, " \t\n" );
|
||||
|
||||
|
|
@ -366,13 +366,13 @@ ConsoleMethod(FieldBrushObject, queryFields, const char*, 3, 4, "(simObject, [gr
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copy Fields.
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleMethod(FieldBrushObject, copyFields, void, 3, 4, "(simObject, [fieldList]) Copy selected static-fields for selected object./\n"
|
||||
DefineConsoleMethod(FieldBrushObject, copyFields, void, (const char* simObjName, const char* pFieldList), (""), "(simObject, [fieldList]) Copy selected static-fields for selected object./\n"
|
||||
"@param simObject Object to copy static-fields from.\n"
|
||||
"@param fieldList fields to filter static-fields against.\n"
|
||||
"@return No return value.")
|
||||
{
|
||||
// Fetch selected object.
|
||||
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( argv[2] ) );
|
||||
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) );
|
||||
|
||||
// Valid object?
|
||||
if ( pSimObject == NULL )
|
||||
|
|
@ -383,7 +383,6 @@ ConsoleMethod(FieldBrushObject, copyFields, void, 3, 4, "(simObject, [fieldList]
|
|||
}
|
||||
|
||||
// Fetch field list.
|
||||
const char* pFieldList = (argc > 3 ) ? (const char*)argv[3] : NULL;
|
||||
|
||||
// Copy Fields.
|
||||
object->copyFields( pSimObject, pFieldList );
|
||||
|
|
@ -501,12 +500,12 @@ void FieldBrushObject::copyFields( SimObject* pSimObject, const char* fieldList
|
|||
//-----------------------------------------------------------------------------
|
||||
// Paste Fields.
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleMethod(FieldBrushObject, pasteFields, void, 3, 3, "(simObject) Paste copied static-fields to selected object./\n"
|
||||
DefineConsoleMethod(FieldBrushObject, pasteFields, void, (const char* simObjName), , "(simObject) Paste copied static-fields to selected object./\n"
|
||||
"@param simObject Object to paste static-fields to.\n"
|
||||
"@return No return value.")
|
||||
{
|
||||
// Fetch selected object.
|
||||
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( argv[2] ) );
|
||||
SimObject* pSimObject = dynamic_cast<SimObject*>( Sim::findObject( simObjName ) );
|
||||
|
||||
// Valid object?
|
||||
if ( pSimObject == NULL )
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "persistenceManager.h"
|
||||
#include "console/simSet.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
#include "gui/core/guiTypes.h"
|
||||
#include "materials/customMaterialDefinition.h"
|
||||
|
|
@ -2189,52 +2190,51 @@ void PersistenceManager::deleteObjectsFromFile(const char* fileName)
|
|||
clearAll();
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, deleteObjectsFromFile, void, 3, 3, "( fileName )"
|
||||
DefineConsoleMethod( PersistenceManager, deleteObjectsFromFile, void, ( const char * fileName ), , "( fileName )"
|
||||
"Delete all of the objects that are created from the given file." )
|
||||
{
|
||||
// Delete Objects.
|
||||
object->deleteObjectsFromFile( argv[2] );
|
||||
object->deleteObjectsFromFile( fileName );
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, setDirty, void, 3, 4, "(SimObject object, [filename])"
|
||||
DefineConsoleMethod( PersistenceManager, setDirty, void, ( const char * objName, const char * fileName ), (""), "(SimObject object, [filename])"
|
||||
"Mark an existing SimObject as dirty (will be written out when saveDirty() is called).")
|
||||
{
|
||||
SimObject *dirtyObject = NULL;
|
||||
if (argv[2][0])
|
||||
if (dStrcmp(objName,"") != 0)
|
||||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
if (!Sim::findObject(objName, dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
Con::printf("PersistenceManager::setDirty(): Invalid SimObject: %s", objName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent ourselves from shooting us in the foot.
|
||||
|
||||
if( dirtyObject == Sim::getRootGroup() )
|
||||
{
|
||||
Con::errorf( "%s(): Cannot save RootGroup", (const char*)argv[ 0 ] );
|
||||
Con::errorf( "PersistenceManager::setDirty(): Cannot save RootGroup" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (dirtyObject)
|
||||
{
|
||||
if (argc == 4 && argv[3][0])
|
||||
object->setDirty(dirtyObject, argv[3]);
|
||||
if (dStrcmp( fileName,"")!=0)
|
||||
object->setDirty(dirtyObject, fileName);
|
||||
else
|
||||
object->setDirty(dirtyObject);
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, removeDirty, void, 3, 3, "(SimObject object)"
|
||||
DefineConsoleMethod( PersistenceManager, removeDirty, void, ( const char * objName ), , "(SimObject object)"
|
||||
"Remove a SimObject from the dirty list.")
|
||||
{
|
||||
SimObject *dirtyObject = NULL;
|
||||
if (argv[2][0])
|
||||
if (dStrcmp( objName,"")!=0)
|
||||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
if (!Sim::findObject(objName, dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
Con::printf("PersistenceManager::removeDirty(): Invalid SimObject: %s", objName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2243,15 +2243,15 @@ ConsoleMethod( PersistenceManager, removeDirty, void, 3, 3, "(SimObject object)"
|
|||
object->removeDirty(dirtyObject);
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, isDirty, bool, 3, 3, "(SimObject object)"
|
||||
DefineConsoleMethod( PersistenceManager, isDirty, bool, ( const char * objName ), , "(SimObject object)"
|
||||
"Returns true if the SimObject is on the dirty list.")
|
||||
{
|
||||
SimObject *dirtyObject = NULL;
|
||||
if (argv[2][0])
|
||||
if (dStrcmp ( objName,"")!=0)
|
||||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
if (!Sim::findObject(objName, dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
Con::printf("PersistenceManager::isDirty(): Invalid SimObject: %s", objName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -2262,25 +2262,24 @@ ConsoleMethod( PersistenceManager, isDirty, bool, 3, 3, "(SimObject object)"
|
|||
return false;
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, hasDirty, bool, 2, 2, "()"
|
||||
DefineConsoleMethod( PersistenceManager, hasDirty, bool, (), , "()"
|
||||
"Returns true if the manager has dirty objects to save." )
|
||||
{
|
||||
return object->hasDirty();
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, getDirtyObjectCount, S32, 2, 2, "()"
|
||||
DefineConsoleMethod( PersistenceManager, getDirtyObjectCount, S32, (), , "()"
|
||||
"Returns the number of dirty objects." )
|
||||
{
|
||||
return object->getDirtyList().size();
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, getDirtyObject, S32, 3, 3, "( index )"
|
||||
DefineConsoleMethod( PersistenceManager, getDirtyObject, S32, (S32 index), , "( index )"
|
||||
"Returns the ith dirty object." )
|
||||
{
|
||||
const S32 index = dAtoi( argv[2] );
|
||||
if ( index < 0 || index >= object->getDirtyList().size() )
|
||||
{
|
||||
Con::warnf( "PersistenceManager::getDirtyObject() - Index (%s) out of range.", (const char*)argv[2] );
|
||||
Con::warnf( "PersistenceManager::getDirtyObject() - Index (%s) out of range.", index );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2291,7 +2290,7 @@ ConsoleMethod( PersistenceManager, getDirtyObject, S32, 3, 3, "( index )"
|
|||
return ( dirtyObject.getObject() ) ? dirtyObject.getObject()->getId() : 0;
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, listDirty, void, 2, 2, "()"
|
||||
DefineConsoleMethod( PersistenceManager, listDirty, void, (), , "()"
|
||||
"Prints the dirty list to the console.")
|
||||
{
|
||||
const PersistenceManager::DirtyList dirtyList = object->getDirtyList();
|
||||
|
|
@ -2319,21 +2318,21 @@ ConsoleMethod( PersistenceManager, listDirty, void, 2, 2, "()"
|
|||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, saveDirty, bool, 2, 2, "()"
|
||||
DefineConsoleMethod( PersistenceManager, saveDirty, bool, (), , "()"
|
||||
"Saves all of the SimObject's on the dirty list to their respective files.")
|
||||
{
|
||||
return object->saveDirty();
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, saveDirtyObject, bool, 3, 3, "(SimObject object)"
|
||||
DefineConsoleMethod( PersistenceManager, saveDirtyObject, bool, (const char * objName), , "(SimObject object)"
|
||||
"Save a dirty SimObject to it's file.")
|
||||
{
|
||||
SimObject *dirtyObject = NULL;
|
||||
if (argv[2][0])
|
||||
if (dStrcmp ( objName, "")!=0)
|
||||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
if (!Sim::findObject(objName, dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
Con::printf("%s(): Invalid SimObject: %s", object->getName(), objName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -2343,51 +2342,51 @@ ConsoleMethod( PersistenceManager, saveDirtyObject, bool, 3, 3, "(SimObject obje
|
|||
return false;
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, clearAll, void, 2, 2, "()"
|
||||
DefineConsoleMethod( PersistenceManager, clearAll, void, (), , "()"
|
||||
"Clears all the tracked objects without saving them." )
|
||||
{
|
||||
object->clearAll();
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, removeObjectFromFile, void, 3, 4, "(SimObject object, [filename])"
|
||||
DefineConsoleMethod( PersistenceManager, removeObjectFromFile, void, (const char * objName, const char * filename),("") , "(SimObject object, [filename])"
|
||||
"Remove an existing SimObject from a file (can optionally specify a different file than \
|
||||
the one it was created in.")
|
||||
{
|
||||
SimObject *dirtyObject = NULL;
|
||||
if (argv[2][0])
|
||||
if (dStrcmp ( objName , "")!=0)
|
||||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
if (!Sim::findObject(objName, dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
Con::printf("PersistenceManager::removeObjectFromFile(): Invalid SimObject: %s", objName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (dirtyObject)
|
||||
{
|
||||
if (argc == 4 && argv[3][0])
|
||||
object->removeObjectFromFile(dirtyObject, argv[3]);
|
||||
if (dStrcmp( filename,"")!=0)
|
||||
object->removeObjectFromFile(dirtyObject, filename);
|
||||
else
|
||||
object->removeObjectFromFile(dirtyObject);
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( PersistenceManager, removeField, void, 4, 4, "(SimObject object, string fieldName)"
|
||||
DefineConsoleMethod( PersistenceManager, removeField, void, (const char * objName, const char * fieldName), , "(SimObject object, string fieldName)"
|
||||
"Remove a specific field from an object declaration.")
|
||||
{
|
||||
SimObject *dirtyObject = NULL;
|
||||
if (argv[2][0])
|
||||
if (dStrcmp(objName,"")!=0)
|
||||
{
|
||||
if (!Sim::findObject(argv[2], dirtyObject))
|
||||
if (!Sim::findObject(objName, dirtyObject))
|
||||
{
|
||||
Con::printf("%s(): Invalid SimObject: %s", (const char*)argv[0], (const char*)argv[2]);
|
||||
Con::printf("PersistenceManager::removeField(): Invalid SimObject: %s", objName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (dirtyObject)
|
||||
{
|
||||
if (argv[3][0])
|
||||
object->addRemoveField(dirtyObject, argv[3]);
|
||||
if (dStrcmp(fieldName,"") != 0)
|
||||
object->addRemoveField(dirtyObject, fieldName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "console/console.h"
|
||||
|
||||
#include "console/engineAPI.h"
|
||||
#include "console/sim.h"
|
||||
#include "console/simEvents.h"
|
||||
#include "console/simObject.h"
|
||||
|
|
@ -86,23 +86,21 @@ namespace Sim
|
|||
|
||||
ConsoleFunctionGroupBegin ( SimFunctions, "Functions relating to Sim.");
|
||||
|
||||
ConsoleFunction(nameToID, S32, 2, 2, "nameToID(object)")
|
||||
DefineConsoleFunction( nameToID, S32, (const char * objectName), ,"nameToID(object)")
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
SimObject *obj = Sim::findObject(argv[1]);
|
||||
SimObject *obj = Sim::findObject(objectName);
|
||||
if(obj)
|
||||
return obj->getId();
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
ConsoleFunction(isObject, bool, 2, 2, "isObject(object)")
|
||||
DefineConsoleFunction( isObject, bool, (const char * objectName), ,"isObject(object)")
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
if (!dStrcmp(argv[1], "0") || !dStrcmp(argv[1], ""))
|
||||
if (!dStrcmp(objectName, "0") || !dStrcmp(objectName, ""))
|
||||
return false;
|
||||
else
|
||||
return (Sim::findObject(argv[1]) != NULL);
|
||||
return (Sim::findObject(objectName) != NULL);
|
||||
}
|
||||
|
||||
ConsoleDocFragment _spawnObject1(
|
||||
|
|
@ -135,24 +133,14 @@ ConsoleDocFragment _spawnObject1(
|
|||
"bool spawnObject(class [, dataBlock, name, properties, script]);"
|
||||
);
|
||||
|
||||
ConsoleFunction(spawnObject, S32, 3, 6, "spawnObject(class [, dataBlock, name, properties, script])"
|
||||
DefineConsoleFunction( spawnObject, S32, ( const char * spawnClass
|
||||
, const char * spawnDataBlock
|
||||
, const char * spawnName
|
||||
, const char * spawnProperties
|
||||
, const char * spawnScript
|
||||
),("","","","") ,"spawnObject(class [, dataBlock, name, properties, script])"
|
||||
"@hide")
|
||||
{
|
||||
String spawnClass((const char*)argv[1]);
|
||||
String spawnDataBlock;
|
||||
String spawnName;
|
||||
String spawnProperties;
|
||||
String spawnScript;
|
||||
|
||||
if (argc >= 3)
|
||||
spawnDataBlock = (const char*)argv[2];
|
||||
if (argc >= 4)
|
||||
spawnName = (const char*)argv[3];
|
||||
if (argc >= 5)
|
||||
spawnProperties = (const char*)argv[4];
|
||||
if (argc >= 6)
|
||||
spawnScript = (const char*)argv[5];
|
||||
|
||||
SimObject* spawnObject = Sim::spawnObject(spawnClass, spawnDataBlock, spawnName, spawnProperties, spawnScript);
|
||||
|
||||
if (spawnObject)
|
||||
|
|
@ -161,35 +149,35 @@ ConsoleFunction(spawnObject, S32, 3, 6, "spawnObject(class [, dataBlock, name, p
|
|||
return -1;
|
||||
}
|
||||
|
||||
ConsoleFunction(cancel,void,2,2,"cancel(eventId)")
|
||||
DefineConsoleFunction( cancel, void, (S32 eventId), ,"cancel(eventId)")
|
||||
{
|
||||
Sim::cancelEvent(dAtoi(argv[1]));
|
||||
Sim::cancelEvent(eventId);
|
||||
}
|
||||
|
||||
ConsoleFunction(cancelAll,void,2,2,"cancelAll(objectId): cancel pending events on the specified object. Events will be automatically cancelled if object is deleted.")
|
||||
DefineConsoleFunction( cancelAll, void, (const char * objectId), ,"cancelAll(objectId): cancel pending events on the specified object. Events will be automatically cancelled if object is deleted.")
|
||||
{
|
||||
Sim::cancelPendingEvents(Sim::findObject(argv[1]));
|
||||
Sim::cancelPendingEvents(Sim::findObject(objectId));
|
||||
}
|
||||
|
||||
ConsoleFunction(isEventPending, bool, 2, 2, "isEventPending(%scheduleId);")
|
||||
DefineConsoleFunction( isEventPending, bool, (S32 scheduleId), ,"isEventPending(%scheduleId);")
|
||||
{
|
||||
return Sim::isEventPending(dAtoi(argv[1]));
|
||||
return Sim::isEventPending(scheduleId);
|
||||
}
|
||||
|
||||
ConsoleFunction(getEventTimeLeft, S32, 2, 2, "getEventTimeLeft(scheduleId) Get the time left in ms until this event will trigger.")
|
||||
DefineConsoleFunction( getEventTimeLeft, S32, (S32 scheduleId), ,"getEventTimeLeft(scheduleId) Get the time left in ms until this event will trigger.")
|
||||
{
|
||||
return Sim::getEventTimeLeft(dAtoi(argv[1]));
|
||||
return Sim::getEventTimeLeft(scheduleId);
|
||||
}
|
||||
|
||||
ConsoleFunction(getScheduleDuration, S32, 2, 2, "getScheduleDuration(%scheduleId);")
|
||||
DefineConsoleFunction( getScheduleDuration, S32, (S32 scheduleId), ,"getScheduleDuration(%scheduleId);" )
|
||||
{
|
||||
TORQUE_UNUSED(argc); S32 ret = Sim::getScheduleDuration(dAtoi(argv[1]));
|
||||
S32 ret = Sim::getScheduleDuration(scheduleId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ConsoleFunction(getTimeSinceStart, S32, 2, 2, "getTimeSinceStart(%scheduleId);")
|
||||
DefineConsoleFunction( getTimeSinceStart, S32, (S32 scheduleId), ,"getTimeSinceStart(%scheduleId);" )
|
||||
{
|
||||
TORQUE_UNUSED(argc); S32 ret = Sim::getTimeSinceStart(dAtoi(argv[1]));
|
||||
S32 ret = Sim::getTimeSinceStart(scheduleId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +202,7 @@ ConsoleFunction(schedule, S32, 4, 0, "schedule(time, refobject|0, command, <arg1
|
|||
return ret;
|
||||
}
|
||||
|
||||
ConsoleFunction(getUniqueName, const char*, 2, 2,
|
||||
DefineConsoleFunction( getUniqueName, const char*, (const char * baseName), ,
|
||||
"( String baseName )\n"
|
||||
"@brief Returns a unique unused SimObject name based on a given base name.\n\n"
|
||||
"@baseName Name to conver to a unique string if another instance exists\n"
|
||||
|
|
@ -222,7 +210,7 @@ ConsoleFunction(getUniqueName, const char*, 2, 2,
|
|||
"@ingroup Editors\n"
|
||||
"@internal")
|
||||
{
|
||||
String outName = Sim::getUniqueName( argv[1] );
|
||||
String outName = Sim::getUniqueName( baseName );
|
||||
|
||||
if ( outName.isEmpty() )
|
||||
return NULL;
|
||||
|
|
@ -233,7 +221,7 @@ ConsoleFunction(getUniqueName, const char*, 2, 2,
|
|||
return buffer;
|
||||
}
|
||||
|
||||
ConsoleFunction(getUniqueInternalName, const char*, 4, 4,
|
||||
DefineConsoleFunction( getUniqueInternalName, const char*, (const char * baseName, const char * setString, bool searchChildren), ,
|
||||
"( String baseName, SimSet set, bool searchChildren )\n"
|
||||
"@brief Returns a unique unused internal name within the SimSet/Group based on a given base name.\n\n"
|
||||
"@note Currently only used by editors\n"
|
||||
|
|
@ -241,13 +229,13 @@ ConsoleFunction(getUniqueInternalName, const char*, 4, 4,
|
|||
"@internal")
|
||||
{
|
||||
SimSet *set;
|
||||
if ( !Sim::findObject( argv[2], set ) )
|
||||
if ( !Sim::findObject( setString, set ) )
|
||||
{
|
||||
Con::errorf( "getUniqueInternalName() - invalid parameter for SimSet." );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
String outName = Sim::getUniqueInternalName( argv[1], set, dAtob(argv[3]) );
|
||||
String outName = Sim::getUniqueInternalName( baseName, set, searchChildren );
|
||||
|
||||
if ( outName.isEmpty() )
|
||||
return NULL;
|
||||
|
|
@ -258,13 +246,12 @@ ConsoleFunction(getUniqueInternalName, const char*, 4, 4,
|
|||
return buffer;
|
||||
}
|
||||
|
||||
ConsoleFunction( isValidObjectName, bool, 2, 2, "( string name )"
|
||||
DefineConsoleFunction( isValidObjectName, bool, (const char * name), , "( string name )"
|
||||
"@brief Return true if the given name makes for a valid object name.\n\n"
|
||||
"@param name Name of object\n"
|
||||
"@return True if name is allowed, false if denied (usually because it starts with a number, _, or invalid character"
|
||||
"@ingroup Console")
|
||||
{
|
||||
const char* name = argv[ 1 ];
|
||||
return Sim::isValidObjectName( name );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,19 +29,23 @@ extern U32 HashPointer(StringTableEntry e);
|
|||
|
||||
SimNameDictionary::SimNameDictionary()
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
hashTable = NULL;
|
||||
#endif
|
||||
mutex = Mutex::createMutex();
|
||||
}
|
||||
|
||||
SimNameDictionary::~SimNameDictionary()
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
delete[] hashTable;
|
||||
#endif
|
||||
Mutex::destroyMutex(mutex);
|
||||
}
|
||||
|
||||
void SimNameDictionary::insert(SimObject* obj)
|
||||
{
|
||||
if(!obj->objectName)
|
||||
if(!obj || !obj->objectName)
|
||||
return;
|
||||
|
||||
SimObject* checkForDup = find(obj->objectName);
|
||||
|
|
@ -50,7 +54,7 @@ void SimNameDictionary::insert(SimObject* obj)
|
|||
Con::warnf("Warning! You have a duplicate datablock name of %s. This can cause problems. You should rename one of them.", obj->objectName);
|
||||
|
||||
Mutex::lockMutex(mutex);
|
||||
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
if(!hashTable)
|
||||
{
|
||||
hashTable = new SimObject *[DefaultTableSize];
|
||||
|
|
@ -95,12 +99,15 @@ void SimNameDictionary::insert(SimObject* obj)
|
|||
hashTable = newHashTable;
|
||||
hashTableSize = newHashTableSize;
|
||||
}
|
||||
|
||||
#else
|
||||
root[obj->objectName] = obj;
|
||||
#endif
|
||||
Mutex::unlockMutex(mutex);
|
||||
}
|
||||
|
||||
SimObject* SimNameDictionary::find(StringTableEntry name)
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
// NULL is a valid lookup - it will always return NULL
|
||||
if(!hashTable)
|
||||
return NULL;
|
||||
|
|
@ -121,15 +128,22 @@ SimObject* SimNameDictionary::find(StringTableEntry name)
|
|||
|
||||
Mutex::unlockMutex(mutex);
|
||||
return NULL;
|
||||
#else
|
||||
Mutex::lockMutex(mutex);
|
||||
StringDictDef::iterator it = root.find(name);
|
||||
SimObject* f = (it == root.end() ? NULL : it->second);
|
||||
Mutex::unlockMutex(mutex);
|
||||
return f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimNameDictionary::remove(SimObject* obj)
|
||||
{
|
||||
if(!obj->objectName)
|
||||
if(!obj || !obj->objectName)
|
||||
return;
|
||||
|
||||
Mutex::lockMutex(mutex);
|
||||
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
SimObject **walk = &hashTable[HashPointer(obj->objectName) % hashTableSize];
|
||||
while(*walk)
|
||||
{
|
||||
|
|
@ -144,7 +158,11 @@ void SimNameDictionary::remove(SimObject* obj)
|
|||
}
|
||||
walk = &((*walk)->nextNameObject);
|
||||
}
|
||||
|
||||
#else
|
||||
const char* name = obj->objectName;
|
||||
if (root.find(name) != root.end())
|
||||
root.erase(name);
|
||||
#endif
|
||||
Mutex::unlockMutex(mutex);
|
||||
}
|
||||
|
||||
|
|
@ -152,28 +170,31 @@ void SimNameDictionary::remove(SimObject* obj)
|
|||
|
||||
SimManagerNameDictionary::SimManagerNameDictionary()
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
hashTable = new SimObject *[DefaultTableSize];
|
||||
hashTableSize = DefaultTableSize;
|
||||
hashEntryCount = 0;
|
||||
|
||||
dMemset( hashTable, 0, sizeof( hashTable[ 0 ] ) * hashTableSize );
|
||||
|
||||
#endif
|
||||
mutex = Mutex::createMutex();
|
||||
}
|
||||
|
||||
SimManagerNameDictionary::~SimManagerNameDictionary()
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
delete[] hashTable;
|
||||
#endif
|
||||
Mutex::destroyMutex(mutex);
|
||||
}
|
||||
|
||||
void SimManagerNameDictionary::insert(SimObject* obj)
|
||||
{
|
||||
if(!obj->objectName)
|
||||
if(!obj || !obj->objectName)
|
||||
return;
|
||||
|
||||
Mutex::lockMutex(mutex);
|
||||
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
S32 idx = HashPointer(obj->objectName) % hashTableSize;
|
||||
obj->nextManagerNameObject = hashTable[idx];
|
||||
hashTable[idx] = obj;
|
||||
|
|
@ -209,7 +230,9 @@ void SimManagerNameDictionary::insert(SimObject* obj)
|
|||
hashTable = newHashTable;
|
||||
hashTableSize = newHashTableSize;
|
||||
}
|
||||
|
||||
#else
|
||||
root[obj->objectName] = obj;
|
||||
#endif
|
||||
Mutex::unlockMutex(mutex);
|
||||
}
|
||||
|
||||
|
|
@ -219,6 +242,7 @@ SimObject* SimManagerNameDictionary::find(StringTableEntry name)
|
|||
|
||||
Mutex::lockMutex(mutex);
|
||||
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
S32 idx = HashPointer(name) % hashTableSize;
|
||||
SimObject *walk = hashTable[idx];
|
||||
while(walk)
|
||||
|
|
@ -230,16 +254,23 @@ SimObject* SimManagerNameDictionary::find(StringTableEntry name)
|
|||
}
|
||||
walk = walk->nextManagerNameObject;
|
||||
}
|
||||
|
||||
Mutex::unlockMutex(mutex);
|
||||
|
||||
return NULL;
|
||||
#else
|
||||
StringDictDef::iterator it = root.find(name);
|
||||
SimObject* f = (it == root.end() ? NULL : it->second);
|
||||
Mutex::unlockMutex(mutex);
|
||||
return f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimManagerNameDictionary::remove(SimObject* obj)
|
||||
{
|
||||
if(!obj->objectName)
|
||||
if(!obj || !obj->objectName)
|
||||
return;
|
||||
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
Mutex::lockMutex(mutex);
|
||||
|
||||
SimObject **walk = &hashTable[HashPointer(obj->objectName) % hashTableSize];
|
||||
|
|
@ -256,7 +287,11 @@ void SimManagerNameDictionary::remove(SimObject* obj)
|
|||
}
|
||||
walk = &((*walk)->nextManagerNameObject);
|
||||
}
|
||||
|
||||
#else
|
||||
StringTableEntry name = obj->objectName;
|
||||
if (root.find(name) != root.end())
|
||||
root.erase(name);
|
||||
#endif
|
||||
Mutex::unlockMutex(mutex);
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +300,9 @@ void SimManagerNameDictionary::remove(SimObject* obj)
|
|||
|
||||
SimIdDictionary::SimIdDictionary()
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
dMemset( table, 0, sizeof( table[ 0 ] ) * DefaultTableSize );
|
||||
#endif
|
||||
mutex = Mutex::createMutex();
|
||||
}
|
||||
|
||||
|
|
@ -274,22 +311,29 @@ SimIdDictionary::~SimIdDictionary()
|
|||
Mutex::destroyMutex(mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SimIdDictionary::insert(SimObject* obj)
|
||||
{
|
||||
Mutex::lockMutex(mutex);
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
Mutex::lockMutex(mutex);
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
S32 idx = obj->getId() & TableBitMask;
|
||||
obj->nextIdObject = table[idx];
|
||||
AssertFatal( obj->nextIdObject != obj, "SimIdDictionary::insert - Creating Infinite Loop linking to self!" );
|
||||
table[idx] = obj;
|
||||
|
||||
#else
|
||||
root[obj->getId()] = obj;
|
||||
#endif
|
||||
Mutex::unlockMutex(mutex);
|
||||
}
|
||||
|
||||
SimObject* SimIdDictionary::find(S32 id)
|
||||
{
|
||||
Mutex::lockMutex(mutex);
|
||||
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
S32 idx = id & TableBitMask;
|
||||
SimObject *walk = table[idx];
|
||||
while(walk)
|
||||
|
|
@ -301,22 +345,32 @@ SimObject* SimIdDictionary::find(S32 id)
|
|||
}
|
||||
walk = walk->nextIdObject;
|
||||
}
|
||||
|
||||
Mutex::unlockMutex(mutex);
|
||||
|
||||
return NULL;
|
||||
#else
|
||||
SimObjectIdDictDef::iterator it = root.find(id);
|
||||
SimObject* f = (it == root.end() ? NULL : it->second);
|
||||
Mutex::unlockMutex(mutex);
|
||||
return f;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimIdDictionary::remove(SimObject* obj)
|
||||
{
|
||||
Mutex::lockMutex(mutex);
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
Mutex::lockMutex(mutex);
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
SimObject **walk = &table[obj->getId() & TableBitMask];
|
||||
while(*walk && *walk != obj)
|
||||
walk = &((*walk)->nextIdObject);
|
||||
if(*walk)
|
||||
*walk = obj->nextIdObject;
|
||||
|
||||
#else
|
||||
root.erase(obj->getId());
|
||||
#endif
|
||||
Mutex::unlockMutex(mutex);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,38 @@
|
|||
#include "platform/threads/mutex.h"
|
||||
#endif
|
||||
|
||||
#include "torqueConfig.h"
|
||||
|
||||
class SimObject;
|
||||
|
||||
#ifdef USE_NEW_SIMDICTIONARY
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#ifndef _SIM_H_
|
||||
#include "console/sim.h"
|
||||
#endif
|
||||
|
||||
struct StringTableEntryHash
|
||||
{
|
||||
inline size_t operator()(StringTableEntry val) const
|
||||
{
|
||||
return (size_t)val;
|
||||
}
|
||||
};
|
||||
|
||||
struct StringTableEntryEq
|
||||
{
|
||||
inline bool operator()(StringTableEntry s1, StringTableEntry s2) const
|
||||
{
|
||||
return s1 == s2;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::unordered_map<StringTableEntry, SimObject*, StringTableEntryHash, StringTableEntryEq> StringDictDef;
|
||||
typedef std::unordered_map<SimObjectId, SimObject*> SimObjectIdDictDef;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// Map of names to SimObjects
|
||||
///
|
||||
|
|
@ -42,6 +72,7 @@ class SimObject;
|
|||
/// for fast removal of an object given object*
|
||||
class SimNameDictionary
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
enum
|
||||
{
|
||||
DefaultTableSize = 29
|
||||
|
|
@ -50,6 +81,9 @@ class SimNameDictionary
|
|||
SimObject **hashTable; // hash the pointers of the names...
|
||||
S32 hashTableSize;
|
||||
S32 hashEntryCount;
|
||||
#else
|
||||
StringDictDef root;
|
||||
#endif
|
||||
|
||||
void *mutex;
|
||||
|
||||
|
|
@ -64,6 +98,7 @@ public:
|
|||
|
||||
class SimManagerNameDictionary
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
enum
|
||||
{
|
||||
DefaultTableSize = 29
|
||||
|
|
@ -72,6 +107,9 @@ class SimManagerNameDictionary
|
|||
SimObject **hashTable; // hash the pointers of the names...
|
||||
S32 hashTableSize;
|
||||
S32 hashEntryCount;
|
||||
#else
|
||||
StringDictDef root;
|
||||
#endif
|
||||
|
||||
void *mutex;
|
||||
|
||||
|
|
@ -91,12 +129,16 @@ public:
|
|||
/// for fast removal of an object given object*
|
||||
class SimIdDictionary
|
||||
{
|
||||
#ifndef USE_NEW_SIMDICTIONARY
|
||||
enum
|
||||
{
|
||||
DefaultTableSize = 4096,
|
||||
TableBitMask = 4095
|
||||
};
|
||||
SimObject *table[DefaultTableSize];
|
||||
#else
|
||||
SimObjectIdDictDef root;
|
||||
#endif
|
||||
|
||||
void *mutex;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "console/simPersistSet.h"
|
||||
#include "console/simPersistID.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
|
||||
IMPLEMENT_CONOBJECT( SimPersistSet );
|
||||
|
|
@ -186,7 +187,7 @@ void SimPersistSet::addObject( SimObject* object )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( SimPersistSet, resolvePersistentIds, void, 2, 2, "() - Try to bind unresolved persistent IDs in the set." )
|
||||
DefineConsoleMethod( SimPersistSet, resolvePersistentIds, void, (), , "() - Try to bind unresolved persistent IDs in the set." )
|
||||
{
|
||||
object->resolvePIDs();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "core/stringTable.h"
|
||||
#include "console/console.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
#include "sim/actionMap.h"
|
||||
#include "core/fileObject.h"
|
||||
|
|
@ -950,7 +951,7 @@ DefineEngineMethod( SimSet, clear, void, (),,
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
//UNSAFE; don't want this in the new API
|
||||
ConsoleMethod( SimSet, deleteAllObjects, void, 2, 2, "() Delete all objects in the set." )
|
||||
DefineConsoleMethod( SimSet, deleteAllObjects, void, (), , "() Delete all objects in the set." )
|
||||
{
|
||||
object->deleteAllObjects();
|
||||
}
|
||||
|
|
@ -1022,7 +1023,7 @@ DEFINE_CALLIN( fnSimSet_getCountRecursive, getCountRecursive, SimSet, U32, ( Sim
|
|||
return set->sizeRecursive();
|
||||
}
|
||||
|
||||
ConsoleMethod( SimSet, getFullCount, S32, 2, 2, "() Get the number of direct and indirect child objects contained in the set.\n"
|
||||
DefineConsoleMethod( SimSet, getFullCount, S32, (), , "() Get the number of direct and indirect child objects contained in the set.\n"
|
||||
"@return The number of objects contained in the set as well as in other sets contained directly or indirectly in the set." )
|
||||
{
|
||||
return object->sizeRecursive();
|
||||
|
|
@ -1118,10 +1119,10 @@ DefineEngineMethod( SimSet, pushToBack, void, ( SimObject* obj ),,
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleMethod( SimSet, sort, void, 3, 3, "( string callbackFunction ) Sort the objects in the set using the given comparison function.\n"
|
||||
DefineConsoleMethod( SimSet, sort, void, ( const char * callbackFunction ), , "( string callbackFunction ) Sort the objects in the set using the given comparison function.\n"
|
||||
"@param callbackFunction Name of a function that takes two object arguments A and B and returns -1 if A is less, 1 if B is less, and 0 if both are equal." )
|
||||
{
|
||||
object->scriptSort( (const char*)argv[2] );
|
||||
object->scriptSort( callbackFunction );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ ConsoleValue* ConsoleValueStack::pop()
|
|||
|
||||
void ConsoleValueStack::pushFrame()
|
||||
{
|
||||
//Con::printf("CSTK pushFrame");
|
||||
//Con::printf("CSTK pushFrame[%i] (%i)", mFrame, mStackPos);
|
||||
mStackFrames[mFrame++] = mStackPos;
|
||||
}
|
||||
|
||||
|
|
@ -181,6 +181,12 @@ void ConsoleValueStack::resetFrame()
|
|||
//Con::printf("CSTK resetFrame to %i", mStackPos);
|
||||
}
|
||||
|
||||
void ConsoleValueStack::clearFrames()
|
||||
{
|
||||
mStackPos = 0;
|
||||
mFrame = 0;
|
||||
}
|
||||
|
||||
void ConsoleValueStack::popFrame()
|
||||
{
|
||||
//Con::printf("CSTK popFrame");
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ struct StringStack
|
|||
mBuffer = (char *) dRealloc(mBuffer, mBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
void validateArgBufferSize(U32 size)
|
||||
{
|
||||
if(size > mArgBufferSize)
|
||||
|
|
@ -82,6 +83,7 @@ struct StringStack
|
|||
mArgBuffer = (char *) dRealloc(mArgBuffer, mArgBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
StringStack()
|
||||
{
|
||||
mBufferSize = 0;
|
||||
|
|
@ -95,6 +97,8 @@ struct StringStack
|
|||
mFunctionOffset = 0;
|
||||
validateBufferSize(8192);
|
||||
validateArgBufferSize(2048);
|
||||
dMemset(mBuffer, '\0', mBufferSize);
|
||||
dMemset(mArgBuffer, '\0', mArgBufferSize);
|
||||
}
|
||||
~StringStack()
|
||||
{
|
||||
|
|
@ -141,6 +145,7 @@ struct StringStack
|
|||
/// Clear the function offset.
|
||||
void clearFunctionOffset()
|
||||
{
|
||||
//Con::printf("StringStack mFunctionOffset = 0 (from %i)", mFunctionOffset);
|
||||
mFunctionOffset = 0;
|
||||
}
|
||||
|
||||
|
|
@ -262,9 +267,9 @@ struct StringStack
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void pushFrame()
|
||||
{
|
||||
//Con::printf("StringStack pushFrame [frame=%i, start=%i]", mNumFrames, mStartStackSize);
|
||||
mFrameOffsets[mNumFrames++] = mStartStackSize;
|
||||
mStartOffsets[mStartStackSize++] = mStart;
|
||||
mStart += ReturnBufferSpace;
|
||||
|
|
@ -273,11 +278,22 @@ struct StringStack
|
|||
|
||||
void popFrame()
|
||||
{
|
||||
//Con::printf("StringStack popFrame [frame=%i, start=%i]", mNumFrames, mStartStackSize);
|
||||
mStartStackSize = mFrameOffsets[--mNumFrames];
|
||||
mStart = mStartOffsets[mStartStackSize];
|
||||
mLen = 0;
|
||||
}
|
||||
|
||||
void clearFrames()
|
||||
{
|
||||
//Con::printf("StringStack clearFrames");
|
||||
mNumFrames = 0;
|
||||
mStart = 0;
|
||||
mLen = 0;
|
||||
mStartStackSize = 0;
|
||||
mFunctionOffset = 0;
|
||||
}
|
||||
|
||||
/// Get the arguments for a function call from the stack.
|
||||
void getArgcArgv(StringTableEntry name, U32 *argc, const char ***in_argv, bool popStackFrame = false);
|
||||
};
|
||||
|
|
@ -309,6 +325,7 @@ public:
|
|||
void popFrame();
|
||||
|
||||
void resetFrame();
|
||||
void clearFrames();
|
||||
|
||||
void getArgcArgv(StringTableEntry name, U32 *argc, ConsoleValueRef **in_argv, bool popStackFrame = false);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "core/frameAllocator.h"
|
||||
#include "console/console.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "core/stringTable.h"
|
||||
#include "console/consoleInternal.h"
|
||||
#include "console/ast.h"
|
||||
|
|
@ -112,24 +113,25 @@ MODULE_END;
|
|||
// BRKCLR file line - sent when a breakpoint cannot be moved to a breakable line on the client.
|
||||
//
|
||||
|
||||
|
||||
ConsoleFunction( dbgSetParameters, void, 3, 4, "(int port, string password, bool waitForClient)"
|
||||
DefineConsoleFunction( dbgSetParameters, void, (S32 port, const char * password, bool waitForClient ), (false), "( int port, string password, bool waitForClient )"
|
||||
"Open a debug server port on the specified port, requiring the specified password, "
|
||||
"and optionally waiting for the debug client to connect.\n"
|
||||
"@internal Primarily used for Torsion and other debugging tools")
|
||||
{
|
||||
if (TelDebugger)
|
||||
TelDebugger->setDebugParameters(dAtoi(argv[1]), argv[2], argc > 3 ? dAtob(argv[3]) : false );
|
||||
{
|
||||
TelDebugger->setDebugParameters(port, password, waitForClient );
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleFunction( dbgIsConnected, bool, 1, 1, "()"
|
||||
DefineConsoleFunction( dbgIsConnected, bool, (), , "()"
|
||||
"Returns true if a script debugging client is connected else return false.\n"
|
||||
"@internal Primarily used for Torsion and other debugging tools")
|
||||
{
|
||||
return TelDebugger && TelDebugger->isConnected();
|
||||
}
|
||||
|
||||
ConsoleFunction( dbgDisconnect, void, 1, 1, "()"
|
||||
DefineConsoleFunction( dbgDisconnect, void, (), , "()"
|
||||
"Forcibly disconnects any attached script debugging client.\n"
|
||||
"@internal Primarily used for Torsion and other debugging tools")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "core/strings/stringFunctions.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
|
||||
bool gLogToConsole = false;
|
||||
|
|
@ -49,14 +50,13 @@ static const char *packetTypeNames[] =
|
|||
//-----------------------------------------------------------------
|
||||
//-----------------------------------------------------------------
|
||||
//-----------------------------------------------------------------
|
||||
ConsoleFunction(DNetSetLogging, void, 2, 2, "(bool enabled)"
|
||||
DefineConsoleFunction( DNetSetLogging, void, (bool enabled), , "(bool enabled)"
|
||||
"@brief Enables logging of the connection protocols\n\n"
|
||||
"When enabled a lot of network debugging information is sent to the console.\n"
|
||||
"@param enabled True to enable, false to disable\n"
|
||||
"@ingroup Networking")
|
||||
{
|
||||
TORQUE_UNUSED(argc);
|
||||
gLogToConsole = dAtob(argv[1]);
|
||||
gLogToConsole = enabled;
|
||||
}
|
||||
|
||||
ConnectionProtocol::ConnectionProtocol()
|
||||
|
|
|
|||
|
|
@ -484,19 +484,17 @@ static ConsoleDocFragment _FileObjectwriteObject2(
|
|||
"FileObject",
|
||||
"void writeObject( SimObject* object, string prepend);");
|
||||
|
||||
ConsoleMethod( FileObject, writeObject, void, 3, 4, "FileObject.writeObject(SimObject, object prepend)"
|
||||
DefineConsoleMethod( FileObject, writeObject, void, (const char * simName, const char * objName), (""), "FileObject.writeObject(SimObject, object prepend)"
|
||||
"@hide")
|
||||
{
|
||||
SimObject* obj = Sim::findObject( argv[2] );
|
||||
SimObject* obj = Sim::findObject( simName );
|
||||
if( !obj )
|
||||
{
|
||||
Con::printf("FileObject::writeObject - Invalid Object!");
|
||||
return;
|
||||
}
|
||||
|
||||
const char *objName = NULL;
|
||||
if( argc == 4 )
|
||||
objName = (const char*)argv[3];
|
||||
if (!dStrcmp(objName,""))
|
||||
objName = NULL;
|
||||
|
||||
object->writeObject( obj, (const U8*)objName );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ U32 OggVorbisDecoder::read( RawData** buffer, U32 num )
|
|||
S32 val = S32( pcmData[ c ][ n ] * 32767.f );
|
||||
if( val > 32767 )
|
||||
val = 32767;
|
||||
else if( val < -34768 )
|
||||
else if( val < -32768 )
|
||||
val = -32768;
|
||||
|
||||
*samplePtr = val;
|
||||
|
|
|
|||
|
|
@ -221,16 +221,18 @@ ResourceBase ResourceManager::nextResource()
|
|||
|
||||
ConsoleFunctionGroupBegin(ResourceManagerFunctions, "Resource management functions.");
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
|
||||
ConsoleFunction(resourceDump, void, 1, 1, "()"
|
||||
"@brief List the currently managed resources\n\n"
|
||||
"Currently used by editors only, internal\n"
|
||||
"@ingroup Editors\n"
|
||||
"@internal")
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
ResourceManager::get().dumpToConsole();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
DefineEngineFunction( reloadResource, void, ( const char* path ),,
|
||||
"Force the resource at specified input path to be reloaded\n"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "core/frameAllocator.h"
|
||||
#include "core/strings/unicode.h"
|
||||
#include "core/strings/stringFunctions.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
|
||||
#if defined(TORQUE_DEBUG)
|
||||
|
|
@ -47,12 +48,12 @@
|
|||
void dumpAllStrings();
|
||||
};
|
||||
|
||||
ConsoleFunction(sbmDumpStats, void, 1, 1, "")
|
||||
DefineConsoleFunction( sbmDumpStats, void, (), , "()")
|
||||
{
|
||||
StringBufferManager::getManager().dumpStats();
|
||||
}
|
||||
|
||||
ConsoleFunction(sbmDumpStrings, void, 1, 1, "")
|
||||
DefineConsoleFunction( sbmDumpStrings, void, (), , "()")
|
||||
{
|
||||
StringBufferManager::getManager().dumpAllStrings();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ inline S32 dStrcmp(const char *str1, const char *str2)
|
|||
return strcmp(str1, str2);
|
||||
}
|
||||
|
||||
inline bool dStrIsEmpty(const char *src)
|
||||
{
|
||||
return src == 0 || src[0] == '\0';
|
||||
}
|
||||
|
||||
inline S32 dStrncmp(const char *str1, const char *str2, dsize_t len)
|
||||
{
|
||||
return strncmp(str1, str2, len);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ namespace KeyCmp
|
|||
#include "core/util/tVector.h"
|
||||
#include "core/dataChunker.h"
|
||||
#include "console/console.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#include "math/mMathFn.h"
|
||||
|
||||
|
|
@ -476,15 +477,18 @@ static U32 sgStringMemBytes;
|
|||
/// Tracks the number of Strings which are currently instantiated.
|
||||
static U32 sgStringInstances;
|
||||
|
||||
ConsoleFunction( dumpStringMemStats, void, 1, 1, "()"
|
||||
|
||||
|
||||
#endif
|
||||
DefineConsoleFunction( dumpStringMemStats, void, (), , "()"
|
||||
"@brief Dumps information about String memory usage\n\n"
|
||||
"@ingroup Debugging\n"
|
||||
"@ingroup Strings\n")
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::printf( "String Data: %i instances, %i bytes", sgStringInstances, sgStringMemBytes );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ bool BasicClouds::onAdd()
|
|||
mTexScaleSC = mShader->getShaderConstHandle( "$texScale" );
|
||||
mTexDirectionSC = mShader->getShaderConstHandle( "$texDirection" );
|
||||
mTexOffsetSC = mShader->getShaderConstHandle( "$texOffset" );
|
||||
mDiffuseMapSC = mShader->getShaderConstHandle( "$diffuseMap" );
|
||||
|
||||
// Create StateBlocks
|
||||
GFXStateBlockDesc desc;
|
||||
|
|
@ -312,7 +313,7 @@ void BasicClouds::renderObject( ObjectRenderInst *ri, SceneRenderState *state, B
|
|||
mShaderConsts->setSafe( mTexDirectionSC, mTexDirection[i] * mTexSpeed[i] );
|
||||
mShaderConsts->setSafe( mTexOffsetSC, mTexOffset[i] );
|
||||
|
||||
GFX->setTexture( 0, mTexture[i] );
|
||||
GFX->setTexture( mDiffuseMapSC->getSamplerRegister(), mTexture[i] );
|
||||
GFX->setVertexBuffer( mVB[i] );
|
||||
|
||||
GFX->drawIndexedPrimitive( GFXTriangleList, 0, 0, smVertCount, 0, smTriangleCount );
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ protected:
|
|||
GFXShaderConstHandle *mTexScaleSC;
|
||||
GFXShaderConstHandle *mTexDirectionSC;
|
||||
GFXShaderConstHandle *mTexOffsetSC;
|
||||
GFXShaderConstHandle *mDiffuseMapSC;
|
||||
|
||||
GFXVertexBufferHandle<GFXVertexPT> mVB[TEX_COUNT];
|
||||
GFXPrimitiveBufferHandle mPB;
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ bool CloudLayer::onAdd()
|
|||
mCoverageSC = mShader->getShaderConstHandle( "$cloudCoverage" );
|
||||
mExposureSC = mShader->getShaderConstHandle( "$cloudExposure" );
|
||||
mBaseColorSC = mShader->getShaderConstHandle( "$cloudBaseColor" );
|
||||
mNormalHeightMapSC = mShader->getShaderConstHandle( "$normalHeightMap" );
|
||||
|
||||
// Create StateBlocks
|
||||
GFXStateBlockDesc desc;
|
||||
|
|
@ -365,7 +366,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
|
|||
|
||||
mShaderConsts->setSafe( mExposureSC, mExposure );
|
||||
|
||||
GFX->setTexture( 0, mTexture );
|
||||
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), mTexture );
|
||||
GFX->setVertexBuffer( mVB );
|
||||
GFX->setPrimitiveBuffer( mPB );
|
||||
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ protected:
|
|||
GFXShaderConstHandle *mCoverageSC;
|
||||
GFXShaderConstHandle *mExposureSC;
|
||||
GFXShaderConstHandle *mEyePosWorldSC;
|
||||
GFXShaderConstHandle *mNormalHeightMapSC;
|
||||
|
||||
GFXVertexBufferHandle<GFXCloudVertex> mVB;
|
||||
GFXPrimitiveBufferHandle mPB;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "environment/editors/guiMeshRoadEditorCtrl.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "environment/meshRoad.h"
|
||||
#include "renderInstance/renderPassManager.h"
|
||||
#include "collision/collision.h"
|
||||
|
|
@ -1185,125 +1186,95 @@ void GuiMeshRoadEditorCtrl::matchTerrainToRoad()
|
|||
// with the terrain underneath it.
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, deleteNode, void, 2, 2, "deleteNode()" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, deleteNode, void, (), , "deleteNode()" )
|
||||
{
|
||||
object->deleteSelectedNode();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, getMode, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, getMode, const char*, (), , "" )
|
||||
{
|
||||
return object->getMode();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, setMode, void, 3, 3, "setMode( String mode )" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setMode, void, (const char * mode), , "setMode( String mode )" )
|
||||
{
|
||||
String newMode = ( argv[2] );
|
||||
String newMode = ( mode );
|
||||
object->setMode( newMode );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, getNodeWidth, F32, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeWidth, F32, (), , "" )
|
||||
{
|
||||
return object->getNodeWidth();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, setNodeWidth, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
|
||||
{
|
||||
object->setNodeWidth( dAtof(argv[2]) );
|
||||
object->setNodeWidth( width );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, getNodeDepth, F32, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeDepth, F32, (), , "" )
|
||||
{
|
||||
return object->getNodeDepth();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, setNodeDepth, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeDepth, void, ( F32 depth ), , "" )
|
||||
{
|
||||
object->setNodeDepth( dAtof(argv[2]) );
|
||||
object->setNodeDepth( depth );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, getNodePosition, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodePosition, Point3F, (), , "" )
|
||||
{
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
|
||||
dSprintf(returnBuffer, bufSize, "%f %f %f",
|
||||
object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z);
|
||||
|
||||
return returnBuffer;
|
||||
return object->getNodePosition();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, setNodePosition, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodePosition, void, (Point3F pos), , "" )
|
||||
{
|
||||
Point3F pos;
|
||||
|
||||
S32 count = dSscanf( argv[2], "%f %f %f",
|
||||
&pos.x, &pos.y, &pos.z);
|
||||
|
||||
if ( (count != 3) )
|
||||
{
|
||||
Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
object->setNodePosition( pos );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, getNodeNormal, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, getNodeNormal, Point3F, (), , "" )
|
||||
{
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
|
||||
dSprintf(returnBuffer, bufSize, "%f %f %f",
|
||||
object->getNodeNormal().x, object->getNodeNormal().y, object->getNodeNormal().z);
|
||||
|
||||
return returnBuffer;
|
||||
return object->getNodeNormal();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setNodeNormal, void, (Point3F normal), , "" )
|
||||
{
|
||||
VectorF normal;
|
||||
|
||||
S32 count = dSscanf( argv[2], "%f %f %f",
|
||||
&normal.x, &normal.y, &normal.z);
|
||||
|
||||
if ( (count != 3) )
|
||||
{
|
||||
Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
object->setNodeNormal( normal );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, 2, 3, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, setSelectedRoad, void, (const char * objName), (""), "" )
|
||||
{
|
||||
if ( argc == 2 )
|
||||
if ( dStrIsEmpty(objName) )
|
||||
object->setSelectedRoad(NULL);
|
||||
else
|
||||
{
|
||||
MeshRoad *road = NULL;
|
||||
if ( Sim::findObject( argv[2], road ) )
|
||||
if ( Sim::findObject( objName, road ) )
|
||||
object->setSelectedRoad(road);
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, getSelectedRoad, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, getSelectedRoad, S32, (), , "" )
|
||||
{
|
||||
MeshRoad *road = object->getSelectedRoad();
|
||||
if ( !road )
|
||||
return NULL;
|
||||
|
||||
return road->getIdString();
|
||||
return road->getId();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, regenerate, void, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, regenerate, void, (), , "" )
|
||||
{
|
||||
MeshRoad *road = object->getSelectedRoad();
|
||||
if ( road )
|
||||
road->regenerate();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiMeshRoadEditorCtrl, matchTerrainToRoad, void, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiMeshRoadEditorCtrl, matchTerrainToRoad, void, (), , "" )
|
||||
{
|
||||
object->matchTerrainToRoad();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "environment/editors/guiRiverEditorCtrl.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "environment/river.h"
|
||||
#include "renderInstance/renderPassManager.h"
|
||||
#include "collision/collision.h"
|
||||
|
|
@ -1392,118 +1393,87 @@ void GuiRiverEditorCtrl::_renderSelectedRiver( ObjectRenderInst *ri, SceneRender
|
|||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, deleteNode, void, 2, 2, "deleteNode()" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, deleteNode, void, (), , "deleteNode()" )
|
||||
{
|
||||
object->deleteSelectedNode();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, getMode, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, getMode, const char*, (), , "" )
|
||||
{
|
||||
return object->getMode();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, setMode, void, 3, 3, "setMode( String mode )" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, setMode, void, ( const char * mode ), , "setMode( String mode )" )
|
||||
{
|
||||
String newMode = ( argv[2] );
|
||||
String newMode = ( mode );
|
||||
object->setMode( newMode );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, getNodeWidth, F32, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, getNodeWidth, F32, (), , "" )
|
||||
{
|
||||
return object->getNodeWidth();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, setNodeWidth, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
|
||||
{
|
||||
object->setNodeWidth( dAtof(argv[2]) );
|
||||
object->setNodeWidth( width );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, getNodeDepth, F32, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, getNodeDepth, F32, (), , "" )
|
||||
{
|
||||
return object->getNodeDepth();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, setNodeDepth, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, setNodeDepth, void, ( F32 depth ), , "" )
|
||||
{
|
||||
object->setNodeDepth( dAtof(argv[2]) );
|
||||
object->setNodeDepth( depth );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, getNodePosition, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, getNodePosition, Point3F, (), , "" )
|
||||
{
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
|
||||
dSprintf(returnBuffer, bufSize, "%f %f %f",
|
||||
object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z);
|
||||
|
||||
return returnBuffer;
|
||||
return object->getNodePosition();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, setNodePosition, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, setNodePosition, void, (Point3F pos), , "" )
|
||||
{
|
||||
Point3F pos;
|
||||
|
||||
S32 count = dSscanf( argv[2], "%f %f %f",
|
||||
&pos.x, &pos.y, &pos.z);
|
||||
|
||||
if ( (count != 3) )
|
||||
{
|
||||
Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
object->setNodePosition( pos );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, getNodeNormal, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, getNodeNormal, Point3F, (), , "" )
|
||||
{
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
|
||||
dSprintf(returnBuffer, bufSize, "%f %f %f",
|
||||
object->getNodeNormal().x, object->getNodeNormal().y, object->getNodeNormal().z);
|
||||
|
||||
return returnBuffer;
|
||||
return object->getNodeNormal();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, setNodeNormal, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, setNodeNormal, void, (Point3F normal), , "" )
|
||||
{
|
||||
VectorF normal;
|
||||
|
||||
S32 count = dSscanf( argv[2], "%f %f %f",
|
||||
&normal.x, &normal.y, &normal.z);
|
||||
|
||||
if ( (count != 3) )
|
||||
{
|
||||
Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
object->setNodeNormal( normal );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, setSelectedRiver, void, 2, 3, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, setSelectedRiver, void, (const char * objName), (""), "" )
|
||||
{
|
||||
if ( argc == 2 )
|
||||
if (dStrcmp( objName,"" )==0)
|
||||
object->setSelectedRiver(NULL);
|
||||
else
|
||||
{
|
||||
River *river = NULL;
|
||||
if ( Sim::findObject( argv[2], river ) )
|
||||
if ( Sim::findObject( objName, river ) )
|
||||
object->setSelectedRiver(river);
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, getSelectedRiver, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, getSelectedRiver, S32, (), , "" )
|
||||
{
|
||||
River *river = object->getSelectedRiver();
|
||||
if ( !river )
|
||||
return NULL;
|
||||
|
||||
return river->getIdString();
|
||||
return river->getId();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRiverEditorCtrl, regenerate, void, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRiverEditorCtrl, regenerate, void, (), , "" )
|
||||
{
|
||||
River *river = object->getSelectedRiver();
|
||||
if ( river )
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "environment/editors/guiRoadEditorCtrl.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "scene/sceneManager.h"
|
||||
#include "collision/collision.h"
|
||||
#include "math/util/frustum.h"
|
||||
|
|
@ -1036,86 +1037,71 @@ void GuiRoadEditorCtrl::submitUndo( const UTF8 *name )
|
|||
undoMan->addAction( action );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, deleteNode, void, 2, 2, "deleteNode()" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, deleteNode, void, (), , "deleteNode()" )
|
||||
{
|
||||
object->deleteSelectedNode();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, getMode, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, getMode, const char*, (), , "" )
|
||||
{
|
||||
return object->getMode();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, setMode, void, 3, 3, "setMode( String mode )" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, setMode, void, ( const char * mode ), , "setMode( String mode )" )
|
||||
{
|
||||
String newMode = ( argv[2] );
|
||||
String newMode = ( mode );
|
||||
object->setMode( newMode );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, getNodeWidth, F32, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, getNodeWidth, F32, (), , "" )
|
||||
{
|
||||
return object->getNodeWidth();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, setNodeWidth, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, setNodeWidth, void, ( F32 width ), , "" )
|
||||
{
|
||||
object->setNodeWidth( dAtof(argv[2]) );
|
||||
object->setNodeWidth( width );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, getNodePosition, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, getNodePosition, Point3F, (), , "" )
|
||||
{
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
|
||||
dSprintf(returnBuffer, bufSize, "%f %f %f",
|
||||
object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z);
|
||||
|
||||
return returnBuffer;
|
||||
return object->getNodePosition();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, setNodePosition, void, 3, 3, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, setNodePosition, void, ( Point3F pos ), , "" )
|
||||
{
|
||||
Point3F pos;
|
||||
|
||||
S32 count = dSscanf( argv[2], "%f %f %f",
|
||||
&pos.x, &pos.y, &pos.z);
|
||||
|
||||
if ( (count != 3) )
|
||||
{
|
||||
Con::printf("Failed to parse node information \"px py pz\" from '%s'", (const char*)argv[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
object->setNodePosition( pos );
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, setSelectedRoad, void, 2, 3, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, setSelectedRoad, void, ( const char * pathRoad ), (""), "" )
|
||||
{
|
||||
if ( argc == 2 )
|
||||
if (dStrcmp( pathRoad,"")==0 )
|
||||
object->setSelectedRoad(NULL);
|
||||
else
|
||||
{
|
||||
DecalRoad *road = NULL;
|
||||
if ( Sim::findObject( argv[2], road ) )
|
||||
if ( Sim::findObject( pathRoad, road ) )
|
||||
object->setSelectedRoad(road);
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, getSelectedRoad, const char*, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, getSelectedRoad, S32, (), , "" )
|
||||
{
|
||||
DecalRoad *road = object->getSelectedRoad();
|
||||
if ( road )
|
||||
return road->getIdString();
|
||||
return road->getId();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, getSelectedNode, S32, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, getSelectedNode, S32, (), , "" )
|
||||
{
|
||||
return object->getSelectedNode();
|
||||
}
|
||||
|
||||
ConsoleMethod( GuiRoadEditorCtrl, deleteRoad, void, 2, 2, "" )
|
||||
DefineConsoleMethod( GuiRoadEditorCtrl, deleteRoad, void, (), , "" )
|
||||
{
|
||||
object->deleteSelectedRoad();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "environment/skyBox.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "scene/sceneRenderState.h"
|
||||
#include "renderInstance/renderPassManager.h"
|
||||
#include "gfx/primBuilder.h"
|
||||
|
|
@ -637,7 +638,7 @@ BaseMatInstance* SkyBox::_getMaterialInstance()
|
|||
return mMatInstance;
|
||||
}
|
||||
|
||||
ConsoleMethod( SkyBox, postApply, void, 2, 2, "")
|
||||
DefineConsoleMethod( SkyBox, postApply, void, (), , "")
|
||||
{
|
||||
object->inspectPostApply();
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
#include "math/mathIO.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "scene/sceneManager.h"
|
||||
#include "math/mathUtils.h"
|
||||
#include "lighting/lightInfo.h"
|
||||
|
|
@ -546,18 +547,13 @@ void Sun::_onUnselected()
|
|||
Parent::_onUnselected();
|
||||
}
|
||||
|
||||
ConsoleMethod(Sun, apply, void, 2, 2, "")
|
||||
DefineConsoleMethod(Sun, apply, void, (), , "")
|
||||
{
|
||||
object->inspectPostApply();
|
||||
}
|
||||
|
||||
ConsoleMethod(Sun, animate, void, 7, 7, "animate( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation )")
|
||||
DefineConsoleMethod(Sun, animate, void, ( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation ), , "animate( F32 duration, F32 startAzimuth, F32 endAzimuth, F32 startElevation, F32 endElevation )")
|
||||
{
|
||||
F32 duration = dAtof(argv[2]);
|
||||
F32 startAzimuth = dAtof(argv[3]);
|
||||
F32 endAzimuth = dAtof(argv[4]);
|
||||
F32 startElevation = dAtof(argv[5]);
|
||||
F32 endElevation = dAtof(argv[6]);
|
||||
|
||||
object->animate(duration, startAzimuth, endAzimuth, startElevation, endElevation);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -780,7 +780,7 @@ void WaterObject::drawUnderwaterFilter( SceneRenderState *state )
|
|||
GFX->setWorldMatrix( newMat );
|
||||
|
||||
// set up render states
|
||||
GFX->disableShaders();
|
||||
GFX->setupGenericShaders();
|
||||
GFX->setStateBlock( mUnderwaterSB );
|
||||
|
||||
/*
|
||||
|
|
@ -891,6 +891,10 @@ void WaterObject::onRemove()
|
|||
{
|
||||
mPlaneReflector.unregisterReflector();
|
||||
cleanupMaterials();
|
||||
|
||||
PostEffect *underWaterEffect = getUnderwaterEffect( );
|
||||
if( underWaterEffect )
|
||||
underWaterEffect->disable( );
|
||||
}
|
||||
|
||||
Parent::onRemove();
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#include "platform/platform.h"
|
||||
#include "forest/editor/forestBrushElement.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "forest/forestItem.h"
|
||||
|
||||
|
||||
|
|
@ -187,10 +187,10 @@ bool ForestBrush::containsItemData( const ForestItemData *inData )
|
|||
return false;
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestBrush, containsItemData, bool, 3, 3, "( ForestItemData obj )" )
|
||||
DefineConsoleMethod( ForestBrush, containsItemData, bool, ( const char * obj ), , "( ForestItemData obj )" )
|
||||
{
|
||||
ForestItemData *data = NULL;
|
||||
if ( !Sim::findObject( argv[2], data ) )
|
||||
if ( !Sim::findObject( obj, data ) )
|
||||
{
|
||||
Con::warnf( "ForestBrush::containsItemData - invalid object passed" );
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "gui/worldEditor/editTSCtrl.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "core/util/tVector.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "gui/core/guiCanvas.h"
|
||||
|
|
@ -681,7 +682,7 @@ bool ForestBrushTool::getGroundAt( const Point3F &worldPt, F32 *zValueOut, Vecto
|
|||
return true;
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestBrushTool, collectElements, void, 2, 2, "" )
|
||||
DefineConsoleMethod( ForestBrushTool, collectElements, void, (), , "" )
|
||||
{
|
||||
object->collectElements();
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "forest/editor/forestBrushTool.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "gui/core/guiCanvas.h"
|
||||
#include "windowManager/platformCursorController.h"
|
||||
#include "forest/editor/forestUndo.h"
|
||||
|
|
@ -370,33 +371,33 @@ bool ForestEditorCtrl::isDirty()
|
|||
return foundDirty;
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestEditorCtrl, updateActiveForest, void, 2, 2, "()" )
|
||||
DefineConsoleMethod( ForestEditorCtrl, updateActiveForest, void, (), , "()" )
|
||||
{
|
||||
object->updateActiveForest( true );
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestEditorCtrl, setActiveTool, void, 3, 3, "( ForestTool tool )" )
|
||||
DefineConsoleMethod( ForestEditorCtrl, setActiveTool, void, ( const char * toolName ), , "( ForestTool tool )" )
|
||||
{
|
||||
ForestTool *tool = dynamic_cast<ForestTool*>( Sim::findObject( argv[2] ) );
|
||||
ForestTool *tool = dynamic_cast<ForestTool*>( Sim::findObject( toolName ) );
|
||||
object->setActiveTool( tool );
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestEditorCtrl, getActiveTool, S32, 2, 2, "()" )
|
||||
DefineConsoleMethod( ForestEditorCtrl, getActiveTool, S32, (), , "()" )
|
||||
{
|
||||
ForestTool *tool = object->getActiveTool();
|
||||
return tool ? tool->getId() : 0;
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestEditorCtrl, deleteMeshSafe, void, 3, 3, "( ForestItemData obj )" )
|
||||
DefineConsoleMethod( ForestEditorCtrl, deleteMeshSafe, void, ( const char * obj ), , "( ForestItemData obj )" )
|
||||
{
|
||||
ForestItemData *db;
|
||||
if ( !Sim::findObject( argv[2], db ) )
|
||||
if ( !Sim::findObject( obj, db ) )
|
||||
return;
|
||||
|
||||
object->deleteMeshSafe( db );
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestEditorCtrl, isDirty, bool, 2, 2, "" )
|
||||
DefineConsoleMethod( ForestEditorCtrl, isDirty, bool, (), , "" )
|
||||
{
|
||||
return object->isDirty();
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
#include "gui/worldEditor/editTSCtrl.h"
|
||||
#include "gui/worldEditor/gizmo.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "core/util/tVector.h"
|
||||
#include "core/util/safeDelete.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
|
|
@ -558,32 +559,32 @@ void ForestSelectionTool::onUndoAction()
|
|||
mBounds.intersect( mSelection[i].getWorldBox() );
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestSelectionTool, getSelectionCount, S32, 2, 2, "" )
|
||||
DefineConsoleMethod( ForestSelectionTool, getSelectionCount, S32, (), , "" )
|
||||
{
|
||||
return object->getSelectionCount();
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestSelectionTool, deleteSelection, void, 2, 2, "" )
|
||||
DefineConsoleMethod( ForestSelectionTool, deleteSelection, void, (), , "" )
|
||||
{
|
||||
object->deleteSelection();
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestSelectionTool, clearSelection, void, 2, 2, "" )
|
||||
DefineConsoleMethod( ForestSelectionTool, clearSelection, void, (), , "" )
|
||||
{
|
||||
object->clearSelection();
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestSelectionTool, cutSelection, void, 2, 2, "" )
|
||||
DefineConsoleMethod( ForestSelectionTool, cutSelection, void, (), , "" )
|
||||
{
|
||||
object->cutSelection();
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestSelectionTool, copySelection, void, 2, 2, "" )
|
||||
DefineConsoleMethod( ForestSelectionTool, copySelection, void, (), , "" )
|
||||
{
|
||||
object->copySelection();
|
||||
}
|
||||
|
||||
ConsoleMethod( ForestSelectionTool, pasteSelection, void, 2, 2, "" )
|
||||
DefineConsoleMethod( ForestSelectionTool, pasteSelection, void, (), , "" )
|
||||
{
|
||||
object->pasteSelection();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,10 @@
|
|||
#include "environment/sun.h"
|
||||
#include "scene/sceneManager.h"
|
||||
#include "math/mathUtils.h"
|
||||
#include "math/mTransform.h"
|
||||
#include "T3D/physics/physicsBody.h"
|
||||
#include "forest/editor/forestBrushElement.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
/// For frame signal
|
||||
#include "gui/core/guiCanvas.h"
|
||||
|
|
@ -359,23 +361,22 @@ void Forest::saveDataFile( const char *path )
|
|||
mData->write( mDataFileName );
|
||||
}
|
||||
|
||||
ConsoleMethod( Forest, saveDataFile, bool, 2, 3, "saveDataFile( [path] )" )
|
||||
DefineConsoleMethod( Forest, saveDataFile, void, (const char * path), (""), "saveDataFile( [path] )" )
|
||||
{
|
||||
object->saveDataFile( argc == 3 ? (const char*)argv[2] : NULL );
|
||||
return true;
|
||||
object->saveDataFile( path );
|
||||
}
|
||||
|
||||
ConsoleMethod(Forest, isDirty, bool, 2, 2, "()")
|
||||
DefineConsoleMethod(Forest, isDirty, bool, (), , "()")
|
||||
{
|
||||
return object->getData() && object->getData()->isDirty();
|
||||
}
|
||||
|
||||
ConsoleMethod(Forest, regenCells, void, 2, 2, "()")
|
||||
DefineConsoleMethod(Forest, regenCells, void, (), , "()")
|
||||
{
|
||||
object->getData()->regenCells();
|
||||
}
|
||||
|
||||
ConsoleMethod(Forest, clear, void, 2, 2, "()" )
|
||||
DefineConsoleMethod(Forest, clear, void, (), , "()" )
|
||||
{
|
||||
object->clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ protected:
|
|||
// }
|
||||
|
||||
virtual GFXShader* createShader();
|
||||
void disableShaders();
|
||||
|
||||
/// Device helper function
|
||||
virtual D3DPRESENT_PARAMETERS setupPresentParams( const GFXVideoMode &mode, const HWND &hwnd ) const = 0;
|
||||
|
|
@ -271,7 +272,6 @@ public:
|
|||
|
||||
virtual F32 getPixelShaderVersion() const { return mPixVersion; }
|
||||
virtual void setPixelShaderVersion( F32 version ){ mPixVersion = version; }
|
||||
virtual void disableShaders();
|
||||
virtual void setShader( GFXShader *shader );
|
||||
virtual U32 getNumSamplers() const { return mNumSamplers; }
|
||||
virtual U32 getNumRenderTargets() const { return mNumRenderTargets; }
|
||||
|
|
|
|||
|
|
@ -1101,11 +1101,13 @@ void GFXD3D9Shader::_getShaderConstants( ID3DXConstantTable *table,
|
|||
desc.constType = GFXSCT_Sampler;
|
||||
desc.arraySize = constantDesc.RegisterIndex;
|
||||
samplerDescriptions.push_back( desc );
|
||||
mShaderConsts.push_back(desc);
|
||||
break;
|
||||
case D3DXPT_SAMPLERCUBE :
|
||||
desc.constType = GFXSCT_SamplerCube;
|
||||
desc.arraySize = constantDesc.RegisterIndex;
|
||||
samplerDescriptions.push_back( desc );
|
||||
mShaderConsts.push_back(desc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1371,7 +1373,7 @@ GFXShaderConstBufferRef GFXD3D9Shader::allocConstBuffer()
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns a shader constant handle for name, if the variable doesn't exist NULL is returned.
|
||||
/// Returns a shader constant handle for name
|
||||
GFXShaderConstHandle* GFXD3D9Shader::getShaderConstHandle(const String& name)
|
||||
{
|
||||
HandleMap::Iterator i = mHandles.find(name);
|
||||
|
|
@ -1390,6 +1392,20 @@ GFXShaderConstHandle* GFXD3D9Shader::getShaderConstHandle(const String& name)
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns a shader constant handle for name, if the variable doesn't exist NULL is returned.
|
||||
GFXShaderConstHandle* GFXD3D9Shader::findShaderConstHandle(const String& name)
|
||||
{
|
||||
HandleMap::Iterator i = mHandles.find(name);
|
||||
if ( i != mHandles.end() )
|
||||
{
|
||||
return i->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const Vector<GFXShaderConstDesc>& GFXD3D9Shader::getShaderConstDesc() const
|
||||
{
|
||||
return mShaderConsts;
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ public:
|
|||
virtual GFXShaderConstBufferRef allocConstBuffer();
|
||||
virtual const Vector<GFXShaderConstDesc>& getShaderConstDesc() const;
|
||||
virtual GFXShaderConstHandle* getShaderConstHandle(const String& name);
|
||||
virtual GFXShaderConstHandle* findShaderConstHandle(const String& name);
|
||||
virtual U32 getAlignmentValue(const GFXShaderConstType constType) const;
|
||||
virtual bool getDisassembly( String &outStr ) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -450,6 +450,7 @@ bool GFXD3D9TextureManager::_loadTexture( GFXTextureObject *inTex, void *raw )
|
|||
break;
|
||||
case GFXFormatR8G8B8A8:
|
||||
case GFXFormatR8G8B8X8:
|
||||
case GFXFormatB8G8R8A8:
|
||||
bytesPerPix = 4;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ void GFXD3D9EnumTranslate::init()
|
|||
GFXD3D9TextureFormat[GFXFormatR8G8B8] = D3DFMT_R8G8B8;
|
||||
GFXD3D9TextureFormat[GFXFormatR8G8B8A8] = D3DFMT_A8R8G8B8;
|
||||
GFXD3D9TextureFormat[GFXFormatR8G8B8X8] = D3DFMT_X8R8G8B8;
|
||||
GFXD3D9TextureFormat[GFXFormatB8G8R8A8] = D3DFMT_A8R8G8B8;
|
||||
GFXD3D9TextureFormat[GFXFormatR5G6B5] = D3DFMT_R5G6B5;
|
||||
GFXD3D9TextureFormat[GFXFormatR5G5B5A1] = D3DFMT_A1R5G5B5;
|
||||
GFXD3D9TextureFormat[GFXFormatR5G5B5X1] = D3DFMT_X1R5G5B5;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void GFXCardProfiler::loadProfileScript(const char* aScriptName)
|
|||
|
||||
Con::printf(" - Loaded card profile %s", scriptName.c_str());
|
||||
|
||||
Con::executef("eval", script);
|
||||
Con::evaluate(script, false, NULL);
|
||||
delete[] script;
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue