Merge branch 'TorqueGameEngines:development' into Sir-Skurpsalot-player_fixes_&_tweaks

This commit is contained in:
Sir-Skurpsalot 2026-05-02 19:14:04 -06:00 committed by GitHub
commit 80eaaff7fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 2723 additions and 2305 deletions

View file

@ -186,6 +186,13 @@ void LevelAsset::loadAsset()
{
// Ensure the image-file is expanded.
mLevelPath = getOwned() ? expandAssetFilePath(mLevelFile) : mLevelPath;
if (mLevelPath == StringTable->EmptyString())
{
mLoadedState = AssetErrCode::BadFileReference;
return;
}
mPostFXPresetPath = getOwned() ? expandAssetFilePath(mPostFXPresetFile) : mPostFXPresetPath;
mDecalsPath = getOwned() ? expandAssetFilePath(mDecalsFile) : mDecalsPath;
mForestPath = getOwned() ? expandAssetFilePath(mForestFile) : mForestPath;
@ -198,6 +205,8 @@ void LevelAsset::loadAsset()
mPreviewImageAssetId = previewImageAssetId;
mPreviewImageAsset = mPreviewImageAssetId;
}
mLoadedState = AssetErrCode::Ok;
}
//
@ -248,7 +257,7 @@ void LevelAsset::setEditorFile(const char* pEditorFile)
return;
// Update.
mEditorFile = getOwned() ? expandAssetFilePath(pEditorFile) : pEditorFile;
mEditorFile = pEditorFile;
// Refresh the asset.
refreshAsset();
@ -267,7 +276,7 @@ void LevelAsset::setBakedSceneFile(const char* pBakedSceneFile)
return;
// Update.
mBakedSceneFile = getOwned() ? expandAssetFilePath(pBakedSceneFile) : pBakedSceneFile;
mBakedSceneFile = pBakedSceneFile;
// Refresh the asset.
refreshAsset();
@ -286,7 +295,7 @@ void LevelAsset::setPostFXPresetFile(const char* pPostFXPresetFile)
return;
// Update.
mPostFXPresetFile = getOwned() ? expandAssetFilePath(pPostFXPresetFile) : pPostFXPresetFile;
mPostFXPresetFile = pPostFXPresetFile;
// Refresh the asset.
refreshAsset();
@ -305,7 +314,7 @@ void LevelAsset::setDecalsFile(const char* pDecalsFile)
return;
// Update.
mDecalsFile = getOwned() ? expandAssetFilePath(pDecalsFile) : pDecalsFile;
mDecalsFile = pDecalsFile;
// Refresh the asset.
refreshAsset();
@ -324,7 +333,7 @@ void LevelAsset::setForestFile(const char* pForestFile)
return;
// Update.
mForestFile = getOwned() ? expandAssetFilePath(pForestFile) : pForestFile;
mForestFile = pForestFile;
// Refresh the asset.
refreshAsset();
@ -343,7 +352,7 @@ void LevelAsset::setNavmeshFile(const char* pNavmeshFile)
return;
// Update.
mNavmeshFile = getOwned() ? expandAssetFilePath(pNavmeshFile) : pNavmeshFile;
mNavmeshFile = pNavmeshFile;
// Refresh the asset.
refreshAsset();
@ -398,35 +407,88 @@ DefineEngineMethod(LevelAsset, getPreviewImagePath, const char*, (), ,
"Gets the full path of the asset's defined preview image file.\n"
"@return The string result of the level preview image path")
{
return object->getPreviewImagePath();
String previewPath = object->getPreviewImagePath();
if (previewPath.isEmpty() || !Torque::FS::IsFile(previewPath))
{
Torque::Path levelPath = object->getLevelPath();
previewPath = String(levelPath.getPath() + "/" + levelPath.getFileName()) + ".png";
}
char* returnBuffer = Con::getReturnBuffer(previewPath.size());
dSprintf(returnBuffer, 256, "%s", previewPath.c_str());
return returnBuffer;
}
DefineEngineMethod(LevelAsset, getPostFXPresetPath, const char*, (), ,
"Gets the full path of the asset's defined postFX preset file.\n"
"@return The string result of the postFX preset path")
{
return object->getPostFXPresetPath();
String pfxPath = object->getPostFXPresetPath();
if (pfxPath.isEmpty() || !Torque::FS::IsFile(pfxPath))
{
Torque::Path levelPath = object->getLevelPath();
pfxPath = String(levelPath.getPath() + "/" + levelPath.getFileName()) + ".postfxpreset.tscript";
}
char* returnBuffer = Con::getReturnBuffer(pfxPath.size());
dSprintf(returnBuffer, 256, "%s", pfxPath.c_str());
return returnBuffer;
}
DefineEngineMethod(LevelAsset, getDecalsPath, const char*, (), ,
"Gets the full path of the asset's defined decal file.\n"
"@return The string result of the decal path")
{
return object->getDecalsPath();
String decalPath = object->getDecalsPath();
if (decalPath.isEmpty() || !Torque::FS::IsFile(decalPath))
{
Torque::Path levelPath = object->getLevelPath();
decalPath = String(levelPath.getPath() + levelPath.getFileName()) + ".decals";
if (!Torque::FS::IsFile(decalPath)) //Legacy pattern support if it kept the '.mis' sub extension in there
decalPath = String(levelPath.getFullPath()) + ".decals";
}
char* returnBuffer = Con::getReturnBuffer(decalPath.size());
dSprintf(returnBuffer, 256, "%s", decalPath.c_str());
return returnBuffer;
}
DefineEngineMethod(LevelAsset, getForestPath, const char*, (), ,
"Gets the full path of the asset's defined forest file.\n"
"@return The string result of the forest path")
{
return object->getForestPath();
String forestPath = object->getForestPath();
if (forestPath.isEmpty() || !Torque::FS::IsFile(forestPath))
{
Torque::Path levelPath = object->getLevelPath();
forestPath = String(levelPath.getPath() + "/" + levelPath.getFileName()) + ".forest";
}
char* returnBuffer = Con::getReturnBuffer(forestPath.size());
dSprintf(returnBuffer, 256, "%s", forestPath.c_str());
return returnBuffer;
}
DefineEngineMethod(LevelAsset, getNavmeshPath, const char*, (), ,
"Gets the full path of the asset's defined navmesh file.\n"
"@return The string result of the navmesh path")
{
return object->getNavmeshPath();
String navPath = object->getNavmeshPath();
if (navPath.isEmpty() || !Torque::FS::IsFile(navPath))
{
Torque::Path levelPath = object->getLevelPath();
navPath = String(levelPath.getPath() + "/" + levelPath.getFileName()) + ".nav";
}
char* returnBuffer = Con::getReturnBuffer(navPath.size());
dSprintf(returnBuffer, 256, "%s", navPath.c_str());
return returnBuffer;
}
DefineEngineMethod(LevelAsset, loadDependencies, void, (), ,

View file

@ -238,6 +238,11 @@ void AssetImportConfig::initPersistFields()
void AssetImportConfig::loadImportConfig(Settings* configSettings, String configName)
{
if (!configSettings)
{
Con::errorf("AssetImportConfig::loadImportConfig - No config settings!");
return;
}
//General
DuplicateAutoResolution = configSettings->value(String(configName + "/General/DuplicateAutoResolution").c_str());
WarningsAsErrors = dAtob(configSettings->value(String(configName + "/General/WarningsAsErrors").c_str()));

View file

@ -1457,7 +1457,7 @@ bool DecalManager::_createDataFile()
if(dot)
*dot = '\0';
dSprintf( fileName, sizeof(fileName), "%s.mis.decals", missionName );
dSprintf( fileName, sizeof(fileName), "%s.decals", missionName );
mDataFileName = StringTable->insert( fileName );
@ -1572,8 +1572,8 @@ DefineEngineFunction( decalManagerSave, void, ( String decalSaveFile ), ( "" ),
"@param decalSaveFile Filename to save the decals to.\n"
"@tsexample\n"
"// Set the filename to save the decals in. If no filename is set, then the\n"
"// decals will default to <activeMissionName>.mis.decals\n"
"%fileName = \"./missionDecals.mis.decals\";\n"
"// decals will default to <activeMissionName>.decals\n"
"%fileName = \"./missionDecals.decals\";\n"
"// Inform the decal manager to save the decals for the active mission.\n"
"decalManagerSave( %fileName );\n"
"@endtsexample\n"
@ -1603,7 +1603,7 @@ DefineEngineFunction( decalManagerLoad, bool, ( const char* fileName ),,
"false if it could not.\n"
"@tsexample\n"
"// Set the filename to load the decals from.\n"
"%fileName = \"./missionDecals.mis.decals\";\n"
"%fileName = \"./missionDecals.decals\";\n"
"// Inform the decal manager to load the decals from the entered filename.\n"
"decalManagerLoad( %fileName );\n"
"@endtsexample\n"

View file

@ -907,6 +907,9 @@ GuiControl* GuiInspectorTypeParticleDataList::constructEditControl()
mNewParticleBtn->registerObject();
mNewParticleBtn->_setBitmap(StringTable->insert("ToolsModule:iconAdd_image"));
mNewParticleBtn->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiDefaultProfile");
mNewParticleBtn->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
mNewParticleBtn->setDataField(StringTable->insert("hovertime"), NULL, "1000");
mNewParticleBtn->setDataField(StringTable->insert("tooltip"), NULL, "Add new particle slot");
mNewParticleBtn->setHorizSizing(horizResizeRight);
mNewParticleBtn->mMakeIconSquare = true;
mNewParticleBtn->mFitBitmapToButton = true;
@ -914,7 +917,7 @@ GuiControl* GuiInspectorTypeParticleDataList::constructEditControl()
char szBuffer[512];
dSprintf(szBuffer, sizeof(szBuffer), "ParticleEditor.addParticleSlot(%s, %s);",
mNewParticleBtn->getIdString(), mInspector->getInspectObject()->getIdString());
this->getIdString(), mInspector->getInspectObject()->getIdString());
mNewParticleBtn->setField("Command", szBuffer);
GuiContainer* newBtnCtnr = new GuiContainer();
@ -924,39 +927,16 @@ GuiControl* GuiInspectorTypeParticleDataList::constructEditControl()
mStack->addObject(newBtnCtnr);
//Particle 0
mParticleSlot0Ctrl = _buildParticleEntryField(0);
mStack->addObject(mParticleSlot0Ctrl);
//Now the non-default entries if we already have some
Parent::updateValue();
const char* data = getData();
if (data != NULL && !String::isEmpty(data))
{
U32 particlesCount = StringUnit::getUnitCount(data, " ");
for (U32 i=1; i < particlesCount; i++)
{
GuiControl* particleSlotCtrl = _buildParticleEntryField(i);
mStack->addObject(particleSlotCtrl);
}
}
_rebuildParticleEntryList();
_registerEditControl(mStack);
//constructEditControlChildren(retCtrl, getWidth());
//retCtrl->addObject(mScriptValue);
/*char szBuffer[512];
dSprintf(szBuffer, 512, "setClipboard(%d.getText());", mScriptValue->getId());
mCopyButton->setField("Command", szBuffer);
addObject(mCopyButton);*/
mUseHeightOverride = true;
mHeightOverride = (mStack->getCount() * 23) + 6;
//Now the non-default entries if we already have some
//Parent::updateValue();
return mStack;
}
@ -980,7 +960,7 @@ GuiControl* GuiInspectorTypeParticleDataList::_buildParticleEntryField(const S32
char szBuffer[512];
dSprintf(szBuffer, sizeof(szBuffer), "ParticleEditor.changeParticleSlot(%s, %s, %d);",
listBtn->getIdString(), mInspector->getInspectObject()->getIdString(), index);
this->getIdString(), mInspector->getInspectObject()->getIdString(), index);
listBtn->setField("Command", szBuffer);
if (mField && index != -1)
@ -1001,6 +981,9 @@ GuiControl* GuiInspectorTypeParticleDataList::_buildParticleEntryField(const S32
editSlotBtn->registerObject();
editSlotBtn->setText(StringTable->insert("..."));
editSlotBtn->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiButtonProfile");
editSlotBtn->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
editSlotBtn->setDataField(StringTable->insert("hovertime"), NULL, "1000");
editSlotBtn->setDataField(StringTable->insert("tooltip"), NULL, "Edit this particle");
editSlotBtn->setHorizSizing(horizResizeRight);
editSlotBtn->setInternalName("editBtn");
editSlotBtn->setPosition(editExtent.x - 40, 0);
@ -1019,6 +1002,9 @@ GuiControl* GuiInspectorTypeParticleDataList::_buildParticleEntryField(const S32
deleteSlotBtn->registerObject();
deleteSlotBtn->_setBitmap(StringTable->insert("ToolsModule:iconCancel_image"));
deleteSlotBtn->setDataField(StringTable->insert("profile"), NULL, "ToolsGuiDefaultProfile");
deleteSlotBtn->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
deleteSlotBtn->setDataField(StringTable->insert("hovertime"), NULL, "1000");
deleteSlotBtn->setDataField(StringTable->insert("tooltip"), NULL, "Delete this particle slot");
deleteSlotBtn->setHorizSizing(horizResizeRight);
deleteSlotBtn->setInternalName("deleteBtn");
deleteSlotBtn->mMakeIconSquare = true;
@ -1062,6 +1048,38 @@ void GuiInspectorTypeParticleDataList::_populateMenu(GuiPopUpMenuCtrlEx* menu)
menu->sort();
}
void GuiInspectorTypeParticleDataList::_rebuildParticleEntryList()
{
const char* data = getData();
//whoops it's misaligned, force a rebuild
mParticleSlot0Ctrl = NULL;
for (U32 i = 0; i < mParticleSlotList.size(); i++)
{
mStack->removeObject(mParticleSlotList[i]);
mParticleSlotList[i]->deleteObject();
}
mParticleSlotList.clear();
//Particle 0
mParticleSlot0Ctrl = _buildParticleEntryField(0);
mStack->addObject(mParticleSlot0Ctrl);
mParticleSlotList.push_back(mParticleSlot0Ctrl);
if (data != NULL && !String::isEmpty(data))
{
U32 particlesCount = StringUnit::getUnitCount(data, " ");
for (U32 i = 1; i < particlesCount; i++)
{
GuiControl* particleSlotCtrl = _buildParticleEntryField(i);
mStack->addObject(particleSlotCtrl);
mParticleSlotList.push_back(particleSlotCtrl);
}
}
}
bool GuiInspectorTypeParticleDataList::updateRects()
{
S32 rowSize = 18;
@ -1109,14 +1127,43 @@ bool GuiInspectorTypeParticleDataList::updateRects()
mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
mUseHeightOverride = true;
mHeightOverride = (mStack->getCount() * 23) + 6;
//mCopyButton->resize(Point2I(mProfile->mTextOffset.x, rowSize + 3), Point2I(45, 15));
//mPasteButton->resize(Point2I(mProfile->mTextOffset.x, rowSize + rowSize + 6), Point2I(45, 15));
RectI bnds = getBounds();
setBounds(bnds.point.x, bnds.point.y, bnds.extent.x, mHeightOverride);
return true;
}
void GuiInspectorTypeParticleDataList::updateValue()
{
const char* data = getData();
if (data != NULL && !String::isEmpty(data))
{
U32 particlesCount = StringUnit::getUnitCount(data, " ");
if (particlesCount != mParticleSlotList.size())
{
_rebuildParticleEntryList();
}
else
{
for (U32 i = 0; i < particlesCount; i++)
{
GuiButtonCtrl* listBtn = dynamic_cast<GuiButtonCtrl*>(mParticleSlotList[i]->getObject(0));
if (!listBtn) //This *really* shouldn't happen
continue;
const char* particleName = StringUnit::getUnit(data, i, " ");
listBtn->setText(particleName);
}
}
}
updateRects();
}
void GuiInspectorTypeParticleDataList::consoleInit()
{

View file

@ -33,8 +33,10 @@ public:
GuiControl* constructEditControl() override;
bool updateRects() override;
void updateValue() override;
void _populateMenu(GuiPopUpMenuCtrlEx* menu);
GuiControl* _buildParticleEntryField(const S32& index);
void _rebuildParticleEntryList();
};
#endif

View file

@ -465,6 +465,7 @@ PlayerData::PlayerData()
physicsPlayerType = StringTable->EmptyString();
mControlMap = StringTable->EmptyString();
mDynamicAnimsStart = NumTableActionAnims;
dMemset( actionList, 0, sizeof(actionList) );
}
@ -516,7 +517,7 @@ bool PlayerData::preload(bool server, String &errorStr)
// Extract ground transform velocity from animations
// Get the named ones first so they can be indexed directly.
ActionAnimation *dp = &actionList[0];
for (S32 i = 0; i < NumTableActionAnims; i++,dp++)
for (S32 i = 0; i < mDynamicAnimsStart; i++,dp++)
{
ActionAnimationDef *sp = &ActionAnimationList[i];
dp->name = sp->name;
@ -694,7 +695,7 @@ bool PlayerData::isTableSequence(S32 seq)
{
// The sequences from the table must already have
// been loaded for this to work.
for (S32 i = 0; i < NumTableActionAnims; i++)
for (S32 i = 0; i < mDynamicAnimsStart; i++)
if (actionList[i].sequence == seq)
return true;
return false;
@ -2834,7 +2835,7 @@ void Player::updateMove(const Move* move)
// Cancel any script driven animations if we are going to move.
if (moveVec.x + moveVec.y + moveVec.z != 0.0f &&
(mActionAnimation.action >= PlayerData::NumTableActionAnims
(mActionAnimation.action >= mDataBlock->mDynamicAnimsStart
|| mActionAnimation.action == PlayerData::LandAnim))
mActionAnimation.action = PlayerData::NullAnimation;
}
@ -3729,7 +3730,7 @@ bool Player::inSittingAnim()
U32 action = mActionAnimation.action;
if (mActionAnimation.thread && action < mDataBlock->actionCount) {
const char * name = mDataBlock->actionList[action].name;
if (!dStricmp(name, "Sitting") || !dStricmp(name, "Scoutroot"))
if (name && (!dStricmp(name, "Sitting") || !dStricmp(name, "Scoutroot")))
return true;
}
return false;
@ -3979,7 +3980,7 @@ void Player::updateActionThread()
if (mMountPending)
mMountPending = (isMounted() ? 0 : (mMountPending - 1));
if (isServerObject() && (mActionAnimation.action >= PlayerData::NumTableActionAnims) && mActionAnimation.atEnd)
if (isServerObject() && (mActionAnimation.action >= mDataBlock->mDynamicAnimsStart) && mActionAnimation.atEnd)
{
//The scripting language will get a call back when a script animation has finished...
// example: When the chat menu animations are done playing...
@ -4080,7 +4081,7 @@ void Player::pickActionAnimation()
// Go into root position unless something was set explicitly
// from a script.
if (mActionAnimation.action != PlayerData::RootAnim &&
mActionAnimation.action < PlayerData::NumTableActionAnims)
mActionAnimation.action < mDataBlock->mDynamicAnimsStart)
setActionThread(PlayerData::RootAnim,true,false,false);
return;
}
@ -5978,7 +5979,7 @@ void Player::getMuzzlePointAI(U32 imageSlot, Point3F* point)
// If we are in one of the standard player animations, adjust the
// muzzle to point in the direction we are looking.
if (mActionAnimation.action < PlayerData::NumTableActionAnims)
if (mActionAnimation.action < mDataBlock->mDynamicAnimsStart)
{
MatrixF xmat;
xmat.set(EulerF(mHead.x, 0, 0));
@ -6362,7 +6363,7 @@ U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
if (stream->writeFlag(mask & ActionMask &&
mActionAnimation.action != PlayerData::NullAnimation &&
mActionAnimation.action >= PlayerData::NumTableActionAnims)) {
mActionAnimation.action >= mDataBlock->mDynamicAnimsStart)) {
stream->writeInt(mActionAnimation.action,PlayerData::ActionAnimBits);
stream->writeFlag(mActionAnimation.holdAtEnd);
stream->writeFlag(mActionAnimation.atEnd);

View file

@ -303,7 +303,7 @@ struct PlayerData: public ShapeBaseData /*protected AssetPtrCallback < already i
ActionAnimBits = 9,
NullAnimation = (1 << ActionAnimBits) - 1
};
int mDynamicAnimsStart;
static ActionAnimationDef ActionAnimationList[NumTableActionAnims];
ActionAnimation actionList[NumActionAnims];
U32 actionCount;
@ -410,9 +410,9 @@ protected:
class Player: public ShapeBase
{
public:
typedef ShapeBase Parent;
public:
enum Pose {
StandPose = 0,
SprintPose,