-
Notifications
You must be signed in to change notification settings - Fork 169
feature(WorldBuilder): add all operation modes to single brush tool #1910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b70665c
02ac220
a6110ad
14299cc
f5cae0f
dc80a61
f57f9bd
2118634
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,14 +31,40 @@ class WorldHeightMapEdit; | |
| /// Height brush tool. | ||
| class BrushTool : public Tool | ||
| { | ||
| public: | ||
| enum { | ||
| MIN_RAISE_LOWER = 1, | ||
| MAX_RAISE_LOWER = 21, | ||
| MIN_SMOOTH_RADIUS = 1, | ||
| MAX_SMOOTH_RADIUS = 5, | ||
| MIN_SMOOTH_RATE = 1, | ||
| MAX_SMOOTH_RATE = 10 | ||
| }; | ||
|
|
||
| enum EBrushMode { | ||
| BRUSH_MODE_RAISE, | ||
| BRUSH_MODE_LOWER, | ||
| BRUSH_MODE_SET, | ||
| BRUSH_MODE_SMOOTH | ||
| }; | ||
|
|
||
| protected: | ||
| enum {MIN_DELAY_TIME = 60}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this name is too generic. I would suggest to add what the delay time is for in the name. |
||
|
|
||
| WorldHeightMapEdit *m_htMapEditCopy; ///< ref counted. | ||
| WorldHeightMapEdit *m_htMapFeatherCopy; ///< ref counted. | ||
| WorldHeightMapEdit *m_htMapRateCopy; ///< ref counted (smooth mode). | ||
|
|
||
| static Int m_brushWidth; | ||
| static Int m_brushFeather; | ||
| static Bool m_brushSquare; | ||
| static Int m_brushHeight; | ||
| static Int m_raiseLowerAmount; | ||
| static Int m_smoothRadius; | ||
| static Int m_smoothRate; | ||
|
|
||
| EBrushMode m_activeMode; | ||
| Int m_lastMoveTime; | ||
|
|
||
| public: | ||
| BrushTool(void); | ||
|
|
@@ -48,9 +74,68 @@ class BrushTool : public Tool | |
| static Int getWidth(void) {return m_brushWidth;}; ///<Returns width. | ||
| static Int getFeather(void) {return m_brushFeather;}; ///<Returns feather. | ||
| static Int getHeight(void) {return m_brushHeight;}; ///<Returns height. | ||
| static Int getRaiseLowerAmount(void) {return m_raiseLowerAmount;}; | ||
| static Int getSmoothRadius(void) {return m_smoothRadius;}; | ||
| static Int getSmoothRate(void) {return m_smoothRate;}; | ||
| static void setWidth(Int width); | ||
| static void setFeather(Int feather); | ||
| static void setHeight(Int height); | ||
| static void setRaiseLowerAmount(Int amount); | ||
| static void setSmoothRadius(Int radius); | ||
| static void setSmoothRate(Int rate); | ||
| static EBrushMode getModeFromModifiers(Bool shiftDown, Bool ctrlDown); | ||
| static EBrushMode getPreviewModeFromKeys(); | ||
| static const char* getModeDisplayName(EBrushMode mode); | ||
| static void getModeHintStrings(char *primaryBuf, Int primaryBufSize, char *secondaryBuf, Int secondaryBufSize); | ||
|
|
||
| // Helper functions for brush hint drawing (shared between 2D and 3D views) | ||
| struct BrushHintInfo { | ||
| Bool shouldShow; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
reading further, the only case it is used is |
||
| Bool shouldClear; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the difference between
|
||
| EBrushMode currentMode; | ||
| Int modeInt; | ||
| CPoint hintPos; | ||
| }; | ||
| static Bool getBrushHintInfo(BrushHintInfo &info, char *hintTextBuf, Int hintTextBufSize, const CPoint &hintPos, Int lastBrushMode); | ||
|
|
||
| // Shared smoothing algorithm function (processes a single cell) | ||
| static void applySmoothingAlgorithm( | ||
| WorldHeightMapEdit *editMap, | ||
| WorldHeightMapEdit *featherMap, | ||
| Int i, Int j, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I presume these are cell coordinates? Then cellX and cellY would be better. |
||
| Int rate, | ||
| Int smoothRadius, | ||
| Int minRadius, | ||
| Int maxRadius, | ||
| CWorldBuilderDoc *pDoc); | ||
|
|
||
| // Shared brush iteration with rate accumulation - returns true if rate buffer overflow occurred | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. returning |
||
| static Bool applyBrushWithRateAccumulation( | ||
| WorldHeightMapEdit *editMap, | ||
| WorldHeightMapEdit *featherMap, | ||
| WorldHeightMapEdit *rateMap, | ||
| const CPoint &ndx, | ||
| Int brushWidth, | ||
| Int rateMultiplier, | ||
| Int smoothRadius, | ||
| Int minRadius, | ||
| Int maxRadius, | ||
| CWorldBuilderDoc *pDoc); | ||
|
|
||
| // Shared rate buffer reset | ||
| static void resetSmoothingBuffers( | ||
| WorldHeightMapEdit *editMap, | ||
| WorldHeightMapEdit *featherMap, | ||
| WorldHeightMapEdit *rateMap); | ||
|
|
||
| // Helper to create a partial range for height map updates | ||
| static IRegion2D makePartialRange(const CPoint &ndx, Int brushWidth); | ||
|
|
||
| // Helper to calculate blend factor (square or round) | ||
| static Real calcBlendFactor(const CPoint &ndx, Int i, Int j, Int width, Int feather, Bool square); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would name it A boolean should be named in a way that is clear it is a boolean, e.g. |
||
|
|
||
| // Helper to get effective brush width including feather | ||
| static Int getEffectiveBrushWidth(Int baseWidth, Int feather); | ||
|
|
||
| public: | ||
| virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc); | ||
|
|
@@ -60,4 +145,10 @@ class BrushTool : public Tool | |
| virtual void activate(); ///< Become the current tool. | ||
| virtual Bool followsTerrain(void) {return false;}; | ||
|
|
||
| protected: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these can be made private |
||
| EBrushMode determineBrushMode() const; | ||
| void applySetHeightBrush(const CPoint &ndx, Int brushWidth, CWorldBuilderDoc *pDoc); | ||
| void applyRaiseLowerBrush(const CPoint &ndx, Int brushWidth, Bool raising, CWorldBuilderDoc *pDoc); | ||
| void applySmoothBrush(const CPoint &ndx, Int brushWidth, CWorldBuilderDoc *pDoc); | ||
| void resetSmoothRateBuffer(); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.