mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Merge branch 'master' into console-func-refactor
Conflicts: Engine/source/app/net/net.cpp Engine/source/console/astNodes.cpp Engine/source/console/compiledEval.cpp Engine/source/console/console.h Engine/source/console/consoleInternal.h Engine/source/console/engineAPI.h
This commit is contained in:
commit
b507dc9555
6487 changed files with 315149 additions and 609761 deletions
|
|
@ -1298,7 +1298,7 @@ DefineEngineMethod( EditTSCtrl, renderCircle, void, ( Point3F pos, Point3F norma
|
|||
|
||||
PrimBuild::begin( GFXLineStrip, points.size() + 1 );
|
||||
|
||||
for( int i = 0; i < points.size(); i++ )
|
||||
for( S32 i = 0; i < points.size(); i++ )
|
||||
PrimBuild::vertex3fv( points[i] );
|
||||
|
||||
// GFX does not have a LineLoop primitive, so connect the last line
|
||||
|
|
@ -1321,7 +1321,7 @@ DefineEngineMethod( EditTSCtrl, renderCircle, void, ( Point3F pos, Point3F norma
|
|||
PrimBuild::vertex3fv( pos );
|
||||
|
||||
// Edge verts
|
||||
for( int i = 0; i < points.size(); i++ )
|
||||
for( S32 i = 0; i < points.size(); i++ )
|
||||
PrimBuild::vertex3fv( points[i] );
|
||||
|
||||
PrimBuild::vertex3fv( points[0] );
|
||||
|
|
|
|||
|
|
@ -821,12 +821,13 @@ ConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, 3, 3, "getDec
|
|||
if( decalInstance == NULL )
|
||||
return "";
|
||||
|
||||
char* returnBuffer = Con::getReturnBuffer(256);
|
||||
static const U32 bufSize = 256;
|
||||
char* returnBuffer = Con::getReturnBuffer(bufSize);
|
||||
returnBuffer[0] = 0;
|
||||
|
||||
if ( decalInstance )
|
||||
{
|
||||
dSprintf(returnBuffer, 256, "%f %f %f %f %f %f %f",
|
||||
dSprintf(returnBuffer, bufSize, "%f %f %f %f %f %f %f",
|
||||
decalInstance->mPosition.x, decalInstance->mPosition.y, decalInstance->mPosition.z,
|
||||
decalInstance->mTangent.x, decalInstance->mTangent.y, decalInstance->mTangent.z,
|
||||
decalInstance->mSize);
|
||||
|
|
|
|||
|
|
@ -631,6 +631,52 @@ void SmoothHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool
|
|||
}
|
||||
}
|
||||
|
||||
void SmoothSlopeAction::process(Selection * sel, const Gui3DMouseEvent &, bool selChanged, Type)
|
||||
{
|
||||
if(!sel->size())
|
||||
return;
|
||||
|
||||
if(selChanged)
|
||||
{
|
||||
// Perform simple 2d linear regression on x&z and y&z:
|
||||
// b = (Avg(xz) - Avg(x)Avg(z))/(Avg(x^2) - Avg(x)^2)
|
||||
Point2F prod(0.f, 0.f); // mean of product for covar
|
||||
Point2F avgSqr(0.f, 0.f); // mean sqr of x, y for var
|
||||
Point2F avgPos(0.f, 0.f);
|
||||
F32 avgHeight = 0.f;
|
||||
F32 z;
|
||||
Point2F pos;
|
||||
for(U32 k = 0; k < sel->size(); k++)
|
||||
{
|
||||
mTerrainEditor->getUndoSel()->add((*sel)[k]);
|
||||
pos = Point2F((*sel)[k].mGridPoint.gridPos.x, (*sel)[k].mGridPoint.gridPos.y);
|
||||
z = (*sel)[k].mHeight;
|
||||
|
||||
prod += pos * z;
|
||||
avgSqr += pos * pos;
|
||||
avgPos += pos;
|
||||
avgHeight += z;
|
||||
}
|
||||
|
||||
prod /= sel->size();
|
||||
avgSqr /= sel->size();
|
||||
avgPos /= sel->size();
|
||||
avgHeight /= sel->size();
|
||||
|
||||
Point2F avgSlope = (prod - avgPos*avgHeight)/(avgSqr - avgPos*avgPos);
|
||||
|
||||
F32 goalHeight;
|
||||
for(U32 i = 0; i < sel->size(); i++)
|
||||
{
|
||||
goalHeight = avgHeight + ((*sel)[i].mGridPoint.gridPos.x - avgPos.x)*avgSlope.x +
|
||||
((*sel)[i].mGridPoint.gridPos.y - avgPos.y)*avgSlope.y;
|
||||
(*sel)[i].mHeight += (goalHeight - (*sel)[i].mHeight) * (*sel)[i].mWeight;
|
||||
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||
}
|
||||
mTerrainEditor->scheduleGridUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void PaintNoiseAction::process(Selection * sel, const Gui3DMouseEvent &, bool selChanged, Type type)
|
||||
{
|
||||
// If this is the ending
|
||||
|
|
|
|||
|
|
@ -258,6 +258,15 @@ class SmoothHeightAction : public TerrainAction
|
|||
void process(Selection * sel, const Gui3DMouseEvent & event, bool selChanged, Type type);
|
||||
};
|
||||
|
||||
class SmoothSlopeAction : public TerrainAction
|
||||
{
|
||||
public:
|
||||
SmoothSlopeAction(TerrainEditor * editor) : TerrainAction(editor){}
|
||||
StringTableEntry getName(){return("smoothSlope");}
|
||||
|
||||
void process(Selection * sel, const Gui3DMouseEvent & event, bool selChanged, Type type);
|
||||
};
|
||||
|
||||
class PaintNoiseAction : public TerrainAction
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "gui/core/guiCanvas.h"
|
||||
#include "gui/worldEditor/terrainActions.h"
|
||||
#include "interior/interiorInstance.h"
|
||||
#include "terrain/terrMaterial.h"
|
||||
|
||||
|
||||
|
|
@ -671,7 +670,7 @@ TerrainEditor::TerrainEditor() :
|
|||
mUndoSel(0),
|
||||
mGridUpdateMin( S32_MAX, S32_MAX ),
|
||||
mGridUpdateMax( 0, 0 ),
|
||||
mMaxBrushSize(48,48),
|
||||
mMaxBrushSize(256,256),
|
||||
mNeedsGridUpdate( false ),
|
||||
mNeedsMaterialUpdate( false ),
|
||||
mMouseDown( false )
|
||||
|
|
@ -710,6 +709,7 @@ TerrainEditor::TerrainEditor() :
|
|||
mActions.push_back(new AdjustHeightAction(this));
|
||||
mActions.push_back(new FlattenHeightAction(this));
|
||||
mActions.push_back(new SmoothHeightAction(this));
|
||||
mActions.push_back(new SmoothSlopeAction(this));
|
||||
mActions.push_back(new PaintNoiseAction(this));
|
||||
//mActions.push_back(new ThermalErosionAction(this));
|
||||
|
||||
|
|
@ -2111,8 +2111,9 @@ const char* TerrainEditor::getBrushPos()
|
|||
AssertFatal(mMouseBrush!=NULL, "TerrainEditor::getBrushPos: no mouse brush!");
|
||||
|
||||
Point2I pos = mMouseBrush->getPosition();
|
||||
char * ret = Con::getReturnBuffer(32);
|
||||
dSprintf(ret, 32, "%d %d", pos.x, pos.y);
|
||||
static const U32 bufSize = 32;
|
||||
char * ret = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(ret, bufSize, "%d %d", pos.x, pos.y);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
|
@ -2244,73 +2245,6 @@ void TerrainEditor::markEmptySquares()
|
|||
{
|
||||
if(!checkTerrainBlock(this, "markEmptySquares"))
|
||||
return;
|
||||
|
||||
// TODO!
|
||||
/*
|
||||
// build a list of all the marked interiors
|
||||
Vector<InteriorInstance*> interiors;
|
||||
U32 mask = InteriorObjectType;
|
||||
gServerContainer.findObjects(mask, findObjectsCallback, &interiors);
|
||||
|
||||
// walk the terrains and empty any grid which clips to an interior
|
||||
for (U32 i = 0; i < mTerrainBlocks.size(); i++)
|
||||
{
|
||||
for(U32 x = 0; x < TerrainBlock::BlockSize; x++)
|
||||
{
|
||||
for(U32 y = 0; y < TerrainBlock::BlockSize; y++)
|
||||
{
|
||||
TerrainBlock::Material * material = mTerrainBlocks[i]->getMaterial(x,y);
|
||||
material->flags |= ~(TerrainBlock::Material::Empty);
|
||||
|
||||
Point3F a, b;
|
||||
gridToWorld(Point2I(x,y), a, mTerrainBlocks[i]);
|
||||
gridToWorld(Point2I(x+1,y+1), b, mTerrainBlocks[i]);
|
||||
|
||||
Box3F box;
|
||||
box.minExtents = a;
|
||||
box.maxExtents = b;
|
||||
|
||||
box.minExtents.setMin(b);
|
||||
box.maxExtents.setMax(a);
|
||||
|
||||
const MatrixF & terrOMat = mTerrainBlocks[i]->getTransform();
|
||||
const MatrixF & terrWMat = mTerrainBlocks[i]->getWorldTransform();
|
||||
|
||||
terrWMat.mulP(box.minExtents);
|
||||
terrWMat.mulP(box.maxExtents);
|
||||
|
||||
for(U32 i = 0; i < interiors.size(); i++)
|
||||
{
|
||||
MatrixF mat = interiors[i]->getWorldTransform();
|
||||
mat.scale(interiors[i]->getScale());
|
||||
mat.mul(terrOMat);
|
||||
|
||||
U32 waterMark = FrameAllocator::getWaterMark();
|
||||
U16* zoneVector = (U16*)FrameAllocator::alloc(interiors[i]->getDetailLevel(0)->getNumZones());
|
||||
U32 numZones = 0;
|
||||
interiors[i]->getDetailLevel(0)->scanZones(box, mat,
|
||||
zoneVector, &numZones);
|
||||
if (numZones != 0)
|
||||
{
|
||||
Con::printf("%d %d", x, y);
|
||||
material->flags |= TerrainBlock::Material::Empty;
|
||||
FrameAllocator::setWaterMark(waterMark);
|
||||
break;
|
||||
}
|
||||
FrameAllocator::setWaterMark(waterMark);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rebuild stuff..
|
||||
for (U32 i = 0; i < mTerrainBlocks.size(); i++)
|
||||
{
|
||||
mTerrainBlocks[i]->buildGridMap();
|
||||
mTerrainBlocks[i]->rebuildEmptyFlags();
|
||||
mTerrainBlocks[i]->packEmptySquares();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void TerrainEditor::mirrorTerrain(S32 mirrorIndex)
|
||||
|
|
@ -2588,8 +2522,9 @@ ConsoleMethod( TerrainEditor, getBrushSize, const char*, 2, 2, "()")
|
|||
{
|
||||
Point2I size = object->getBrushSize();
|
||||
|
||||
char * ret = Con::getReturnBuffer(32);
|
||||
dSprintf(ret, 32, "%d %d", size.x, size.y);
|
||||
static const U32 bufSize = 32;
|
||||
char * ret = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(ret, bufSize, "%d %d", size.x, size.y);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -2933,3 +2868,77 @@ ConsoleMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, 3, 3, 0)
|
|||
object->mSlopeMaxAngle = angle;
|
||||
return angle;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void TerrainEditor::autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinSlope, F32 mMaxSlope, F32 mCoverage )
|
||||
{
|
||||
if (!mActiveTerrain)
|
||||
return;
|
||||
|
||||
S32 mat = getPaintMaterialIndex();
|
||||
if (mat == -1)
|
||||
return;
|
||||
|
||||
mUndoSel = new Selection;
|
||||
|
||||
U32 terrBlocks = mActiveTerrain->getBlockSize();
|
||||
for (U32 y = 0; y < terrBlocks; y++)
|
||||
{
|
||||
for (U32 x = 0; x < terrBlocks; x++)
|
||||
{
|
||||
// get info
|
||||
GridPoint gp;
|
||||
gp.terrainBlock = mActiveTerrain;
|
||||
gp.gridPos.set(x, y);
|
||||
|
||||
GridInfo gi;
|
||||
getGridInfo(gp, gi);
|
||||
|
||||
if (gi.mMaterial == mat)
|
||||
continue;
|
||||
|
||||
if (mRandI(0, 100) > mCoverage)
|
||||
continue;
|
||||
|
||||
Point3F wp;
|
||||
gridToWorld(gp, wp);
|
||||
|
||||
if (!(wp.z >= mMinHeight && wp.z <= mMaxHeight))
|
||||
continue;
|
||||
|
||||
// transform wp to object space
|
||||
Point3F op;
|
||||
mActiveTerrain->getWorldTransform().mulP(wp, &op);
|
||||
|
||||
Point3F norm;
|
||||
mActiveTerrain->getNormal(Point2F(op.x, op.y), &norm, true);
|
||||
|
||||
if (mMinSlope > 0)
|
||||
if (norm.z > mSin(mDegToRad(90.0f - mMinSlope)))
|
||||
continue;
|
||||
|
||||
if (mMaxSlope < 90)
|
||||
if (norm.z < mSin(mDegToRad(90.0f - mMaxSlope)))
|
||||
continue;
|
||||
|
||||
gi.mMaterialChanged = true;
|
||||
mUndoSel->add(gi);
|
||||
gi.mMaterial = mat;
|
||||
setGridInfo(gi);
|
||||
}
|
||||
}
|
||||
|
||||
if(mUndoSel->size())
|
||||
submitUndo( mUndoSel );
|
||||
else
|
||||
delete mUndoSel;
|
||||
|
||||
mUndoSel = 0;
|
||||
|
||||
scheduleMaterialUpdate();
|
||||
}
|
||||
|
||||
ConsoleMethod( TerrainEditor, autoMaterialLayer, void, 7, 7, "(float minHeight, float maxHeight, float minSlope, float maxSlope, float coverage)")
|
||||
{
|
||||
object->autoMaterialLayer( dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4]), dAtof(argv[5]), dAtof(argv[6]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
enum { MaxBrushDim = 40 };
|
||||
enum { MaxBrushDim = 256 };
|
||||
|
||||
Brush(TerrainEditor * editor);
|
||||
virtual ~Brush(){};
|
||||
|
|
@ -230,6 +230,8 @@ class TerrainEditor : public EditTSCtrl
|
|||
void submitMaterialUndo( String actionName );
|
||||
void onMaterialUndo( TerrainBlock *terr );
|
||||
|
||||
void autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinSlope, F32 mMaxSlope, F32 mCoverage );
|
||||
|
||||
private:
|
||||
|
||||
typedef EditTSCtrl Parent;
|
||||
|
|
|
|||
|
|
@ -1505,7 +1505,8 @@ void WorldEditor::renderSplinePath(SimPath::Path *path)
|
|||
|
||||
GFXVertexBufferHandle<GFXVertexPC> vb;
|
||||
vb.set(GFX, 3*batchSize, GFXBufferTypeVolatile);
|
||||
vb.lock();
|
||||
void *lockPtr = vb.lock();
|
||||
if(!lockPtr) return;
|
||||
|
||||
U32 vIdx=0;
|
||||
|
||||
|
|
@ -1542,7 +1543,8 @@ void WorldEditor::renderSplinePath(SimPath::Path *path)
|
|||
|
||||
// Reset for next pass...
|
||||
vIdx = 0;
|
||||
vb.lock();
|
||||
void *lockPtr = vb.lock();
|
||||
if(!lockPtr) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2880,8 +2882,9 @@ const Point3F& WorldEditor::getSelectionCentroid()
|
|||
const char* WorldEditor::getSelectionCentroidText()
|
||||
{
|
||||
const Point3F & centroid = getSelectionCentroid();
|
||||
char * ret = Con::getReturnBuffer(100);
|
||||
dSprintf(ret, 100, "%g %g %g", centroid.x, centroid.y, centroid.z);
|
||||
static const U32 bufSize = 100;
|
||||
char * ret = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(ret, bufSize, "%g %g %g", centroid.x, centroid.y, centroid.z);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -3261,8 +3264,9 @@ ConsoleMethod( WorldEditor, getSelectionCentroid, const char *, 2, 2, "")
|
|||
ConsoleMethod( WorldEditor, getSelectionExtent, const char *, 2, 2, "")
|
||||
{
|
||||
Point3F bounds = object->getSelectionExtent();
|
||||
char * ret = Con::getReturnBuffer(100);
|
||||
dSprintf(ret, 100, "%g %g %g", bounds.x, bounds.y, bounds.z);
|
||||
static const U32 bufSize = 100;
|
||||
char * ret = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(ret, bufSize, "%g %g %g", bounds.x, bounds.y, bounds.z);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -642,10 +642,11 @@ ConsoleMethod( WorldEditorSelection, containsGlobalBounds, bool, 2, 2, "() - Tru
|
|||
|
||||
ConsoleMethod( WorldEditorSelection, getCentroid, const char*, 2, 2, "() - Return the median of all object positions in the selection." )
|
||||
{
|
||||
char* buffer = Con::getReturnBuffer( 256 );
|
||||
static const U32 bufSize = 256;
|
||||
char* buffer = Con::getReturnBuffer( bufSize );
|
||||
const Point3F& centroid = object->getCentroid();
|
||||
|
||||
dSprintf( buffer, 256, "%g %g %g", centroid.x, centroid.y, centroid.z );
|
||||
dSprintf( buffer, bufSize, "%g %g %g", centroid.x, centroid.y, centroid.z );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
@ -653,10 +654,11 @@ ConsoleMethod( WorldEditorSelection, getCentroid, const char*, 2, 2, "() - Retur
|
|||
|
||||
ConsoleMethod( WorldEditorSelection, getBoxCentroid, const char*, 2, 2, "() - Return the center of the bounding box around the selection." )
|
||||
{
|
||||
char* buffer = Con::getReturnBuffer( 256 );
|
||||
static const U32 bufSize = 256;
|
||||
char* buffer = Con::getReturnBuffer( bufSize );
|
||||
const Point3F& boxCentroid = object->getBoxCentroid();
|
||||
|
||||
dSprintf( buffer, 256, "%g %g %g", boxCentroid.x, boxCentroid.y, boxCentroid.z );
|
||||
dSprintf( buffer, bufSize, "%g %g %g", boxCentroid.x, boxCentroid.y, boxCentroid.z );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue