Merge pull request #1574 from Areloch/MiscShapeEdFixups

Fixes various reported issues with the ShapeEd update
This commit is contained in:
Brian Roberts 2025-10-13 07:26:08 -05:00 committed by GitHub
commit 10ac5cc293
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 91 additions and 50 deletions

View file

@ -159,7 +159,7 @@ void ShapeAnimationAsset::initializeAsset(void)
mSourceShape = ResourceManager::get().load(mFilePath); mSourceShape = ResourceManager::get().load(mFilePath);
if (!mSourceShape || !mSourceShape->addSequence("ambient", "", mAnimationName, mStartFrame, mEndFrame, mPadRotation, mPadTransforms)) if (!mSourceShape || !mSourceShape->addSequence("ambient", "", "", mAnimationName, mStartFrame, mEndFrame, mPadRotation, mPadTransforms))
{ {
Con::errorf("ShapeAnimationAsset::initializeAsset - Unable to do initial setup of the animation clip named %s for asset %s", mAnimationName, getAssetName()); Con::errorf("ShapeAnimationAsset::initializeAsset - Unable to do initial setup of the animation clip named %s for asset %s", mAnimationName, getAssetName());
return; return;

View file

@ -387,7 +387,7 @@ U32 ShapeAsset::load()
String srcPath(mAnimationAssets[i]->getAnimationFilename()); String srcPath(mAnimationAssets[i]->getAnimationFilename());
//SplitSequencePathAndName(srcPath, srcName); //SplitSequencePathAndName(srcPath, srcName);
if (!mShape->addSequence(srcPath, srcName, srcName, if (!mShape->addSequence(srcPath, mAnimationAssets[i]->getAssetId(), srcName, srcName,
mAnimationAssets[i]->getStartFrame(), mAnimationAssets[i]->getEndFrame(), mAnimationAssets[i]->getPadRotation(), mAnimationAssets[i]->getPadTransforms())) mAnimationAssets[i]->getStartFrame(), mAnimationAssets[i]->getEndFrame(), mAnimationAssets[i]->getPadRotation(), mAnimationAssets[i]->getPadTransforms()))
{ {
mLoadedState = MissingAnimatons; mLoadedState = MissingAnimatons;
@ -755,6 +755,11 @@ DefineEngineMethod(ShapeAsset, getStatusString, String, (), , "get status string
return ShapeAsset::getAssetErrstrn(object->getStatus()); return ShapeAsset::getAssetErrstrn(object->getStatus());
} }
DefineEngineMethod(ShapeAsset, load, String, (), , "get status string")\
{
U32 code = object->load();
return ShapeAsset::getAssetErrstrn(code);
}
#ifdef TORQUE_TOOLS #ifdef TORQUE_TOOLS
DefineEngineMethod(ShapeAsset, generateCachedPreviewImage, const char*, (S32 resolution, const char* overrideMaterialName), (256, ""), DefineEngineMethod(ShapeAsset, generateCachedPreviewImage, const char*, (S32 resolution, const char* overrideMaterialName), (256, ""),

View file

@ -682,7 +682,7 @@ class TSShape
bool removeDetail(S32 size); bool removeDetail(S32 size);
static bool isShapeFileType(Torque::Path filePath); static bool isShapeFileType(Torque::Path filePath);
bool addSequence(const Torque::Path& path, const String& fromSeq, const String& name, S32 startFrame, S32 endFrame, bool padRotKeys, bool padTransKeys); bool addSequence(const Torque::Path& path, const String& assetId, const String& fromSeq, const String& name, S32 startFrame, S32 endFrame, bool padRotKeys, bool padTransKeys);
bool removeSequence(const String& name); bool removeSequence(const String& name);
bool addTrigger(const String& seqName, S32 keyframe, S32 state); bool addTrigger(const String& seqName, S32 keyframe, S32 state);

View file

@ -2147,11 +2147,13 @@ DefineTSShapeConstructorMethod(addSequence, bool,
{ {
String srcName; String srcName;
String srcPath(source); String srcPath(source);
StringTableEntry assetId = StringTable->EmptyString();
SplitSequencePathAndName(srcPath, srcName); SplitSequencePathAndName(srcPath, srcName);
if (AssetDatabase.isDeclaredAsset(srcPath)) if (AssetDatabase.isDeclaredAsset(srcPath))
{ {
StringTableEntry assetId = StringTable->insert(srcPath.c_str()); assetId = StringTable->insert(srcPath.c_str());
StringTableEntry assetType = AssetDatabase.getAssetType(assetId); StringTableEntry assetType = AssetDatabase.getAssetType(assetId);
if (assetType == StringTable->insert("ShapeAsset")) if (assetType == StringTable->insert("ShapeAsset"))
{ {
@ -2167,7 +2169,7 @@ DefineTSShapeConstructorMethod(addSequence, bool,
} }
} }
if (!mShape->addSequence(srcPath, srcName, name, start, end, padRot, padTrans)) if (!mShape->addSequence(srcPath, assetId, srcName, name, start, end, padRot, padTrans))
return false; return false;
ADD_TO_CHANGE_SET(); ADD_TO_CHANGE_SET();

View file

@ -30,6 +30,7 @@
#include "ts/tsMaterialList.h" #include "ts/tsMaterialList.h"
#include "core/stream/fileStream.h" #include "core/stream/fileStream.h"
#include "core/volume.h" #include "core/volume.h"
#include "assets/assetManager.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1376,7 +1377,7 @@ bool TSShape::isShapeFileType(Torque::Path filePath)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool TSShape::addSequence(const Torque::Path& path, const String& fromSeq, bool TSShape::addSequence(const Torque::Path& path, const String& assetId, const String& fromSeq,
const String& name, S32 startFrame, S32 endFrame, const String& name, S32 startFrame, S32 endFrame,
bool padRotKeys, bool padTransKeys) bool padRotKeys, bool padTransKeys)
{ {
@ -1810,7 +1811,11 @@ bool TSShape::addSequence(const Torque::Path& path, const String& fromSeq,
seq.dirtyFlags |= TSShapeInstance::MatFrameDirty; seq.dirtyFlags |= TSShapeInstance::MatFrameDirty;
// Store information about how this sequence was created // Store information about how this sequence was created
seq.sourceData.from = String::ToString("%s\t%s", path.getFullPath().c_str(), oldName.c_str()); String fromData = path.getFullPath();
if (assetId.isNotEmpty() && AssetDatabase.isDeclaredAsset(assetId.c_str()))
fromData = assetId;
seq.sourceData.from = String::ToString("%s\t%s", fromData.c_str(), oldName.c_str());
seq.sourceData.total = srcSeq->numKeyframes; seq.sourceData.total = srcSeq->numKeyframes;
seq.sourceData.start = startFrame; seq.sourceData.start = startFrame;
seq.sourceData.end = endFrame; seq.sourceData.end = endFrame;

View file

@ -6,6 +6,21 @@ function shapeEdAddSequenceGui::show(%seqSourceData)
shapeEdAddSequenceWindow-->startFrame.setText("0"); shapeEdAddSequenceWindow-->startFrame.setText("0");
shapeEdAddSequenceWindow-->endFrame.setText("-1"); shapeEdAddSequenceWindow-->endFrame.setText("-1");
shapeEdAddSequenceWindow.constructor = "";
if(AssetDatabase.isDeclaredAsset(%seqSourceData))
{
%shapeDef = AssetDatabase.acquireAsset(%seqSourceData);
%shapeDef.load();
shapeEdAddSequenceWindow.constructor = findShapeConstructorByAssetId( %seqSourceData );
AssetDatabase.releaseAsset(%seqSourceData);
}
else if(isFile(%seqSourceData))
{
shapeEdAddSequenceWindow.constructor = findShapeConstructorByFilename( %seqSourceData );
}
Canvas.pushDialog(shapeEdAddSequenceGui); Canvas.pushDialog(shapeEdAddSequenceGui);
} }
@ -13,29 +28,16 @@ function shapeEdAddSequenceWindow::onWake(%this)
{ {
%sourceSeq = %this-->sourceSeq.getText(); %sourceSeq = %this-->sourceSeq.getText();
if(AssetDatabase.isDeclaredAsset(%sourceSeq))
{
%sourceShapeConstructor = findShapeConstructorByAssetId( %sourceSeq );
}
else if(isFile(%sourceSeq))
{
%sourceShapeConstructor = findShapeConstructorByFilename( %sourceSeq );
}
else
{
toolsMessageBoxOK("Error!", "Source animation data appears to not be valid. Please close the window and select a different source.");
return;
}
if(!isObject(%sourceShapeConstructor)) if(!isObject(%this.constructor))
{ {
toolsMessageBoxOK("Error!", "Unable to find shape constructor for source animation data. Please close the window and select a different source, or make sure the constructor is valid."); toolsMessageBoxOK("Error!", "Unable to find shape constructor for source animation data. Please close the window and select a different source, or make sure the constructor is valid.");
return; return;
} }
for(%i=0; %i < %sourceShapeConstructor.getSequenceCount(); %i++) for(%i=0; %i < %this.constructor.getSequenceCount(); %i++)
{ {
%name = %sourceShapeConstructor.getSequenceName( %i ); %name = %this.constructor.getSequenceName( %i );
// Ignore __backup__ sequences (only used by editor) // Ignore __backup__ sequences (only used by editor)
if ( !startswith( %name, "__backup__" ) ) if ( !startswith( %name, "__backup__" ) )
@ -51,6 +53,8 @@ function onShapeEditorDoAddNewSequence()
%seqSource = shapeEdAddSequenceWindow-->sourceSeq.getText() TAB shapeEdAddSequenceWindow-->fromSeqName.getText(); %seqSource = shapeEdAddSequenceWindow-->sourceSeq.getText() TAB shapeEdAddSequenceWindow-->fromSeqName.getText();
%startFrame = shapeEdAddSequenceWindow-->startFrame.getText(); %startFrame = shapeEdAddSequenceWindow-->startFrame.getText();
%endFrame = shapeEdAddSequenceWindow-->endFrame.getText(); %endFrame = shapeEdAddSequenceWindow-->endFrame.getText();
%seqSource = trim(%seqSource);
ShapeEditor.doAddSequence(%seqName, %seqSource, %startFrame, %endFrame); ShapeEditor.doAddSequence(%seqName, %seqSource, %startFrame, %endFrame);

View file

@ -6,7 +6,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
HorizSizing = "width"; HorizSizing = "width";
VertSizing = "top"; VertSizing = "top";
Position = "1" SPC getWord($pref::Video::mode, 1) - EditorGuiStatusBar.extent.y - 53; Position = "1" SPC getWord($pref::Video::mode, 1) - EditorGuiStatusBar.extent.y - 53;
Extent = getWord($pref::Video::mode, 1) - ShapeEdPropWindow.Extent.x SPC 53; Extent = 1561 SPC 53;
MinExtent = "475 53"; MinExtent = "475 53";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
@ -36,7 +36,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
HorizSizing = "width"; HorizSizing = "width";
VertSizing = "top"; VertSizing = "top";
Position = "5 10"; Position = "5 10";
Extent = "809 53"; Extent = "1552 52";
MinExtent = "8 8"; MinExtent = "8 8";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
@ -51,7 +51,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
HorizSizing = "width"; HorizSizing = "width";
VertSizing = "top"; VertSizing = "top";
Position = "0 3"; Position = "0 3";
Extent = "809 38"; Extent = "1557 38";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
@ -62,7 +62,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
Profile = "ToolsGuiTextProfile"; Profile = "ToolsGuiTextProfile";
HorizSizing = "left"; HorizSizing = "left";
VertSizing = "top"; VertSizing = "top";
position = "740 19"; position = "1440 19";
Extent = "35 16"; Extent = "35 16";
text = "Frame:"; text = "Frame:";
}; };
@ -70,7 +70,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
HorizSizing = "left"; HorizSizing = "left";
VertSizing = "top"; VertSizing = "top";
Profile = "ToolsGuiTextProfile"; Profile = "ToolsGuiTextProfile";
position = "778 19"; position = "1490 19";
Extent = "26 18"; Extent = "26 18";
Variable = "$ShapeEdCurrentFrame"; Variable = "$ShapeEdCurrentFrame";
}; };
@ -112,7 +112,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
HorizSizing = "width"; HorizSizing = "width";
VertSizing = "bottom"; VertSizing = "bottom";
Position = "35 4"; Position = "35 4";
Extent = "736 20"; Extent = "1480 20";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
@ -131,7 +131,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
Profile = "ToolsGuiTextEditProfile"; Profile = "ToolsGuiTextEditProfile";
HorizSizing = "left"; HorizSizing = "left";
VertSizing = "bottom"; VertSizing = "bottom";
Position = "778 0"; Position = "1524 0";
Extent = "28 18"; Extent = "28 18";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -161,7 +161,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
Profile = "ToolsGuiDefaultProfile"; Profile = "ToolsGuiDefaultProfile";
HorizSizing = "center"; HorizSizing = "center";
VertSizing = "top"; VertSizing = "top";
position = "194 17"; position = "568 17";
extent = "420 18"; extent = "420 18";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -426,7 +426,7 @@ $guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) {
Profile = "ToolsGuiDefaultProfile"; Profile = "ToolsGuiDefaultProfile";
HorizSizing = "left"; HorizSizing = "left";
VertSizing = "bottom"; VertSizing = "bottom";
position = "765 0"; position = "1500 0";
Extent = "8 13"; Extent = "8 13";
MinExtent = "1 1"; MinExtent = "1 1";
bitmapAsset = "ToolsModule:seq_bar_out_n_image"; bitmapAsset = "ToolsModule:seq_bar_out_n_image";

View file

@ -308,7 +308,7 @@ function ShapeEditorPlugin::onDeactivated(%this)
ShapeEdAnimWindow.setVisible(false); ShapeEdAnimWindow.setVisible(false);
ShapeEdAdvancedWindow.setVisible(false); ShapeEdAdvancedWindow.setVisible(false);
if( EditorGui-->MatEdPropertiesWindow.visible ) if( MaterialEditorGui.isAwake() )
{ {
ShapeEdMaterials.editSelectedMaterialEnd( true ); ShapeEdMaterials.editSelectedMaterialEnd( true );
} }

View file

@ -147,17 +147,20 @@ function ShapeEditor::getSequenceSource( %this, %seqName )
if ( %src0 $= "" ) if ( %src0 $= "" )
%source = setField( %source, 0, %seqName ); %source = setField( %source, 0, %seqName );
%aq = new AssetQuery(); if(!AssetDatabase.isDeclaredAsset(%src0))
%foundAssets = AssetDatabase.findAssetLooseFile(%aq, %src0);
if(%foundAssets != 0)
{ {
//if we have an assetId associated to the file, we're gunna just pass that %aq = new AssetQuery();
//through for the edit actions %foundAssets = AssetDatabase.findAssetLooseFile(%aq, %src0);
%assetId = %aq.getAsset(0); if(%foundAssets != 0)
{
%source = setField( %source, 0, %assetId ); //if we have an assetId associated to the file, we're gunna just pass that
//through for the edit actions
%assetId = %aq.getAsset(0);
%source = setField( %source, 0, %assetId );
}
%aq.delete();
} }
%aq.delete();
return %source; return %source;
} }
@ -1058,9 +1061,20 @@ function ShapeEdShapeView::onEditNodeTransform( %this, %node, %txfm, %gizmoID )
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Sequence Editing // Sequence Editing
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function ShapeEdSelectWindow::onWake( %this )
{
%this.setPosition(Canvas.extent.x-%this.extent.x, %this.position.y);
}
function ShapeEdAdvancedWindow::onWake( %this )
{
%this.setPosition(Canvas.extent.x-ShapeEdSelectWindow.extent.x-%this.extent.x, %this.position.y);
}
function ShapeEdPropWindow::onWake( %this ) function ShapeEdPropWindow::onWake( %this )
{ {
%this.setPosition(Canvas.extent.x-%this.extent.x, %this.position.y);
ShapeEdTriggerList.triggerId = 1; ShapeEdTriggerList.triggerId = 1;
ShapeEdTriggerList.addRow( -1, "-1" TAB "Frame" TAB "Trigger" TAB "State" ); ShapeEdTriggerList.addRow( -1, "-1" TAB "Frame" TAB "Trigger" TAB "State" );
@ -1689,11 +1703,18 @@ function ShapeEdSeqNameFromMenu::onSelect( %this, %id, %text )
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function ShapeEdAnimWindow::onWake(%this)
function ShapeEdAnimWindow::onResize(%this)
{ {
%this.doResize();
}
function ShapeEdAnimWindow::doResize(%this)
{
if(GuiEditorGui.isAwake())
return;
%animWindow = ShapeEdAnimWindow; %animWindow = ShapeEdAnimWindow;
%position = "1" SPC Canvas.extent.y - EditorGuiStatusBar.extent.y - %this.Extent.y; %position = "1" SPC Canvas.extent.y - EditorGuiStatusBar.extent.y - %this.Extent.y - 20;
if(isObject(ShapeEdPropWindow)) if(isObject(ShapeEdPropWindow))
{ {
@ -1706,11 +1727,15 @@ function ShapeEdAnimWindow::onResize(%this)
// (when the order of GUI loading has changed for example) // (when the order of GUI loading has changed for example)
%extent = Canvas.extent.x - 360 - 2 SPC %animWindow.extent.y; %extent = Canvas.extent.x - 360 - 2 SPC %animWindow.extent.y;
} }
//echo("ShapeEdAnimWIndow::onWake() - " @ %position.x @ ", " @ %position.y @ ", " @ %extent.x @ ", " @ %extent.y);
// resize and position accordingly // resize and position accordingly
%animWindow.resize(%position.x, %position.y, %extent.x, %extent.y); %animWindow.resize(%position.x, %position.y, %extent.x, %extent.y);
}
function ShapeEdAnimWindow::onResize(%this)
{
%this.doResize();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -2259,14 +2284,14 @@ function ShapeEdMaterials::updateSelectedMaterial( %this, %highlight )
// Remove the highlight effect from the old selection // Remove the highlight effect from the old selection
if ( isObject( %this.selectedMaterial ) ) if ( isObject( %this.selectedMaterial ) )
{ {
%this.selectedMaterial.diffuseMap[1] = %this.savedMap; %this.selectedMaterial.diffuseMapAsset[1] = %this.savedMap;
%this.selectedMaterial.reload(); %this.selectedMaterial.reload();
} }
// Apply the highlight effect to the new selected material // Apply the highlight effect to the new selected material
%this.selectedMapTo = getField( ShapeEdMaterialList.getRowText( ShapeEdMaterialList.getSelectedRow() ), 0 ); %this.selectedMapTo = getField( ShapeEdMaterialList.getRowText( ShapeEdMaterialList.getSelectedRow() ), 0 );
%this.selectedMaterial = ShapeEdMaterialList.getSelectedId(); %this.selectedMaterial = ShapeEdMaterialList.getSelectedId();
%this.savedMap = %this.selectedMaterial.diffuseMap[1]; %this.savedMap = %this.selectedMaterial.diffuseMapAsset[1];
if ( %highlight && isObject( %this.selectedMaterial ) ) if ( %highlight && isObject( %this.selectedMaterial ) )
{ {
%this.selectedMaterial.setDiffuseMap("ToolsModule:highlight_material_image", 1); %this.selectedMaterial.setDiffuseMap("ToolsModule:highlight_material_image", 1);