Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CWorldBuilderDoc : public CDocument
void invalCell(int xIndex, int yIndex);

void updateAllViews();
void updateHeightMap(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange);
void updateHeightMap(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange, Bool invalObjects = true);

/// Gets an xy index into the height map from a pixel location.
Bool getCellIndexFromCoord(Coord3D pt, CPoint *ndxP);
Expand Down
5 changes: 3 additions & 2 deletions GeneralsMD/Code/Tools/WorldBuilder/include/wbview.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ class WbView : public CView
/// Set the center for display.
virtual void setCenterInView(Real x, Real y) { }

/// Update the height map in the 3d window.
virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange) { }
/// Update the height map in the 3d window. Pass invalObjects=false when no heights changed,
/// so objects, roads, lights and scorches don't need to be refitted to the terrain.
virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange, Bool invalObjects = true) { }

/// the doc has changed size; readjust view as necessary.
virtual void adjustDocSize() { }
Expand Down
2 changes: 1 addition & 1 deletion GeneralsMD/Code/Tools/WorldBuilder/include/wbview3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class WbView3d : public WbView, public DX8_CleanupHook
virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain=true) override;
virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt) override;

virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange) override;
virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange, Bool invalObjects = true) override;

/// Invalidates an object. Pass null to inval all objects.
virtual void invalObjectInView(MapObject *pObj) override;
Expand Down
4 changes: 3 additions & 1 deletion GeneralsMD/Code/Tools/WorldBuilder/src/TileTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ void TileTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldB
if (fullUpdate) {
m_htMapEditCopy->optimizeTiles(); // force to optimize tileset
}
pDoc->updateHeightMap(m_htMapEditCopy, !fullUpdate, partialRange);
// Painting tiles or pathing never changes heights, so skip refitting every object,
// road, light and scorch to the terrain on each mouse move.
pDoc->updateHeightMap(m_htMapEditCopy, !fullUpdate, partialRange, false);
}
pView->UpdateWindow();
m_prevViewPt = viewPt;
Expand Down
4 changes: 2 additions & 2 deletions GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,15 +1392,15 @@ void CWorldBuilderDoc::updateAllViews()
}
}

void CWorldBuilderDoc::updateHeightMap(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange)
void CWorldBuilderDoc::updateHeightMap(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange, Bool invalObjects)
{
POSITION pos = GetFirstViewPosition();
while (pos != nullptr)
{
CView* pView = GetNextView(pos);
WbView* pWView = (WbView *)pView;
ASSERT_VALID(pWView);
pWView->updateHeightMapInView(htMap, partial, partialRange);
pWView->updateHeightMapInView(htMap, partial, partialRange, invalObjects);
pWView->Invalidate();
}
}
Expand Down
7 changes: 5 additions & 2 deletions GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ void WbView3d::invalObjectInView(MapObject *pMapObjIn)


// ----------------------------------------------------------------------------
void WbView3d::updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange)
void WbView3d::updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange, Bool invalObjects)
{
if (htMap == nullptr)
return;
Expand Down Expand Up @@ -1612,7 +1612,10 @@ void WbView3d::updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const
if (curTicks < 1) curTicks = 1;
}

invalObjectInView(nullptr); // update all the map objects, to account for ground changes
// A full rebuild always refits objects; a partial update only when heights may have changed.
if (invalObjects || !partial) {
invalObjectInView(nullptr); // update all the map objects, to account for ground changes
}

--m_updateCount;
}
Expand Down
Loading