forestBrushTool.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/platform.h"
  23. #include "forest/editor/forestBrushTool.h"
  24. #include "forest/forest.h"
  25. #include "forest/editor/forestUndo.h"
  26. #include "forest/editor/forestBrushElement.h"
  27. #include "forest/editor/forestEditorCtrl.h"
  28. #include "gui/worldEditor/editTSCtrl.h"
  29. #include "console/consoleTypes.h"
  30. #include "console/engineAPI.h"
  31. #include "core/util/tVector.h"
  32. #include "gfx/gfxDrawUtil.h"
  33. #include "gui/core/guiCanvas.h"
  34. #include "gfx/primBuilder.h"
  35. #include "gui/controls/guiTreeViewCtrl.h"
  36. #include "core/strings/stringUnit.h"
  37. #include "math/mRandomDeck.h"
  38. #include "math/mRandomSet.h"
  39. bool ForestBrushTool::protectedSetSize( void *object, const char *index, const char *data )
  40. {
  41. ForestBrushTool *tool = static_cast<ForestBrushTool*>( object );
  42. F32 val = dAtof(data);
  43. tool->setSize( val );
  44. return false;
  45. }
  46. bool ForestBrushTool::protectedSetPressure( void *object, const char *index, const char *data )
  47. {
  48. ForestBrushTool *tool = static_cast<ForestBrushTool*>( object );
  49. F32 val = dAtof(data);
  50. tool->setPressure( val );
  51. return false;
  52. }
  53. bool ForestBrushTool::protectedSetHardness( void *object, const char *index, const char *data )
  54. {
  55. ForestBrushTool *tool = static_cast<ForestBrushTool*>( object );
  56. F32 val = dAtof(data);
  57. tool->setHardness( val );
  58. return false;
  59. }
  60. ImplementEnumType( ForestBrushMode,
  61. "Active brush mode type.\n"
  62. "@internal\n\n")
  63. { ForestBrushTool::Paint, "Paint", "Creates Items based on the Elements you have selected.\n" },
  64. { ForestBrushTool::Erase, "Erase", "Erases Items of any Mesh type.\n" },
  65. { ForestBrushTool::EraseSelected, "EraseSelected", "Erases items of a specific type.\n" },
  66. EndImplementEnumType;
  67. ForestBrushTool::ForestBrushTool()
  68. : mRandom( Platform::getRealMilliseconds() + 1 ),
  69. mSize( 5.0f ),
  70. mPressure( 0.1f ),
  71. mHardness( 1.0f ),
  72. mMode( Paint ),
  73. mColor( ColorI::WHITE ),
  74. mBrushDown( false ),
  75. mDrawBrush( false ),
  76. mStrokeEvent( 0 ),
  77. mCurrAction( NULL )
  78. {
  79. }
  80. ForestBrushTool::~ForestBrushTool()
  81. {
  82. }
  83. IMPLEMENT_CONOBJECT( ForestBrushTool );
  84. ConsoleDocClass( ForestBrushTool,
  85. "@brief Defines the brush properties when painting trees in Forest Editor\n\n"
  86. "Editor use only.\n\n"
  87. "@internal"
  88. );
  89. void ForestBrushTool::initPersistFields()
  90. {
  91. addGroup( "ForestBrushTool" );
  92. addField( "mode", TYPEID< BrushMode >(), Offset( mMode, ForestBrushTool) );
  93. addProtectedField( "size", TypeF32, Offset( mSize, ForestBrushTool ),
  94. &protectedSetSize, &defaultProtectedGetFn, "Brush Size" );
  95. addProtectedField( "pressure", TypeF32, Offset( mPressure, ForestBrushTool ),
  96. &protectedSetPressure, &defaultProtectedGetFn, "Brush Pressure" );
  97. addProtectedField( "hardness", TypeF32, Offset( mHardness, ForestBrushTool ),
  98. &protectedSetHardness, &defaultProtectedGetFn, "Brush Hardness" );
  99. endGroup( "ForestBrushTool" );
  100. Parent::initPersistFields();
  101. }
  102. bool ForestBrushTool::onAdd()
  103. {
  104. if ( !Parent::onAdd() )
  105. return false;
  106. return true;
  107. }
  108. void ForestBrushTool::onRemove()
  109. {
  110. Parent::onRemove();
  111. }
  112. void ForestBrushTool::on3DMouseDown( const Gui3DMouseEvent &evt )
  113. {
  114. Con::executef( this, "onMouseDown" );
  115. if ( !_updateBrushPoint( evt ) || !mForest )
  116. return;
  117. mBrushDown = true;
  118. mEditor->getRoot()->showCursor( false );
  119. _collectElements();
  120. _onStroke();
  121. return;
  122. }
  123. void ForestBrushTool::on3DMouseUp( const Gui3DMouseEvent &evt )
  124. {
  125. _updateBrushPoint( evt );
  126. Sim::cancelEvent( mStrokeEvent );
  127. mBrushDown = false;
  128. mEditor->getRoot()->showCursor( true );
  129. if ( mCurrAction )
  130. {
  131. _submitUndo( mCurrAction );
  132. mCurrAction = NULL;
  133. }
  134. //mElements.clear();
  135. }
  136. void ForestBrushTool::on3DMouseMove( const Gui3DMouseEvent &evt )
  137. {
  138. _updateBrushPoint( evt );
  139. }
  140. void ForestBrushTool::on3DMouseDragged( const Gui3DMouseEvent &evt )
  141. {
  142. _updateBrushPoint( evt );
  143. if ( mBrushDown && !Sim::isEventPending( mStrokeEvent ) )
  144. mStrokeEvent = Sim::postEvent( this, new ForestBrushToolEvent(), Sim::getCurrentTime() + 250 );
  145. }
  146. bool ForestBrushTool::onMouseWheel( const GuiEvent &evt )
  147. {
  148. if ( evt.modifier & SI_PRIMARY_CTRL )
  149. setPressure( mPressure + evt.fval * ( 0.05f / 120.0f ) );
  150. else if ( evt.modifier & SI_SHIFT )
  151. setHardness( mHardness + evt.fval * ( 0.05f / 120.0f ) );
  152. else
  153. setSize( mSize + evt.fval * ( 1.0f / 120.0f ) );
  154. return true;
  155. }
  156. void ForestBrushTool::onRender3D( )
  157. {
  158. }
  159. void ForestBrushTool::onRender2D()
  160. {
  161. if ( !mDrawBrush )
  162. return;
  163. if ( !mEditor->getRoot()->isCursorON() && !mBrushDown )
  164. return;
  165. RayInfo ri;
  166. Point3F start( 0, 0, mLastBrushPoint.z + mSize );
  167. Point3F end( 0, 0, mLastBrushPoint.z - mSize );
  168. Vector<Point3F> pointList;
  169. const U32 steps = 32;
  170. if ( mForest )
  171. mForest->disableCollision();
  172. for ( S32 i = 0; i < steps; i++ )
  173. {
  174. F32 radians = (F32)i / (F32)(steps-1) * M_2PI_F;
  175. VectorF vec(0,1,0);
  176. MathUtils::vectorRotateZAxis( vec, radians );
  177. end.x = start.x = mLastBrushPoint.x + vec.x * mSize;
  178. end.y = start.y = mLastBrushPoint.y + vec.y * mSize;
  179. bool hit = gServerContainer.castRay( start, end, TerrainObjectType | StaticShapeObjectType, &ri );
  180. if ( hit )
  181. pointList.push_back( ri.point );
  182. }
  183. if ( mForest )
  184. mForest->enableCollision();
  185. if ( pointList.empty() )
  186. return;
  187. ColorI brushColor( ColorI::WHITE );
  188. if ( mMode == Paint )
  189. brushColor = ColorI::BLUE;
  190. else if ( mMode == Erase )
  191. brushColor = ColorI::RED;
  192. else if ( mMode == EraseSelected )
  193. brushColor.set( 150, 0, 0 );
  194. if ( mMode == Paint || mMode == EraseSelected )
  195. {
  196. if ( mElements.empty() )
  197. {
  198. brushColor.set( 140, 140, 140 );
  199. }
  200. }
  201. mEditor->drawLineList( pointList, brushColor, 1.5f );
  202. }
  203. void ForestBrushTool::onActivated( const Gui3DMouseEvent &lastEvent )
  204. {
  205. _updateBrushPoint( lastEvent );
  206. Con::executef( this, "onActivated" );
  207. }
  208. void ForestBrushTool::onDeactivated()
  209. {
  210. Con::executef( this, "onDeactivated" );
  211. }
  212. bool ForestBrushTool::updateGuiInfo()
  213. {
  214. GuiTextCtrl *statusbar;
  215. Sim::findObject( "EWorldEditorStatusBarInfo", statusbar );
  216. GuiTextCtrl *selectionBar;
  217. Sim::findObject( "EWorldEditorStatusBarSelection", selectionBar );
  218. String text;
  219. if ( mMode == Paint )
  220. text = "Forest Editor ( Paint Tool ) - This brush creates Items based on the Elements you have selected.";
  221. else if ( mMode == Erase )
  222. text = "Forest Editor ( Erase Tool ) - This brush erases Items of any Mesh type.";
  223. else if ( mMode == EraseSelected )
  224. text = "Forest Editor ( Erase Selected ) - This brush erases Items based on the Elements you have selected.";
  225. if ( statusbar )
  226. statusbar->setText( text );
  227. if ( mMode == Paint || mMode == EraseSelected )
  228. text = String::ToString( "%i elements selected", mElements.size() );
  229. else
  230. text = "";
  231. if ( selectionBar )
  232. selectionBar->setText( text );
  233. return true;
  234. }
  235. void ForestBrushTool::setSize( F32 val )
  236. {
  237. mSize = mClampF( val, 0.0f, 150.0f );
  238. Con::executef( this, "syncBrushToolbar" );
  239. }
  240. void ForestBrushTool::setPressure( F32 val )
  241. {
  242. mPressure = mClampF( val, 0.0f, 1.0f );
  243. Con::executef( this, "syncBrushToolbar" );
  244. }
  245. void ForestBrushTool::setHardness( F32 val )
  246. {
  247. mHardness = mClampF( val, 0.0f, 1.0f );
  248. Con::executef( this, "syncBrushToolbar" );
  249. }
  250. void ForestBrushTool::_onStroke()
  251. {
  252. if ( !mForest || !mBrushDown )
  253. return;
  254. _action( mLastBrushPoint );
  255. }
  256. void ForestBrushTool::_action( const Point3F &point )
  257. {
  258. if ( mMode == Paint )
  259. _paint( point );
  260. else if ( mMode == Erase || mMode == EraseSelected )
  261. _erase( point );
  262. }
  263. inline F32 mCircleArea( F32 radius )
  264. {
  265. return radius * radius * M_PI_F;
  266. }
  267. void ForestBrushTool::_paint( const Point3F &point )
  268. {
  269. AssertFatal( mForest, "ForestBrushTool::_paint() - Can't paint without a Forest!" );
  270. if ( mElements.empty() )
  271. return;
  272. // Iterators, pointers, and temporaries.
  273. ForestBrushElement *pElement;
  274. ForestItemData *pData;
  275. F32 radius, area;
  276. // How much area do we have to fill with trees ( within the brush ).
  277. F32 fillArea = mCircleArea( mSize );
  278. // Scale that down by pressure, this is how much area we want to fill.
  279. fillArea *= mPressure;
  280. // Create an MRandomSet we can get items we are painting out of with
  281. // the desired distribution.
  282. // Also grab the smallest and largest radius elements while we are looping.
  283. ForestBrushElement *smallestElement, *largestElement;
  284. smallestElement = largestElement = mElements[0];
  285. MRandomSet<ForestBrushElement*> randElementSet(&mRandom);
  286. for ( S32 i = 0; i < mElements.size(); i++ )
  287. {
  288. pElement = mElements[i];
  289. if ( pElement->mData->mRadius > largestElement->mData->mRadius )
  290. largestElement = pElement;
  291. if ( pElement->mData->mRadius < smallestElement->mData->mRadius )
  292. smallestElement = pElement;
  293. randElementSet.add( pElement, pElement->mProbability );
  294. }
  295. // Pull elements from the random set until we would theoretically fill
  296. // the desired area.
  297. F32 areaLeft = fillArea;
  298. F32 scaleFactor, sink, randRot, worldCoordZ, slope;
  299. Point2F worldCoords;
  300. Point3F normalVector, right;
  301. Point2F temp;
  302. const S32 MaxTries = 5;
  303. while ( areaLeft > 0.0f )
  304. {
  305. pElement = randElementSet.get();
  306. pData = pElement->mData;
  307. scaleFactor = mLerp( pElement->mScaleMin, pElement->mScaleMax, mClampF( mPow( mRandom.randF(), pElement->mScaleExponent ), 0.0f, 1.0f ) );
  308. radius = getMax( pData->mRadius * scaleFactor, 0.1f );
  309. area = mCircleArea( radius );
  310. areaLeft -= area * 5.0f; // fudge value
  311. // No room left we are done.
  312. //if ( areaLeft < 0.0f )
  313. // break;
  314. // We have area left to fill...
  315. const F32 rotRange = mDegToRad( pElement->mRotationRange );
  316. // Get a random sink value.
  317. sink = mRandom.randF( pElement->mSinkMin, pElement->mSinkMax ) * scaleFactor;
  318. // Get a random rotation.
  319. randRot = mRandom.randF( 0.0f, rotRange );
  320. // Look for a place within the brush area to place this item.
  321. // We may have to try several times or give and go onto the next.
  322. S32 i = 0;
  323. for ( ; i < MaxTries; i++ )
  324. {
  325. // Pick some randoms for placement.
  326. worldCoords = MathUtils::randomPointInCircle( mSize ) + point.asPoint2F();
  327. // Look for the ground at this position.
  328. if ( !getGroundAt( Point3F( worldCoords.x, worldCoords.y , point.z ),
  329. &worldCoordZ,
  330. &normalVector ) )
  331. {
  332. continue;
  333. }
  334. // Does this pass our slope and elevation limits.
  335. right.set( normalVector.x, normalVector.y, 0 );
  336. right.normalizeSafe();
  337. slope = mRadToDeg( mDot( right, normalVector ) );
  338. if ( worldCoordZ < pElement->mElevationMin ||
  339. worldCoordZ > pElement->mElevationMax ||
  340. slope < pElement->mSlopeMin ||
  341. slope > pElement->mSlopeMax )
  342. {
  343. continue;
  344. }
  345. // Are we up against another tree?
  346. if ( mForest->getData()->getItems( worldCoords, radius, NULL ) > 0 )
  347. continue;
  348. // If the trunk radius is set then we need to sink
  349. // the tree into the ground a bit to hide the bottom.
  350. if ( pElement->mSinkRadius > 0.0f )
  351. {
  352. // Items that are not aligned to the ground surface
  353. // get sunken down to hide the bottom of their trunks.
  354. // sunk down a bit to hide their bottoms on slopes.
  355. normalVector.z = 0;
  356. normalVector.normalizeSafe();
  357. normalVector *= sink;
  358. temp = worldCoords + normalVector.asPoint2F();
  359. getGroundAt( Point3F( temp.x, temp.y, point.z ),
  360. &worldCoordZ,
  361. NULL );
  362. }
  363. worldCoordZ -= sink;
  364. // Create a new undo action if this is a new stroke.
  365. ForestCreateUndoAction *action = dynamic_cast<ForestCreateUndoAction*>( mCurrAction );
  366. if ( !action )
  367. {
  368. action = new ForestCreateUndoAction( mForest->getData(), mEditor );
  369. mCurrAction = action;
  370. }
  371. //Con::printf( "worldCoords = %g, %g, %g", worldCoords.x, worldCoords.y, worldCoordZ );
  372. // Let the action manage adding it to the forest.
  373. action->addItem( pData,
  374. Point3F( worldCoords.x, worldCoords.y, worldCoordZ ),
  375. randRot,
  376. scaleFactor );
  377. break;
  378. }
  379. }
  380. }
  381. void ForestBrushTool::_erase( const Point3F &point )
  382. {
  383. AssertFatal( mForest, "ForestBrushTool::_erase() - Can't erase without a Forest!" );
  384. // First grab all the forest items around the point.
  385. ForestItemVector trees;
  386. if ( mForest->getData()->getItems( point.asPoint2F(), mSize, &trees ) == 0 )
  387. return;
  388. if ( mMode == EraseSelected )
  389. {
  390. for ( U32 i = 0; i < trees.size(); i++ )
  391. {
  392. const ForestItem &tree = trees[i];
  393. if ( !mDatablocks.contains( tree.getData() ) )
  394. {
  395. trees.erase_fast( i );
  396. i--;
  397. }
  398. }
  399. }
  400. if ( trees.empty() )
  401. return;
  402. // Number of trees to erase depending on pressure.
  403. S32 eraseCount = getMax( (S32)mCeil( (F32)trees.size() * mPressure ), 0 );
  404. // Initialize an MRandomDeck with trees under the brush.
  405. MRandomDeck<ForestItem> deck(&mRandom);
  406. deck.addToPile( trees );
  407. deck.shuffle();
  408. ForestItem currentTree;
  409. // Draw eraseCount number of trees from MRandomDeck, adding them to our erase action.
  410. for ( U32 i = 0; i < eraseCount; i++ )
  411. {
  412. deck.draw(&currentTree);
  413. // Create a new undo action if this is a new stroke.
  414. ForestDeleteUndoAction *action = dynamic_cast<ForestDeleteUndoAction*>( mCurrAction );
  415. if ( !action )
  416. {
  417. action = new ForestDeleteUndoAction( mForest->getData(), mEditor );
  418. mCurrAction = action;
  419. }
  420. action->removeItem( currentTree );
  421. }
  422. }
  423. bool ForestBrushTool::_updateBrushPoint( const Gui3DMouseEvent &event_ )
  424. {
  425. // Do a raycast for terrain... thats the placement center.
  426. const U32 mask = TerrainObjectType | StaticShapeObjectType; // TODO: Make an option!
  427. Point3F start( event_.pos );
  428. Point3F end( event_.pos + ( event_.vec * 10000.0f ) );
  429. if ( mForest )
  430. mForest->disableCollision();
  431. RayInfo rinfo;
  432. mDrawBrush = gServerContainer.castRay( start, end, mask, &rinfo );
  433. if ( mForest )
  434. mForest->enableCollision();
  435. if ( mDrawBrush )
  436. {
  437. mLastBrushPoint = rinfo.point;
  438. mLastBrushNormal = rinfo.normal;
  439. }
  440. return mDrawBrush;
  441. }
  442. bool findSelectedElements( ForestBrushElement *obj )
  443. {
  444. if ( obj->isSelectedRecursive() )
  445. return true;
  446. return false;
  447. }
  448. void ForestBrushTool::_collectElements()
  449. {
  450. mElements.clear();
  451. // Get the selected objects from the tree view.
  452. // These can be a combination of ForestBrush(s) and ForestBrushElement(s).
  453. GuiTreeViewCtrl *brushTree;
  454. if ( !Sim::findObject( "ForestEditBrushTree", brushTree ) )
  455. return;
  456. ConsoleValue cValue = Con::executef( brushTree, "getSelectedObjectList" );
  457. const char* objectIdList = cValue.getString();
  458. // Collect those objects in a vector and mark them as selected.
  459. Vector<SimObject*> objectList;
  460. SimObject *simobj;
  461. S32 wordCount = StringUnit::getUnitCount( objectIdList, " " );
  462. for ( S32 i = 0; i < wordCount; i++ )
  463. {
  464. const char* word = StringUnit::getUnit( objectIdList, i, " " );
  465. if ( Sim::findObject( word, simobj ) )
  466. {
  467. objectList.push_back( simobj );
  468. simobj->setSelected(true);
  469. }
  470. }
  471. // Find all ForestBrushElements that are directly or indirectly selected.
  472. SimSet* brushSet;
  473. if (!Sim::findObject("ForestBrushSet", brushSet))
  474. {
  475. Con::errorf("ForestBrushTool::_collectElements() - could not find ForestBrushSet!");
  476. return;
  477. }
  478. brushSet->findObjectByCallback( findSelectedElements, mElements );
  479. // We just needed to flag these objects as selected for the benefit of our
  480. // findSelectedElements callback, we can now mark them un-selected again.
  481. for ( S32 i = 0; i < objectList.size(); i++ )
  482. objectList[i]->setSelected(false);
  483. // If we are in Paint or EraseSelected mode we filter out elements with
  484. // a non-positive probability.
  485. if ( mMode == Paint || mMode == EraseSelected )
  486. {
  487. for ( S32 i = 0; i < mElements.size(); i++ )
  488. {
  489. if ( mElements[i]->mProbability <= 0.0f )
  490. {
  491. mElements.erase_fast(i);
  492. i--;
  493. }
  494. }
  495. }
  496. // Filter out elements with NULL datablocks and collect all unique datablocks
  497. // in a vector.
  498. mDatablocks.clear();
  499. for ( S32 i = 0; i < mElements.size(); i++ )
  500. {
  501. if ( mElements[i]->mData == NULL )
  502. {
  503. mElements.erase_fast(i);
  504. i--;
  505. continue;
  506. }
  507. mDatablocks.push_back_unique( mElements[i]->mData );
  508. }
  509. }
  510. bool ForestBrushTool::getGroundAt( const Point3F &worldPt, F32 *zValueOut, VectorF *normalOut )
  511. {
  512. const U32 mask = TerrainObjectType | StaticShapeObjectType;
  513. Point3F start( worldPt.x, worldPt.y, worldPt.z + mSize );
  514. Point3F end( worldPt.x, worldPt.y, worldPt.z - mSize );
  515. if ( mForest )
  516. mForest->disableCollision();
  517. // Do a cast ray at this point from the top to
  518. // the bottom of our brush radius.
  519. RayInfo rinfo;
  520. bool hit = gServerContainer.castRay( start, end, mask, &rinfo );
  521. if ( mForest )
  522. mForest->enableCollision();
  523. if ( !hit )
  524. return false;
  525. if (zValueOut)
  526. *zValueOut = rinfo.point.z;
  527. if (normalOut)
  528. *normalOut = rinfo.normal;
  529. return true;
  530. }
  531. DefineEngineMethod( ForestBrushTool, collectElements, void, (), , "" )
  532. {
  533. object->collectElements();
  534. }