@@ -1328,6 +1328,38 @@ namespace LevelEditor
1328
1328
}
1329
1329
}
1330
1330
1331
+ void clearTextureOffset (EditorSector* sector, HitPart part, s32 index)
1332
+ {
1333
+ if (part == HP_FLOOR)
1334
+ {
1335
+ sector->floorTex .offset = { 0 };
1336
+ }
1337
+ else if (part == HP_CEIL)
1338
+ {
1339
+ sector->ceilTex .offset = { 0 };
1340
+ }
1341
+ else if (part == HP_MID)
1342
+ {
1343
+ EditorWall* wall = §or->walls [index];
1344
+ wall->tex [WP_MID].offset = { 0 };
1345
+ }
1346
+ else if (part == HP_BOT)
1347
+ {
1348
+ EditorWall* wall = §or->walls [index];
1349
+ wall->tex [WP_BOT].offset = { 0 };
1350
+ }
1351
+ else if (part == HP_TOP)
1352
+ {
1353
+ EditorWall* wall = §or->walls [index];
1354
+ wall->tex [WP_TOP].offset = { 0 };
1355
+ }
1356
+ else if (part == HP_SIGN)
1357
+ {
1358
+ EditorWall* wall = §or->walls [index];
1359
+ wall->tex [WP_SIGN].offset = { 0 };
1360
+ }
1361
+ }
1362
+
1331
1363
bool edit_viewportHovered (s32 mx, s32 my)
1332
1364
{
1333
1365
return mx >= s_editWinPos.x && mx < s_editWinPos.x + s_editWinSize.x && my >= s_editWinPos.z && my < s_editWinPos.z + s_editWinSize.z ;
@@ -3790,6 +3822,54 @@ namespace LevelEditor
3790
3822
}
3791
3823
}
3792
3824
}
3825
+
3826
+ void edit_resetSelectedTextureOffsets (std::vector<FeatureId>& selected)
3827
+ {
3828
+ EditorSector* sector = nullptr ;
3829
+ s32 featureIndex = -1 ;
3830
+ HitPart part = HP_NONE;
3831
+
3832
+ const s32 count = (s32)selection_getCount ();
3833
+ if (s_editMode == LEDIT_SECTOR)
3834
+ {
3835
+ if (!count && selection_hasHovered ())
3836
+ {
3837
+ selection_getSector (SEL_INDEX_HOVERED, sector);
3838
+ clearTextureOffset (sector, s_featureTex.part , 0 );
3839
+ selected.push_back (createFeatureId (sector, 0 , s_featureTex.part ));
3840
+ }
3841
+
3842
+ // move the floor or ceiling based on hovered.
3843
+ for (s32 i = 0 ; i < count; i++)
3844
+ {
3845
+ selection_getSector (i, sector);
3846
+ clearTextureOffset (sector, s_featureTex.part , 0 );
3847
+ selected.push_back (createFeatureId (sector, 0 , s_featureTex.part ));
3848
+ }
3849
+ }
3850
+ else if (s_editMode == LEDIT_WALL)
3851
+ {
3852
+ if (!count && selection_hasHovered ())
3853
+ {
3854
+ selection_getSurface (SEL_INDEX_HOVERED, sector, featureIndex, &part);
3855
+ if (canMoveTexture (part))
3856
+ {
3857
+ clearTextureOffset (sector, s_featureTex.part , featureIndex);
3858
+ selected.push_back (createFeatureId (sector, featureIndex, s_featureTex.part ));
3859
+ }
3860
+ }
3861
+
3862
+ for (s32 i = 0 ; i < count; i++)
3863
+ {
3864
+ selection_getSurface (i, sector, featureIndex, &part);
3865
+ if (canMoveTexture (part))
3866
+ {
3867
+ clearTextureOffset (sector, part, featureIndex);
3868
+ selected.push_back (createFeatureId (sector, featureIndex, s_featureTex.part ));
3869
+ }
3870
+ }
3871
+ }
3872
+ }
3793
3873
3794
3874
void mergeFeatureLists (std::vector<FeatureId>& outList, const std::vector<FeatureId>& inList)
3795
3875
{
@@ -3816,7 +3896,7 @@ namespace LevelEditor
3816
3896
}
3817
3897
}
3818
3898
3819
- void updateTextureMoveFeatures (std::vector<FeatureId>& list, bool clearOnUpdate)
3899
+ void updateTextureMoveFeatures (std::vector<FeatureId>& list, bool clearOnUpdate, u16 cmdName )
3820
3900
{
3821
3901
s_timeSinceLastUpdate += TFE_System::getDeltaTimeRaw ();
3822
3902
if (list.empty ())
@@ -3832,7 +3912,7 @@ namespace LevelEditor
3832
3912
{
3833
3913
u16 prevCmd, prevName;
3834
3914
history_getPrevCmdAndName (prevCmd, prevName);
3835
- if (prevName == LName_MoveTexture )
3915
+ if (prevName == cmdName )
3836
3916
{
3837
3917
history_removeLast ();
3838
3918
mergeFeatureLists (s_texMoveFeatures, list);
@@ -3850,7 +3930,7 @@ namespace LevelEditor
3850
3930
if (!s_texMoveFeatures.empty ())
3851
3931
{
3852
3932
s_timeSinceLastUpdate = 0.0 ;
3853
- cmd_setTextures (LName_MoveTexture , (s32)s_texMoveFeatures.size (), s_texMoveFeatures.data ());
3933
+ cmd_setTextures (cmdName , (s32)s_texMoveFeatures.size (), s_texMoveFeatures.data ());
3854
3934
}
3855
3935
if (clearOnUpdate)
3856
3936
{
@@ -3868,6 +3948,58 @@ namespace LevelEditor
3868
3948
std::vector<FeatureId> updatedList;
3869
3949
bool clearOnUpdate = false ;
3870
3950
3951
+ if (isShortcutPressed (SHORTCUT_TEXOFFSET_RESET))
3952
+ {
3953
+ if (s_view == EDIT_VIEW_2D && s_editMode == LEDIT_SECTOR && canMoveTex && (s_sectorDrawMode == SDM_TEXTURED_CEIL || s_sectorDrawMode == SDM_TEXTURED_FLOOR))
3954
+ {
3955
+ HitPart part = s_sectorDrawMode == SDM_TEXTURED_CEIL ? HP_CEIL : HP_FLOOR;
3956
+ EditorSector* hovered = nullptr ;
3957
+ if (s_featureTex.sector )
3958
+ {
3959
+ hovered = s_featureTex.sector ;
3960
+ s_featureTex.part = part;
3961
+ }
3962
+ else
3963
+ {
3964
+ selection_getSector (SEL_INDEX_HOVERED, hovered);
3965
+ s_featureTex.sector = hovered;
3966
+ s_featureTex.part = part;
3967
+ }
3968
+
3969
+ bool doesItemExist = selection_sector (SA_CHECK_INCLUSION, hovered);
3970
+ if (selection_getCount () < 1 || doesItemExist)
3971
+ {
3972
+ edit_resetSelectedTextureOffsets (updatedList);
3973
+ }
3974
+ }
3975
+ else if (s_view == EDIT_VIEW_3D && s_editMode == LEDIT_WALL && canMoveTex)
3976
+ {
3977
+ EditorSector* hovered = nullptr ;
3978
+ HitPart part = HP_NONE;
3979
+ s32 featureIndex = -1 ;
3980
+ if (s_featureTex.sector )
3981
+ {
3982
+ hovered = s_featureTex.sector ;
3983
+ part = s_featureTex.part ;
3984
+ featureIndex = s_featureTex.featureIndex ;
3985
+ }
3986
+ else if (selection_getSurface (SEL_INDEX_HOVERED, hovered, featureIndex, &part))
3987
+ {
3988
+ s_featureTex.sector = hovered;
3989
+ s_featureTex.part = part;
3990
+ s_featureTex.featureIndex = featureIndex;
3991
+ }
3992
+
3993
+ bool doesItemExist = selection_surface (SA_CHECK_INCLUSION, hovered, featureIndex, part);
3994
+ if (selection_getCount () < 1 || doesItemExist)
3995
+ {
3996
+ edit_resetSelectedTextureOffsets (updatedList);
3997
+ }
3998
+ }
3999
+ updateTextureMoveFeatures (updatedList, true , LName_ClearTextureOffset);
4000
+ return ;
4001
+ }
4002
+
3871
4003
// TODO: Remove code duplication between the 2D and 3D versions.
3872
4004
if (s_view == EDIT_VIEW_2D && s_editMode == LEDIT_SECTOR && canMoveTex && (s_sectorDrawMode == SDM_TEXTURED_CEIL || s_sectorDrawMode == SDM_TEXTURED_FLOOR))
3873
4005
{
@@ -4181,7 +4313,7 @@ namespace LevelEditor
4181
4313
s_featureTex = {};
4182
4314
}
4183
4315
4184
- updateTextureMoveFeatures (updatedList, clearOnUpdate);
4316
+ updateTextureMoveFeatures (updatedList, clearOnUpdate, LName_MoveTexture );
4185
4317
}
4186
4318
4187
4319
void applyTextureToItem (EditorSector* sector, HitPart part, s32 index, s32 texIndex, Vec2f* offset)
0 commit comments