Merge remote-tracking branch 'main/Preview4_0' into bugfix-msvc-compiler-warnings

This commit is contained in:
Robert MacGregor 2021-10-11 19:36:52 -04:00
commit aba091a97a
22 changed files with 315 additions and 275 deletions

View file

@ -167,6 +167,12 @@ void MaterialAsset::initializeAsset()
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
if (mMatDefinitionName == StringTable->EmptyString())
{
mLoadedState = Failed;
return;
}
if (Torque::FS::IsScriptFile(mScriptPath))
{
if (!Sim::findObject(mMatDefinitionName))
@ -180,6 +186,10 @@ void MaterialAsset::initializeAsset()
mLoadedState = Failed;
}
}
else
{
mLoadedState = DefinitionAlreadyExists;
}
}
loadMaterial();
@ -189,6 +199,12 @@ void MaterialAsset::onAssetRefresh()
{
mScriptPath = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptPath;
if (mMatDefinitionName == StringTable->EmptyString())
{
mLoadedState = Failed;
return;
}
if (Torque::FS::IsScriptFile(mScriptPath))
{
//Since we're refreshing, we can assume that the file we're executing WILL have an existing definition.
@ -204,7 +220,6 @@ void MaterialAsset::onAssetRefresh()
//And now that we've executed, switch back to the prior behavior
Con::setVariable("$Con::redefineBehavior", redefineBehaviorPrev.c_str());
}
loadMaterial();
@ -232,7 +247,7 @@ void MaterialAsset::loadMaterial()
if (mMaterialDefinition)
SAFE_DELETE(mMaterialDefinition);
if (mLoadedState == ScriptLoaded && mMatDefinitionName != StringTable->EmptyString())
if ((mLoadedState == ScriptLoaded || mLoadedState == DefinitionAlreadyExists) && mMatDefinitionName != StringTable->EmptyString())
{
Material* matDef;
if (!Sim::findObject(mMatDefinitionName, matDef))

View file

@ -73,6 +73,7 @@ public:
enum MaterialAssetErrCode
{
ScriptLoaded = AssetErrCode::Extended,
DefinitionAlreadyExists,
Extended
};

View file

@ -1908,50 +1908,21 @@ void ParticleEmitter::copyToVB( const Point3F &camPos, const LinearColorF &ambie
if (mDataBlock->reverseOrder)
{
buffPtr += 4 * (n_parts - 1);
// do sorted-oriented particles
if (mDataBlock->sortParticles)
{
SortParticle* partPtr = orderedVector.address();
for (U32 i = 0; i < n_parts - 1; i++, partPtr++, buffPtr -= 4)
{
SortParticle* part = partPtr;
partPtr++;
setupRibbon(part->p, partPtr->p, partPtr->p, camPos, ambientColor, buffPtr);
}
}
// do unsorted-oriented particles
else
{
Particle* oldPtr = NULL;
for (Particle* partPtr = part_list_head.next; partPtr != NULL; partPtr = partPtr->next, buffPtr -= 4) {
for (Particle* partPtr = part_list_head.next; partPtr != NULL; partPtr = partPtr->next, buffPtr -= 4)
{
setupRibbon(partPtr, partPtr->next, oldPtr, camPos, ambientColor, buffPtr);
oldPtr = partPtr;
}
}
}
else
{
// do sorted-oriented particles
if (mDataBlock->sortParticles)
{
SortParticle* partPtr = orderedVector.address();
for (U32 i = 0; i < n_parts - 1; i++, partPtr++, buffPtr += 4)
{
SortParticle* part = partPtr;
partPtr++;
setupRibbon(part->p, partPtr->p, partPtr->p, camPos, ambientColor, buffPtr);
}
}
// do unsorted-oriented particles
else
{
Particle* oldPtr = NULL;
for (Particle* partPtr = part_list_head.next; partPtr != NULL; partPtr = partPtr->next, buffPtr += 4) {
for (Particle* partPtr = part_list_head.next; partPtr != NULL; partPtr = partPtr->next, buffPtr += 4)
{
setupRibbon(partPtr, partPtr->next, oldPtr, camPos, ambientColor, buffPtr);
oldPtr = partPtr;
}
}
}
PROFILE_END();
}