Merge pull request #1541 from Areloch/MiscFixes_20250825

Misc small fixes, improvements and QoL tweaks
This commit is contained in:
Brian Roberts 2025-08-26 01:43:57 -05:00 committed by GitHub
commit e73efc13c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 728 additions and 346 deletions

View file

@ -599,20 +599,42 @@ void GuiInspectorTypeMaterialAssetPtr::updateValue()
void GuiInspectorTypeMaterialAssetPtr::updatePreviewImage()
{
const char* previewImage;
const char* matAssetId;
if (mInspector->getInspectObject() != nullptr)
previewImage = mInspector->getInspectObject()->getDataField(mCaption, NULL);
matAssetId = mInspector->getInspectObject()->getDataField(mCaption, NULL);
else
previewImage = Con::getVariable(mVariableName);
matAssetId = Con::getVariable(mVariableName);
//if what we're working with isn't even a valid asset, don't present like we found a good one
if (!AssetDatabase.isDeclaredAsset(previewImage))
if (!AssetDatabase.isDeclaredAsset(matAssetId))
{
mPreviewImage->_setBitmap(StringTable->EmptyString());
mPreviewImage->_setBitmap(StringTable->insert("Core_Rendering:NoMaterial"));
return;
}
String matPreviewAssetId = String(previewImage) + "_PreviewImage";
AssetPtr<MaterialAsset> matAssetDef = matAssetId;
if (matAssetDef.isNull() || matAssetDef->getStatus() != AssetBase::AssetErrCode::Ok ||
matAssetDef->getMaterialDefinitionName() == StringTable->EmptyString())
{
mPreviewImage->_setBitmap(StringTable->insert("Core_Rendering:WarningMaterial"));
return;
}
Material* matDef;
if (!Sim::findObject(matAssetDef->getMaterialDefinitionName(), matDef))
{
mPreviewImage->_setBitmap(StringTable->insert("Core_Rendering:WarningMaterial"));
return;
}
AssetPtr<ImageAsset> difMapAsset = matDef->getDiffuseMapAsset(0);
if (difMapAsset.isNull() || difMapAsset->getStatus() != AssetBase::AssetErrCode::Ok)
{
mPreviewImage->_setBitmap(StringTable->insert("Core_Rendering:WarningMaterial"));
return;
}
String matPreviewAssetId = String(difMapAsset->getAssetName()) + "_PreviewImage";
matPreviewAssetId.replace(":", "_");
matPreviewAssetId = "ToolsModule:" + matPreviewAssetId;
if (AssetDatabase.isDeclaredAsset(matPreviewAssetId.c_str()))
@ -621,18 +643,14 @@ void GuiInspectorTypeMaterialAssetPtr::updatePreviewImage()
}
else
{
if (AssetDatabase.isDeclaredAsset(previewImage))
if (AssetDatabase.isDeclaredAsset(difMapAsset->getAssetId()))
{
MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(previewImage);
if (matAsset && matAsset->getMaterialDefinition())
{
mPreviewImage->_setBitmap(matAsset->getMaterialDefinition()->_getDiffuseMap(0));
}
mPreviewImage->setBitmap(difMapAsset->getAssetId());
}
}
if (mPreviewImage->getBitmapAsset().isNull())
mPreviewImage->_setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image"));
mPreviewImage->setBitmap(StringTable->insert("ToolsModule:genericAssetIcon_image"));
}
void GuiInspectorTypeMaterialAssetPtr::setPreviewImage(StringTableEntry assetId)

View file

@ -360,7 +360,7 @@ public:
#define INITPERSISTFIELD_SHAPEASSET_REFACTOR(name, consoleClass, docs) \
addProtectedField(assetText(name, Asset), TypeShapeAssetPtr, Offset(m##name##Asset, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.)); \
addProtectedField(assetText(name, File), TypeFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, file docs.));
addProtectedField(assetText(name, File), TypeFilename, Offset(m##name##File, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, file docs.), AbstractClassRep::FIELD_HideInInspectors);
#define DECLARE_SHAPEASSET_ARRAY_REFACTOR(className, name, max) \

View file

@ -400,7 +400,7 @@ bool TSStatic::_createShape()
mObjBox = getShape()->mBounds;
resetWorldBox();
mShapeInstance = new TSShapeInstance(getShape(), isClientObject());
mShapeInstance = new TSShapeInstance(getShape(), true);
mShapeInstance->resetMaterialList();
mShapeInstance->cloneMaterialList();
@ -711,7 +711,7 @@ void TSStatic::_updateShouldTick()
void TSStatic::prepRenderImage(SceneRenderState* state)
{
if (!mShapeInstance)
if (!mShapeAsset.isValid() || !mShapeInstance)
return;
Point3F cameraOffset;
@ -1326,27 +1326,25 @@ bool TSStatic::buildExportPolyList(ColladaUtils::ExportData* exportData, const B
}
//Next, process the LOD levels and materials.
if (isServerObject() && getClientObject())
if (isServerObject())
{
TSStatic* clientShape = dynamic_cast<TSStatic*>(getClientObject());
exportData->meshData.increment();
//Prep a meshData for this shape in particular
ColladaUtils::ExportData::meshLODData* meshData = &exportData->meshData.last();
//Fill out the info we'll need later to actually append our mesh data for the detail levels during the processing phase
meshData->shapeInst = clientShape->mShapeInstance;
meshData->shapeInst = mShapeInstance;
meshData->originatingObject = this;
meshData->meshTransform = mObjToWorld;
meshData->scale = mObjScale;
//Iterate over all our detail levels
for (U32 i = 0; i < clientShape->mShapeInstance->getNumDetails(); i++)
for (U32 i = 0; i < mShapeInstance->getNumDetails(); i++)
{
TSShape::Detail detail = clientShape->mShapeInstance->getShape()->details[i];
TSShape::Detail detail = mShapeInstance->getShape()->details[i];
String detailName = String::ToLower(clientShape->mShapeInstance->getShape()->getName(detail.nameIndex));
String detailName = String::ToLower(mShapeInstance->getShape()->getName(detail.nameIndex));
//Skip it if it's a collision or line of sight element
if (detailName.startsWith("col") || detailName.startsWith("los"))