mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-05 05:20:31 +00:00
Merge remote-tracking branch 'devhead/Preview4_0' into cpuinfo
This commit is contained in:
commit
ca0a5d41a7
42 changed files with 668 additions and 218 deletions
|
|
@ -169,7 +169,13 @@ void MaterialAsset::initializeAsset()
|
|||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
||||
|
||||
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||
Con::executeFile(mScriptPath, false, false);
|
||||
{
|
||||
if (!Sim::findObject(mMatDefinitionName))
|
||||
if (Con::executeFile(mScriptPath, false, false))
|
||||
mLoadedState = ScriptLoaded;
|
||||
else
|
||||
mLoadedState = Failed;
|
||||
}
|
||||
|
||||
loadMaterial();
|
||||
}
|
||||
|
|
@ -179,7 +185,22 @@ void MaterialAsset::onAssetRefresh()
|
|||
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
|
||||
|
||||
if (Torque::FS::IsScriptFile(mScriptPath))
|
||||
Con::executeFile(mScriptPath, false, false);
|
||||
{
|
||||
//Since we're refreshing, we can assume that the file we're executing WILL have an existing definition.
|
||||
//But that definition, whatever it is, is the 'correct' one, so we enable the Replace Existing behavior
|
||||
//when the engine encounters a named object conflict.
|
||||
String redefineBehaviorPrev = Con::getVariable("$Con::redefineBehavior");
|
||||
Con::setVariable("$Con::redefineBehavior", "replaceExisting");
|
||||
|
||||
if (Con::executeFile(mScriptPath, false, false))
|
||||
mLoadedState = ScriptLoaded;
|
||||
else
|
||||
mLoadedState = Failed;
|
||||
|
||||
//And now that we've executed, switch back to the prior behavior
|
||||
Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
|
||||
|
||||
}
|
||||
|
||||
loadMaterial();
|
||||
}
|
||||
|
|
@ -206,7 +227,7 @@ void MaterialAsset::loadMaterial()
|
|||
if (mMaterialDefinition)
|
||||
SAFE_DELETE(mMaterialDefinition);
|
||||
|
||||
if (mMatDefinitionName != StringTable->EmptyString())
|
||||
if (mLoadedState == ScriptLoaded && mMatDefinitionName != StringTable->EmptyString())
|
||||
{
|
||||
Material* matDef;
|
||||
if (!Sim::findObject(mMatDefinitionName, matDef))
|
||||
|
|
|
|||
|
|
@ -70,6 +70,12 @@ class MaterialAsset : public AssetBase
|
|||
public:
|
||||
static StringTableEntry smNoMaterialAssetFallback;
|
||||
|
||||
enum MaterialAssetErrCode
|
||||
{
|
||||
ScriptLoaded = AssetErrCode::Extended,
|
||||
Extended
|
||||
};
|
||||
|
||||
public:
|
||||
MaterialAsset();
|
||||
virtual ~MaterialAsset();
|
||||
|
|
|
|||
|
|
@ -1551,13 +1551,10 @@ void ParticleEmitter::updateBBox()
|
|||
|
||||
for (Particle* part = part_list_head.next; part != NULL; part = part->next)
|
||||
{
|
||||
for (Particle* part = part_list_head.next; part != NULL; part = part->next)
|
||||
{
|
||||
Point3F particleSize(part->size * 0.5f);
|
||||
F32 motion = getMax((part->vel.len() * part->totalLifetime / 1000.0f), 1.0f);
|
||||
minPt.setMin(part->pos - particleSize - Point3F(motion));
|
||||
maxPt.setMax(part->pos + particleSize + Point3F(motion));
|
||||
}
|
||||
Point3F particleSize(part->size * 0.5f);
|
||||
F32 motion = getMax((part->vel.len() * part->totalLifetime / 1000.0f), 1.0f);
|
||||
minPt.setMin(part->pos - particleSize - Point3F(motion));
|
||||
maxPt.setMax(part->pos + particleSize + Point3F(motion));
|
||||
}
|
||||
|
||||
mObjBox = Box3F(minPt, maxPt);
|
||||
|
|
@ -1675,8 +1672,8 @@ void ParticleEmitter::addParticle(const Point3F& pos, const Point3F& axis, const
|
|||
}
|
||||
else
|
||||
{
|
||||
U32 dBlockIndex = gRandGen.randI() % mDataBlock->particleDataBlocks.size();
|
||||
mDataBlock->particleDataBlocks[dBlockIndex]->initializeParticle(pNew, vel);
|
||||
dBlockIndex = gRandGen.randI() % mDataBlock->particleDataBlocks.size();
|
||||
mDataBlock->particleDataBlocks[dBlockIndex]->initializeParticle(pNew, vel);
|
||||
}
|
||||
updateKeyData( pNew );
|
||||
|
||||
|
|
@ -2220,7 +2217,7 @@ void ParticleEmitter::setupOriented( Particle *part,
|
|||
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||
const ColorI color = partCol.toColorI();
|
||||
// Here we deal with UVs for animated particle (oriented)
|
||||
if (part->dataBlock->animateTexture)
|
||||
if (part->dataBlock->animateTexture && !part->dataBlock->animTexFrames.empty())
|
||||
{
|
||||
// Let particle compute the UV indices for current frame
|
||||
S32 fm = (S32)(part->currentAge*(1.0f/1000.0f)*part->dataBlock->framesPerSec);
|
||||
|
|
@ -2331,7 +2328,7 @@ void ParticleEmitter::setupAligned( const Particle *part,
|
|||
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||
const ColorI color = partCol.toColorI();
|
||||
// Here we deal with UVs for animated particle
|
||||
if (part->dataBlock->animateTexture)
|
||||
if (part->dataBlock->animateTexture && !part->dataBlock->animTexFrames.empty())
|
||||
{
|
||||
// Let particle compute the UV indices for current frame
|
||||
S32 fm = (S32)(part->currentAge*(1.0f/1000.0f)*part->dataBlock->framesPerSec);
|
||||
|
|
@ -2520,7 +2517,7 @@ void ParticleEmitter::setupRibbon(Particle *part,
|
|||
ColorI pCol = partCol.toColorI();
|
||||
|
||||
// Here we deal with UVs for animated particle (oriented)
|
||||
if (part->dataBlock->animateTexture)
|
||||
if (part->dataBlock->animateTexture && !part->dataBlock->animTexFrames.empty())
|
||||
{
|
||||
// Let particle compute the UV indices for current frame
|
||||
S32 fm = (S32)(part->currentAge*(1.0f / 1000.0f)*part->dataBlock->framesPerSec);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ ConsoleDocClass( PrecipitationData,
|
|||
//----------------------------------------------------------
|
||||
PrecipitationData::PrecipitationData()
|
||||
{
|
||||
soundProfile = NULL;
|
||||
INIT_SOUNDASSET(Sound);
|
||||
|
||||
INIT_IMAGEASSET(Drop);
|
||||
|
||||
|
|
@ -143,8 +143,7 @@ PrecipitationData::PrecipitationData()
|
|||
|
||||
void PrecipitationData::initPersistFields()
|
||||
{
|
||||
addField( "soundProfile", TYPEID< SFXTrack >(), Offset(soundProfile, PrecipitationData),
|
||||
"Looping SFXProfile effect to play while Precipitation is active." );
|
||||
INITPERSISTFIELD_SOUNDASSET(Sound, PrecipitationData, "Looping SFXProfile effect to play while Precipitation is active.");
|
||||
|
||||
addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn,
|
||||
"@brief Texture filename for drop particles.\n\n"
|
||||
|
|
@ -190,7 +189,7 @@ bool PrecipitationData::preload( bool server, String &errorStr )
|
|||
if( Parent::preload( server, errorStr) == false)
|
||||
return false;
|
||||
|
||||
if( !server && !sfxResolve( &soundProfile, errorStr ) )
|
||||
if (!server && !getSFXProfile())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -200,7 +199,7 @@ void PrecipitationData::packData(BitStream* stream)
|
|||
{
|
||||
Parent::packData(stream);
|
||||
|
||||
sfxWrite( stream, soundProfile );
|
||||
PACKDATA_SOUNDASSET(Sound);
|
||||
|
||||
PACKDATA_IMAGEASSET(Drop);
|
||||
|
||||
|
|
@ -217,7 +216,7 @@ void PrecipitationData::unpackData(BitStream* stream)
|
|||
{
|
||||
Parent::unpackData(stream);
|
||||
|
||||
sfxRead( stream, &soundProfile );
|
||||
UNPACKDATA_SOUNDASSET(Sound);
|
||||
|
||||
UNPACKDATA_IMAGEASSET(Drop);
|
||||
|
||||
|
|
@ -598,9 +597,9 @@ bool Precipitation::onNewDataBlock( GameBaseData *dptr, bool reload )
|
|||
{
|
||||
SFX_DELETE( mAmbientSound );
|
||||
|
||||
if ( mDataBlock->soundProfile )
|
||||
if ( mDataBlock->getSFXProfile())
|
||||
{
|
||||
mAmbientSound = SFX->createSource( mDataBlock->soundProfile, &getTransform() );
|
||||
mAmbientSound = SFX->createSource(mDataBlock->getSFXProfile(), &getTransform() );
|
||||
if ( mAmbientSound )
|
||||
mAmbientSound->play();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,9 @@
|
|||
#endif
|
||||
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
#include "T3D/assets/SoundAsset.h"
|
||||
|
||||
class SFXTrack;
|
||||
//class SFXTrack;
|
||||
class SFXSource;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
|
@ -45,30 +46,39 @@ class PrecipitationData : public GameBaseData
|
|||
typedef GameBaseData Parent;
|
||||
|
||||
public:
|
||||
SFXTrack* soundProfile;
|
||||
//SFXTrack* soundProfile;
|
||||
DECLARE_SOUNDASSET(PrecipitationData, Sound);
|
||||
DECLARE_SOUNDASSET_SETGET(PrecipitationData, Sound);
|
||||
|
||||
DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles
|
||||
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Drop);
|
||||
DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles
|
||||
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Drop);
|
||||
|
||||
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
|
||||
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
|
||||
|
||||
DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles
|
||||
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Splash);
|
||||
DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles
|
||||
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Splash);
|
||||
|
||||
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
|
||||
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
|
||||
|
||||
S32 mDropsPerSide; ///< How many drops are on a side of the raindrop texture.
|
||||
S32 mSplashesPerSide; ///< How many splash are on a side of the splash texture.
|
||||
S32 mDropsPerSide; ///< How many drops are on a side of the raindrop texture.
|
||||
S32 mSplashesPerSide; ///< How many splash are on a side of the splash texture.
|
||||
|
||||
PrecipitationData();
|
||||
DECLARE_CONOBJECT(PrecipitationData);
|
||||
bool preload( bool server, String& errorStr );
|
||||
static void initPersistFields();
|
||||
virtual void packData(BitStream* stream);
|
||||
virtual void unpackData(BitStream* stream);
|
||||
PrecipitationData();
|
||||
DECLARE_CONOBJECT(PrecipitationData);
|
||||
bool preload( bool server, String& errorStr );
|
||||
static void initPersistFields();
|
||||
virtual void packData(BitStream* stream);
|
||||
virtual void unpackData(BitStream* stream);
|
||||
|
||||
void onDropChanged() {}
|
||||
void onSplashChanged() {}
|
||||
void onDropChanged() {}
|
||||
void onSplashChanged() {}
|
||||
|
||||
SFXProfile* getSFXProfile() {
|
||||
if (mSoundAsset.notNull())
|
||||
return mSoundAsset->getSfxProfile();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
struct Raindrop
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ bool Prefab::protectedSetFile( void *object, const char *index, const char *data
|
|||
return false;
|
||||
}
|
||||
|
||||
void Prefab::setFile( String file )
|
||||
void Prefab::setFile( StringTableEntry file )
|
||||
{
|
||||
AssertFatal( isServerObject(), "Prefab-bad" );
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ void Prefab::setFile( String file )
|
|||
// be called for the client-side prefab but maybe the user did so accidentally.
|
||||
if ( isClientObject() )
|
||||
{
|
||||
Con::errorf( "Prefab::setFile( %s ) - Should not be called on a client-side Prefab.", file.c_str() );
|
||||
Con::errorf( "Prefab::setFile( %s ) - Should not be called on a client-side Prefab.", file );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public:
|
|||
void render( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
|
||||
|
||||
///
|
||||
void setFile( String file );
|
||||
void setFile(StringTableEntry file );
|
||||
|
||||
/// Removes all children from this Prefab and puts them into a SimGroup
|
||||
/// which is added to the Scene and returned to the caller.
|
||||
|
|
|
|||
|
|
@ -786,6 +786,8 @@ bool Projectile::onAdd()
|
|||
// If we're on the server, we need to inherit some of our parent's velocity
|
||||
//
|
||||
mCurrTick = 0;
|
||||
|
||||
scriptOnAdd();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1675,10 +1675,6 @@ void TSStatic::onInspect(GuiInspector* inspector)
|
|||
{
|
||||
dSprintf(matFieldName, 128, "MaterialSlot%d", i);
|
||||
|
||||
//addComponentField(matFieldName, "A material used in the shape file", "Material", matAsset->getAssetId(), "");
|
||||
//Con::executef(this, "onConstructComponentField", mTargetComponent, field->mFieldName);
|
||||
Con::printf("Added material field for MaterialSlot %d", i);
|
||||
|
||||
GuiInspectorField* fieldGui = materialGroup->constructField(TypeMaterialAssetPtr);
|
||||
fieldGui->init(inspector, materialGroup);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,57 +56,7 @@ namespace Compiler
|
|||
|
||||
using namespace Compiler;
|
||||
|
||||
class FuncVars
|
||||
{
|
||||
struct Var
|
||||
{
|
||||
S32 reg;
|
||||
TypeReq currentType;
|
||||
StringTableEntry name;
|
||||
bool isConstant;
|
||||
};
|
||||
|
||||
public:
|
||||
S32 assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, bool isConstant = false)
|
||||
{
|
||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||
if (found != vars.end())
|
||||
{
|
||||
AssertISV(!found->second.isConstant, avar("Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||
return found->second.reg;
|
||||
}
|
||||
|
||||
S32 id = counter++;
|
||||
vars[var] = { id, currentType, var, isConstant };
|
||||
variableNameMap[id] = var;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
S32 lookup(StringTableEntry var, S32 lineNumber)
|
||||
{
|
||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||
AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||
return found->second.reg;
|
||||
}
|
||||
|
||||
TypeReq lookupType(StringTableEntry var, S32 lineNumber)
|
||||
{
|
||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||
|
||||
AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||
return found->second.currentType;
|
||||
}
|
||||
|
||||
inline S32 count() { return counter; }
|
||||
|
||||
std::unordered_map<S32, StringTableEntry> variableNameMap;
|
||||
|
||||
private:
|
||||
std::unordered_map<StringTableEntry, Var> vars;
|
||||
S32 counter = 0;
|
||||
};
|
||||
|
||||
FuncVars gEvalFuncVars;
|
||||
FuncVars* gFuncVars = NULL;
|
||||
|
||||
inline FuncVars* getFuncVars(S32 lineNumber)
|
||||
|
|
@ -1602,7 +1552,8 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream& codeStream, U32 ip)
|
|||
tbl->add(fnName, nameSpace, varName);
|
||||
}
|
||||
|
||||
gFuncVars = NULL;
|
||||
// In eval mode, global func vars are allowed.
|
||||
gFuncVars = gIsEvalCompile ? &gEvalFuncVars : NULL;
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ CodeBlock * CodeBlock::smCodeBlockList = NULL;
|
|||
CodeBlock * CodeBlock::smCurrentCodeBlock = NULL;
|
||||
ConsoleParser *CodeBlock::smCurrentParser = NULL;
|
||||
|
||||
extern FuncVars gEvalFuncVars;
|
||||
extern FuncVars* gFuncVars;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
CodeBlock::CodeBlock()
|
||||
|
|
@ -491,6 +494,8 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
|
|||
chompUTF8BOM(inScript, &script);
|
||||
|
||||
gSyntaxError = false;
|
||||
gIsEvalCompile = false;
|
||||
gFuncVars = NULL;
|
||||
|
||||
consoleAllocReset();
|
||||
|
||||
|
|
@ -629,6 +634,11 @@ ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inStr
|
|||
addToCodeList();
|
||||
|
||||
gStatementList = NULL;
|
||||
|
||||
// we are an eval compile if we don't have a file name associated (no exec)
|
||||
gIsEvalCompile = fileName == NULL;
|
||||
// In eval mode, global func vars are allowed.
|
||||
gFuncVars = gIsEvalCompile ? &gEvalFuncVars : NULL;
|
||||
|
||||
// Set up the parser.
|
||||
smCurrentParser = getParserForFile(fileName);
|
||||
|
|
@ -667,6 +677,8 @@ ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inStr
|
|||
|
||||
codeStream.emit(OP_RETURN_VOID);
|
||||
codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs);
|
||||
|
||||
S32 localRegisterCount = gIsEvalCompile ? gEvalFuncVars.count() : 0;
|
||||
|
||||
consoleAllocReset();
|
||||
|
||||
|
|
@ -683,7 +695,8 @@ ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inStr
|
|||
if (lastIp + 1 != codeSize)
|
||||
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
|
||||
|
||||
return std::move(exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame));
|
||||
// repurpose argc as local register counter for global state
|
||||
return std::move(exec(0, fileName, NULL, localRegisterCount, 0, noCalls, NULL, setFrame));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -693,7 +693,8 @@ ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNa
|
|||
// Do we want this code to execute using a new stack frame?
|
||||
if (setFrame < 0)
|
||||
{
|
||||
gEvalState.pushFrame(NULL, NULL, 0);
|
||||
// argc is the local count for eval
|
||||
gEvalState.pushFrame(NULL, NULL, argc);
|
||||
gCallStack.pushFrame(0);
|
||||
popFrame = true;
|
||||
}
|
||||
|
|
@ -734,7 +735,7 @@ ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNa
|
|||
SimObject* curObject = NULL;
|
||||
SimObject* saveObject = NULL;
|
||||
Namespace::Entry* nsEntry;
|
||||
Namespace* ns;
|
||||
Namespace* ns = NULL;
|
||||
const char* curFNDocBlock = NULL;
|
||||
const char* curNSDocBlock = NULL;
|
||||
const S32 nsDocLength = 128;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
#include "console/simBase.h"
|
||||
|
||||
extern FuncVars gEvalFuncVars;
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
|
||||
|
|
@ -86,6 +88,7 @@ namespace Compiler
|
|||
//------------------------------------------------------------
|
||||
|
||||
bool gSyntaxError = false;
|
||||
bool gIsEvalCompile = false;
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
|
|
@ -121,6 +124,7 @@ namespace Compiler
|
|||
getFunctionStringTable().reset();
|
||||
getIdentTable().reset();
|
||||
getFunctionVariableMappingTable().reset();
|
||||
gEvalFuncVars.clear();
|
||||
}
|
||||
|
||||
void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); }
|
||||
|
|
@ -132,6 +136,44 @@ namespace Compiler
|
|||
|
||||
using namespace Compiler;
|
||||
|
||||
S32 FuncVars::assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, bool isConstant)
|
||||
{
|
||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||
if (found != vars.end())
|
||||
{
|
||||
AssertISV(!found->second.isConstant, avar("Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||
return found->second.reg;
|
||||
}
|
||||
|
||||
S32 id = counter++;
|
||||
vars[var] = { id, currentType, var, isConstant };
|
||||
variableNameMap[id] = var;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
S32 FuncVars::lookup(StringTableEntry var, S32 lineNumber)
|
||||
{
|
||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||
AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||
return found->second.reg;
|
||||
}
|
||||
|
||||
TypeReq FuncVars::lookupType(StringTableEntry var, S32 lineNumber)
|
||||
{
|
||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||
|
||||
AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||
return found->second.currentType;
|
||||
}
|
||||
|
||||
void FuncVars::clear()
|
||||
{
|
||||
vars.clear();
|
||||
variableNameMap.clear();
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -276,6 +276,35 @@ namespace Compiler
|
|||
void consoleAllocReset();
|
||||
|
||||
extern bool gSyntaxError;
|
||||
extern bool gIsEvalCompile;
|
||||
};
|
||||
|
||||
class FuncVars
|
||||
{
|
||||
struct Var
|
||||
{
|
||||
S32 reg;
|
||||
TypeReq currentType;
|
||||
StringTableEntry name;
|
||||
bool isConstant;
|
||||
};
|
||||
|
||||
public:
|
||||
S32 assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, bool isConstant = false);
|
||||
|
||||
S32 lookup(StringTableEntry var, S32 lineNumber);
|
||||
|
||||
TypeReq lookupType(StringTableEntry var, S32 lineNumber);
|
||||
|
||||
inline S32 count() { return counter; }
|
||||
|
||||
std::unordered_map<S32, StringTableEntry> variableNameMap;
|
||||
|
||||
void clear();
|
||||
|
||||
private:
|
||||
std::unordered_map<StringTableEntry, Var> vars;
|
||||
S32 counter = 0;
|
||||
};
|
||||
|
||||
/// Utility class to emit and patch bytecode
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ GFXAdapter *GFXInit::getBestAdapterChoice()
|
|||
{
|
||||
S32 adapterIdx = dAtoi(adapterDevice.c_str());
|
||||
if (adapterIdx == -1)
|
||||
adapter = chooseAdapter(adapterType, outputDevice.c_str());
|
||||
adapter = chooseAdapter(NullDevice, outputDevice.c_str());
|
||||
else
|
||||
adapter = chooseAdapter(adapterType, adapterIdx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -933,7 +933,7 @@ void GFXGLDevice::setupGenericShaders( GenericShaderType type )
|
|||
}
|
||||
GFXShader* GFXGLDevice::createShader()
|
||||
{
|
||||
GFXGLShader* shader = new GFXGLShader();
|
||||
GFXGLShader* shader = new GFXGLShader(this);
|
||||
shader->registerResourceWithDevice( this );
|
||||
return shader;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -382,10 +382,11 @@ void GFXGLShaderConstBuffer::onShaderReload( GFXGLShader *shader )
|
|||
mWasLost = true;
|
||||
}
|
||||
|
||||
GFXGLShader::GFXGLShader() :
|
||||
GFXGLShader::GFXGLShader(GFXGLDevice* device) :
|
||||
mVertexShader(0),
|
||||
mPixelShader(0),
|
||||
mProgram(0),
|
||||
mDevice(device),
|
||||
mConstBufferSize(0),
|
||||
mConstBuffer(NULL)
|
||||
{
|
||||
|
|
@ -706,7 +707,8 @@ void GFXGLShader::initHandles()
|
|||
dMemset(mConstBuffer, 0, mConstBufferSize);
|
||||
|
||||
// Set our program so uniforms are assigned properly.
|
||||
glUseProgram(mProgram);
|
||||
mDevice->setShader(this, false);
|
||||
|
||||
// Iterate through uniforms to set sampler numbers.
|
||||
for (HandleMap::Iterator iter = mHandles.begin(); iter != mHandles.end(); ++iter)
|
||||
{
|
||||
|
|
@ -723,7 +725,6 @@ void GFXGLShader::initHandles()
|
|||
dMemcpy(mConstBuffer + handle->mOffset, &handle->mSamplerNum, handle->getSize());
|
||||
}
|
||||
}
|
||||
glUseProgram(0);
|
||||
|
||||
//instancing
|
||||
if (!mInstancingFormat)
|
||||
|
|
@ -830,6 +831,7 @@ void GFXGLShader::setConstantsFromBuffer(GFXGLShaderConstBuffer* buffer)
|
|||
|
||||
// Copy new value into our const buffer and set in GL.
|
||||
dMemcpy(mConstBuffer + handle->mOffset, buffer->mBuffer + handle->mOffset, handle->getSize());
|
||||
|
||||
switch(handle->mDesc.constType)
|
||||
{
|
||||
case GFXSCT_Float:
|
||||
|
|
|
|||
|
|
@ -32,14 +32,15 @@
|
|||
class GFXGLShaderConstHandle;
|
||||
class FileStream;
|
||||
class GFXGLShaderConstBuffer;
|
||||
class GFXGLDevice;
|
||||
|
||||
class GFXGLShader : public GFXShader
|
||||
{
|
||||
typedef Map<String, GFXGLShaderConstHandle*> HandleMap;
|
||||
public:
|
||||
GFXGLShader();
|
||||
GFXGLShader(GFXGLDevice* device);
|
||||
virtual ~GFXGLShader();
|
||||
|
||||
|
||||
/// @name GFXShader interface
|
||||
/// @{
|
||||
virtual GFXShaderConstHandle* getShaderConstHandle(const String& name);
|
||||
|
|
@ -99,6 +100,7 @@ protected:
|
|||
U32 mConstBufferSize;
|
||||
U8* mConstBuffer;
|
||||
HandleMap mHandles;
|
||||
GFXGLDevice* mDevice;
|
||||
Vector<GFXGLShaderConstHandle*> mValidHandles;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -258,17 +258,19 @@ bool GuiCanvas::onAdd()
|
|||
// Make sure we're able to render.
|
||||
newDevice->setAllowRender( true );
|
||||
|
||||
if(mDisplayWindow)
|
||||
// NULL device returns a nullptr for getPlatformWindow
|
||||
PlatformWindow* window = getPlatformWindow();
|
||||
if (mDisplayWindow && window)
|
||||
{
|
||||
getPlatformWindow()->show();
|
||||
window->show();
|
||||
WindowManager->setDisplayWindow(true);
|
||||
getPlatformWindow()->setDisplayWindow(true);
|
||||
window->setDisplayWindow(true);
|
||||
}
|
||||
else
|
||||
else if (window)
|
||||
{
|
||||
getPlatformWindow()->hide();
|
||||
window->hide();
|
||||
WindowManager->setDisplayWindow(false);
|
||||
getPlatformWindow()->setDisplayWindow(false);
|
||||
window->setDisplayWindow(false);
|
||||
}
|
||||
|
||||
// Propagate add to parents.
|
||||
|
|
|
|||
|
|
@ -1993,12 +1993,12 @@ void WorldEditor::on3DMouseMove(const Gui3DMouseEvent & event)
|
|||
if ( !mHitObject )
|
||||
{
|
||||
SceneObject *hitObj = NULL;
|
||||
if ( collide(event, &hitObj) && hitObj->isSelectionEnabled() && !objClassIgnored(hitObj) )
|
||||
if ( collide(event, &hitObj) && !hitObj->isDeleted() && hitObj->isSelectionEnabled() && !objClassIgnored(hitObj) )
|
||||
{
|
||||
mHitObject = hitObj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mLastMouseEvent = event;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ StdConsole *stdConsole = NULL;
|
|||
DefineEngineFunction(enableWinConsole, void, (bool _enable),, "enableWinConsole(bool);")
|
||||
{
|
||||
if (stdConsole)
|
||||
stdConsole->enable(_enable);
|
||||
{
|
||||
stdConsole->enable(_enable);
|
||||
stdConsole->enableInput(_enable);
|
||||
}
|
||||
}
|
||||
|
||||
void StdConsole::create()
|
||||
|
|
@ -141,6 +144,9 @@ StdConsole::StdConsole()
|
|||
stdIn = dup(0);
|
||||
stdErr = dup(2);
|
||||
|
||||
// Ensure in buffer is null terminated after allocation
|
||||
inbuf[0] = 0x00;
|
||||
|
||||
iCmdIndex = 0;
|
||||
stdConsoleEnabled = false;
|
||||
stdConsoleInputEnabled = false;
|
||||
|
|
@ -195,11 +201,14 @@ void StdConsole::processConsoleLine(const char *consoleLine)
|
|||
{
|
||||
if(stdConsoleEnabled)
|
||||
{
|
||||
inbuf[inpos] = 0;
|
||||
if(lineOutput)
|
||||
printf("%s\n", consoleLine);
|
||||
else
|
||||
printf("%c%s\n%s%s", '\r', consoleLine, Con::getVariable("Con::Prompt"), inbuf);
|
||||
{
|
||||
// Clear current line before outputting the console line. This prevents prompt text from overflowing onto normal output.
|
||||
printf("%c[2K", 27);
|
||||
printf("%c%s\n%s%s", '\r', consoleLine, Con::getVariable("Con::Prompt"), inbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -323,6 +332,7 @@ void StdConsole::process()
|
|||
|
||||
printf("%s", Con::getVariable("Con::Prompt"));
|
||||
inpos = outpos = 0;
|
||||
inbuf[0] = 0x00; // Ensure inbuf is NULL terminated after sending out command
|
||||
break;
|
||||
case 27:
|
||||
// JMQTODO: are these magic numbers keyboard map specific?
|
||||
|
|
|
|||
|
|
@ -1613,3 +1613,15 @@ void TerrainBlock::deleteZodiacPrimitiveBuffer()
|
|||
}
|
||||
}
|
||||
|
||||
DefineEngineMethod(TerrainBlock, getTerrain, String, (), , "Returns the terrain file used for this terrain block, either via the asset or the filename assigned, which ever is valid")
|
||||
{
|
||||
return object->getTerrain();
|
||||
}
|
||||
DefineEngineMethod(TerrainBlock, getTerrainAsset, String, (), , "Returns the assetId used for this terrain block")
|
||||
{
|
||||
return object->getTerrainAssetId();
|
||||
}
|
||||
DefineEngineMethod(TerrainBlock, setTerrain, bool, (const char* terrain), , "Terrain assignment.first tries asset then flat file.")
|
||||
{
|
||||
return object->_setTerrain(StringTable->insert(terrain));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -488,6 +488,39 @@ public:
|
|||
void inspectPostApply();
|
||||
|
||||
virtual void getUtilizedAssets(Vector<StringTableEntry>* usedAssetsList);
|
||||
|
||||
const StringTableEntry getTerrain() const
|
||||
{
|
||||
if (mTerrainAsset && (mTerrainAsset->getTerrainFilePath() != StringTable->EmptyString()))
|
||||
return mTerrainAsset->getTerrainFilePath();
|
||||
else if (mTerrainAssetId != StringTable->EmptyString())
|
||||
return mTerrainAssetId;
|
||||
else if (mTerrFileName != StringTable->EmptyString())
|
||||
return mTerrFileName;
|
||||
else
|
||||
return StringTable->EmptyString();
|
||||
}
|
||||
|
||||
const StringTableEntry getTerrainAssetId() const
|
||||
{
|
||||
if (mTerrainAssetId != StringTable->EmptyString())
|
||||
return mTerrainAssetId;
|
||||
else
|
||||
return StringTable->EmptyString();
|
||||
}
|
||||
|
||||
bool _setTerrain(StringTableEntry terrain)
|
||||
{
|
||||
if (terrain == StringTable->EmptyString())
|
||||
return false;
|
||||
|
||||
if (AssetDatabase.isDeclaredAsset(terrain))
|
||||
setTerrainAsset(terrain);
|
||||
else
|
||||
mTerrFileName = terrain;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool mUpdateBasetex;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue