Merge pull request #1554 from Azaezel/alpha41/decalAtlasWipWork

decal atlas and decal editor corrections
This commit is contained in:
Brian Roberts 2025-09-22 08:49:42 -05:00 committed by GitHub
commit eb380e58a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 68 additions and 24 deletions

View file

@ -406,12 +406,15 @@ void DecalData::reloadRects()
bool canRenderColsByFrame = false;
S32 id = 0;
texRect[id].point.x = 0.f;
texRect[id].extent.x = 1.f;
texRect[id].point.y = 0.f;
texRect[id].extent.y = 1.f;
texCoordCount = (texRows * texCols) - 1;
if (texRows > 1 || texCols > 1)
{
texCoordCount = (texRows * texCols) - 1;
texRect[id].point.x = 0.f;
texRect[id].extent.x = 1.f;
texRect[id].point.y = 0.f;
texRect[id].extent.y = 1.f;
}
if( texCoordCount > 16 )
{

View file

@ -294,12 +294,12 @@ bool DecalManager::clipDecal( DecalInstance *decal, Vector<Point3F> *edgeVerts,
// Free old verts and indices.
_freeBuffers( decal );
F32 halfSize = decal->mSize * 0.5f;
const Point2F& halfSize = decal->mSize * 0.5f * decal->mDataBlock->texRect[decal->mTextureRectIdx].extent;
// Ugly hack for ProjectedShadow!
F32 halfSizeZ = clipDepth ? clipDepth->x : halfSize;
F32 negHalfSize = clipDepth ? clipDepth->y : halfSize;
Point3F decalHalfSize( halfSize, halfSize, halfSize );
F32 halfSizeZ = clipDepth ? clipDepth->x : halfSize.x;
F32 negHalfSize = clipDepth ? clipDepth->y : halfSize.y;
Point3F decalHalfSize( halfSize.x, halfSize.y, halfSize.x );
Point3F decalHalfSizeZ( halfSizeZ, halfSizeZ, halfSizeZ );
MatrixF projMat( true );
@ -319,11 +319,11 @@ bool DecalManager::clipDecal( DecalInstance *decal, Vector<Point3F> *edgeVerts,
// See above re: decalHalfSizeZ hack.
mClipper.clear();
mClipper.mPlaneList.setSize(6);
mClipper.mPlaneList[0].set( ( decalPos + ( -newRight * halfSize ) ), -newRight );
mClipper.mPlaneList[1].set( ( decalPos + ( -newFwd * halfSize ) ), -newFwd );
mClipper.mPlaneList[0].set( ( decalPos + ( -newRight * halfSize.x ) ), -newRight );
mClipper.mPlaneList[1].set( ( decalPos + ( -newFwd * halfSize.y ) ), -newFwd );
mClipper.mPlaneList[2].set( ( decalPos + ( -crossVec * decalHalfSizeZ ) ), -crossVec );
mClipper.mPlaneList[3].set( ( decalPos + ( newRight * halfSize ) ), newRight );
mClipper.mPlaneList[4].set( ( decalPos + ( newFwd * halfSize ) ), newFwd );
mClipper.mPlaneList[3].set( ( decalPos + ( newRight * halfSize.x ) ), newRight );
mClipper.mPlaneList[4].set( ( decalPos + ( newFwd * halfSize.y ) ), newFwd );
mClipper.mPlaneList[5].set( ( decalPos + ( crossVec * negHalfSize ) ), crossVec );
mClipper.mNormal = decal->mNormal;

View file

@ -854,7 +854,7 @@ DefineEngineMethod( GuiDecalEditorCtrl, selectDecal, void, ( U32 id ), , "select
object->selectDecal( decalInstance );
}
DefineEngineMethod( GuiDecalEditorCtrl, editDecalDetails, void, ( U32 id, Point3F pos, Point3F tan,F32 size ), , "editDecalDetails( S32 )()" )
DefineEngineMethod( GuiDecalEditorCtrl, editDecalDetails, void, ( U32 id, Point3F pos, Point3F tan, F32 size, S32 uvID), , "editDecalDetails( S32,Point3F,Point3F,F32,S32 )()" )
{
DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id];
if( decalInstance == NULL )
@ -864,7 +864,8 @@ DefineEngineMethod( GuiDecalEditorCtrl, editDecalDetails, void, ( U32 id, Point3
decalInstance->mPosition = pos;
decalInstance->mTangent = tan;
decalInstance->mSize = size;
decalInstance->mTextureRectIdx = uvID;
if ( decalInstance == object->mSELDecal )
object->setGizmoFocus( decalInstance );
@ -873,6 +874,11 @@ DefineEngineMethod( GuiDecalEditorCtrl, editDecalDetails, void, ( U32 id, Point3
gDecalManager->notifyDecalModified( decalInstance );
}
DefineEngineMethod(GuiDecalEditorCtrl, getDecalFrame, S32, (U32 id), , "")
{
return gDecalManager->mDecalInstanceVec[id]->mTextureRectIdx;
}
DefineEngineMethod( GuiDecalEditorCtrl, getSelectionCount, S32, (), , "" )
{
if ( object->mSELDecal != NULL )

View file

@ -71,7 +71,12 @@ function ActionEditNodeDetails::doit(%this)
%count = getWordCount(%this.newTransformData);
if(%this.instanceId !$= "" && %count == 7)
{
DecalEditorGui.editDecalDetails( %this.instanceId, %this.newTransformData );
%pos = getwords(%this.newTransformData,0,2);
%tan = getwords(%this.newTransformData,3,5);
%size = getword(%this.newTransformData,6);
//%uvID = DecalEditorGui.getDecalFrame(%this.instanceId);
%uvID = DecalEditorDetailContainer-->frame.getText();
DecalEditorGui.editDecalDetails( %this.instanceId, %pos, %tan, %size, %uvID );
DecalEditorGui.syncNodeDetails();
DecalEditorGui.selectDecal( %this.instanceId );
return true;
@ -84,7 +89,11 @@ function ActionEditNodeDetails::undo(%this)
%count = getWordCount(%this.oldTransformData);
if(%this.instanceId !$= "" && %count == 7)
{
DecalEditorGui.editDecalDetails( %this.instanceId, %this.oldTransformData );
%pos = getwords(%this.oldTransformData,0,2);
%tan = getwords(%this.oldTransformData,3,5);
%size = getword(%this.oldTransformData,6);
%uvID = DecalEditorGui.getDecalFrame(%this.instanceId);
DecalEditorGui.editDecalDetails( %this.instanceId, %pos, %tan, %size, %uvID );
DecalEditorGui.syncNodeDetails();
DecalEditorGui.selectDecal( %this.instanceId );
}

View file

@ -677,7 +677,7 @@ $guiContent = new GuiDecalEditorCtrl(DecalEditorGui) {
new GuiContainer(DecalEditorDetailContainer){
Position = "0 202";
Extent = "202 79";
Extent = "202 100";
HorizSizing = "width";
VertSizing = "bottom";
isContainer = "1";
@ -753,6 +753,24 @@ $guiContent = new GuiDecalEditorCtrl(DecalEditorGui) {
Extent = "128 18";
text = "";
};
new GuiTextCtrl(){
Profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "3 80";
Extent = "47 16";
text = "frame";
};
new GuiTextEditCtrl(){ // instance frame
Profile = "ToolsGuiTextEditProfile";
internalName = "frame";
HorizSizing = "width";
VertSizing = "bottom";
AltCommand = "DecalEditorGui.editNodeDetails();";
Position = "54 80";
Extent = "128 18";
text = "";
};
};
};
};

View file

@ -291,6 +291,9 @@ function DecalEditorGui::onSelectInstance( %this, %decalId, %lookupName )
%item = DecalEditorTreeView.findItemByName( %name );
DecalEditorTreeView.selectItem( %item );
DecalEditorGui.syncNodeDetails();
%dbListID = DecalDataList.findItemText(%lookupName);
DecalDataList.setCurSel( %dbListID );
}
function DecalEditorGui::onCreateInstance( %this, %decalId, %lookupName )
@ -341,7 +344,8 @@ function DecalEditorGui::prepGizmoTransform( %this, %decalId, %nodeDetails )
// Activated in onMouseUp while gizmo is dirty
function DecalEditorGui::completeGizmoTransform( %this, %decalId, %nodeDetails )
{
DecalEditorGui.doEditNodeDetails( %decalId, %nodeDetails, true );
if( getWordCount(%nodeDetails) == 7 )
DecalEditorGui.doEditNodeDetails( %decalId, %nodeDetails, true );
}
function DecalEditorGui::onSleep( %this )
@ -362,6 +366,7 @@ function DecalEditorGui::syncNodeDetails( %this )
DecalEditorDetailContainer-->nodePosition.setText(getWords(%transformData, 0, 2));
DecalEditorDetailContainer-->nodeTangent.setText(getWords(%transformData, 3, 5));
DecalEditorDetailContainer-->nodeSize.setText(getWord(%transformData, 6));
DecalEditorDetailContainer-->frame.setText(DecalEditorGui.getDecalFrame(DecalEditorGui.selDecalInstanceId));
}
function DecalEditorGui::paletteSync( %this, %mode )
@ -385,7 +390,8 @@ function DecalDataList::onSelect( %this, %id, %text )
$Tools::materialEditorList = %data.getId();
//Canvas.pushDialog( DecalEditDlg );
DecalInspector.inspect( %data );
DecalInspector.inspect( %data );
DecalEditorDetailContainer-->frame.setText(%obj.frame);
DecalEditorGui.updateDecalPreview( %data.materialAsset );
}
@ -559,7 +565,9 @@ function DecalInspector::onInspectorFieldModified( %this, %object, %fieldName, %
DecalEditorGui.updateDecalPreview( %newValue );
// Same work to do as for the regular WorldEditor Inspector.
Inspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue );
Inspector::onInspectorFieldModified( %this, %object, %fieldName, %arrayIndex, %oldValue, %newValue );
warn( "modified "@ DecalEditorGui.selDecalInstanceId); //this is an array id, not an objectid
if (%oldValue != %newValue || %oldValue !$= %newValue)
%this.setDirty(%object);
@ -628,8 +636,8 @@ function DecalEditorGui::updateInstancePreview( %this, %material )
if(AssetDatabase.isDeclaredAsset(%material))
{
%previewImage = %material;
}
}
}
DecalPreviewWindow-->instancePreview.setBitmap( getAssetPreviewImage(%previewImage) );
}