Corrected profile for GameObjectAsset type field button

Initial implementation of changeable TSStatic materials via material slots and drag and drop of material assets onto world editor from AB
Updated Volumetric Fog to support ShapeAsset for it's model data
Added cmake option to hide literal filename fields if the class supports asset fields for the same input
Added light viz modes to see diffuse, specular and detail lighting modes(currently just sun)
New raycast console function to return back material of hit object
Moved GameObject logic to SceneObject and started fixing up of editor behavior to allow any SceneObject to be converted into a GO, along with all supported behavior such as instance-template management and spawning GO via drag-and-drop from AB
Fixed inspector field tooltip text to be positioned in inspector footer properly again
Drag and drop of shape asset attempts to drop at raycast position now, instead of just at the camera ray position
This commit is contained in:
Areloch 2019-12-05 20:42:47 -06:00
parent 551df5e92a
commit 09c651c26d
25 changed files with 572 additions and 35 deletions

View file

@ -171,8 +171,10 @@ void TSStatic::initPersistFields()
&TSStatic::_setShapeAsset, &defaultProtectedGetFn,
"The source shape asset.");
#ifdef TORQUE_ALLOW_DIRECT_FILENAMES
addField("shapeName", TypeShapeFilename, Offset( mShapeName, TSStatic ),
"%Path and filename of the model file (.DTS, .DAE) to use for this TSStatic." );
#endif
addProtectedField( "skin", TypeRealString, Offset( mAppliedSkinName, TSStatic ), &_setFieldSkin, &_getFieldSkin,
"@brief The skin applied to the shape.\n\n"
@ -289,7 +291,7 @@ void TSStatic::inspectPostApply()
if(isServerObject())
{
setMaskBits(AdvancedStaticOptionsMask);
setMaskBits(-1);
prepCollision();
}
@ -463,9 +465,74 @@ bool TSStatic::_createShape()
Sim::findObject( cubeDescId, reflectorDesc );
}
//Set up the material slot vars for easy manipulation
S32 materialCount = mShape->materialList->getMaterialNameList().size(); //mMeshAsset->getMaterialCount();
if (isServerObject())
{
char matFieldName[128];
for (U32 i = 0; i < materialCount; i++)
{
StringTableEntry materialname = StringTable->insert(mShape->materialList->getMaterialName(i).c_str());
dSprintf(matFieldName, 128, "MaterialSlot%d", i);
StringTableEntry matFld = StringTable->insert(matFieldName);
setDataField(matFld, NULL, materialname);
}
}
return true;
}
void TSStatic::onDynamicModified(const char* slotName, const char* newValue)
{
bool isSrv = isServerObject();
if (FindMatch::isMatch("materialslot*", slotName, false))
{
if (!getShape())
return;
S32 slot = -1;
String outStr(String::GetTrailingNumber(slotName, slot));
if (slot == -1)
return;
//Safe to assume the inbound value for the material will be a MaterialAsset, so lets do a lookup on the name
MaterialAsset* matAsset = AssetDatabase.acquireAsset<MaterialAsset>(newValue);
if (!matAsset)
return;
bool found = false;
for (U32 i = 0; i < mChangingMaterials.size(); i++)
{
if (mChangingMaterials[i].slot == slot)
{
mChangingMaterials[i].matAsset = matAsset;
mChangingMaterials[i].assetId = newValue;
found = true;
}
}
if (!found)
{
matMap newMatMap;
newMatMap.slot = slot;
newMatMap.matAsset = matAsset;
newMatMap.assetId = newValue;
mChangingMaterials.push_back(newMatMap);
}
setMaskBits(MaterialMask);
}
Parent::onDynamicModified(slotName, newValue);
}
void TSStatic::prepCollision()
{
// Let the client know that the collision was updated
@ -918,6 +985,22 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
}
stream->write(mOverrideColor);
if (stream->writeFlag(mask & MaterialMask))
{
stream->writeInt(mChangingMaterials.size(), 16);
for (U32 i = 0; i < mChangingMaterials.size(); i++)
{
stream->writeInt(mChangingMaterials[i].slot, 16);
NetStringHandle matNameStr = mChangingMaterials[i].assetId.c_str();
con->packNetStringHandleU(stream, matNameStr);
}
mChangingMaterials.clear();
}
return retMask;
}
@ -1019,6 +1102,26 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream)
stream->read(&mOverrideColor);
if (stream->readFlag())
{
mChangingMaterials.clear();
U32 materialCount = stream->readInt(16);
for (U32 i = 0; i < materialCount; i++)
{
matMap newMatMap;
newMatMap.slot = stream->readInt(16);
newMatMap.assetId = String(con->unpackNetStringHandleU(stream).getString());
//do the lookup, now
newMatMap.matAsset = AssetDatabase.acquireAsset<MaterialAsset>(newMatMap.assetId);
mChangingMaterials.push_back(newMatMap);
}
updateMaterials();
}
if ( isProperlyAdded() )
_updateShouldTick();
set_special_typing();
@ -1458,6 +1561,46 @@ U32 TSStatic::getNumDetails()
return 0;
};
void TSStatic::updateMaterials()
{
if (mChangingMaterials.empty() || !mShape)
return;
TSMaterialList* pMatList = mShapeInstance->getMaterialList();
String path;
if (mShapeAsset->isAssetValid())
path = mShapeAsset->getShapeFilename();
else
path = mShapeName;
pMatList->setTextureLookupPath(path);
bool found = false;
const Vector<String>& materialNames = pMatList->getMaterialNameList();
for (S32 i = 0; i < materialNames.size(); i++)
{
if (found)
break;
for (U32 m = 0; m < mChangingMaterials.size(); m++)
{
if (mChangingMaterials[m].slot == i)
{
//Fetch the actual material asset
pMatList->renameMaterial(i, mChangingMaterials[m].matAsset->getMaterialDefinitionName());
found = true;
break;
}
}
}
mChangingMaterials.clear();
// Initialize the material instances
mShapeInstance->initMaterialList();
}
//------------------------------------------------------------------------
//These functions are duplicated in tsStatic and shapeBase.
//They each function a little differently; but achieve the same purpose of gathering