CompositeSprite_ScriptBinding.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 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. ConsoleMethod(CompositeSprite, addSprite, S32, 2, 3, "( [a] [b] [c] [d] [e] [f] ) - Adds a sprite at the specified logical position.\n"
  23. "You must specify the correct number of arguments for the selected layout mode.\n"
  24. "The created sprite will be automatically selected.\n"
  25. "@param a b c d e f Logical positions #1 & #2 and four additional and optional arguments.\n"
  26. "@return The batch Id of the added sprite or zero if not successful." )
  27. {
  28. if ( argc == 2 )
  29. return object->addSprite( SpriteBatchItem::LogicalPosition() );
  30. else
  31. return object->addSprite( SpriteBatchItem::LogicalPosition(argv[2]) );
  32. }
  33. //-----------------------------------------------------------------------------
  34. ConsoleMethod(CompositeSprite, removeSprite, bool, 2, 2, "() - Removes the selected sprite.\n"
  35. "@return Whether the sprite was removed or not." )
  36. {
  37. return object->removeSprite();
  38. }
  39. //-----------------------------------------------------------------------------
  40. ConsoleMethod(CompositeSprite, clearSprites, void, 2, 2, "() - Removes all sprites.\n"
  41. "@return No return value." )
  42. {
  43. return object->clearSprites();
  44. }
  45. //-----------------------------------------------------------------------------
  46. ConsoleMethod(CompositeSprite, getSpriteCount, S32, 2, 2, "() - Gets a count of sprites in the composite.\n"
  47. "@return The count of sprites in the composite." )
  48. {
  49. return object->getSpriteCount();
  50. }
  51. //-----------------------------------------------------------------------------
  52. ConsoleMethod(CompositeSprite, setBatchLayout, void, 3, 3, "(batchLayoutType) - Sets the batch layout type.\n"
  53. "The render sort mode is used when isolated batch mode is on.\n"
  54. "@param batchLayoutType 'none', 'rect' or 'iso' layout types are valid.\n"
  55. "@return No return value." )
  56. {
  57. // Fetch the batch layout type/
  58. CompositeSprite::BatchLayoutType batchLayoutType = CompositeSprite::getBatchLayoutTypeEnum( argv[2] );
  59. // Sanity!
  60. if ( batchLayoutType == CompositeSprite::INVALID_LAYOUT )
  61. {
  62. // Warn.
  63. Con::warnf( "CompositeSprite::setBatchLayout() - Unknown batch layout type of '%s'.", argv[2] );
  64. return;
  65. }
  66. object->setBatchLayout( batchLayoutType );
  67. }
  68. //-----------------------------------------------------------------------------
  69. ConsoleMethod(CompositeSprite, getBatchLayout, const char*, 2, 2, "() - Gets the batch layout type.\n"
  70. "@return The batch layout type." )
  71. {
  72. return CompositeSprite::getBatchLayoutTypeDescription( object->getBatchLayout() );
  73. }
  74. //-----------------------------------------------------------------------------
  75. ConsoleMethod(CompositeSprite, setBatchIsolated, void, 3, 3, "(bool batchIsolated) - Sets whether the sprites are rendered, isolated from other renderings as one batch or not.\n"
  76. "When in batch isolated mode, the sprites can be optionally sorted.\n"
  77. "@return No return value." )
  78. {
  79. // Fetch batch isolated.
  80. const bool batchIsolated = dAtob(argv[2]);
  81. object->setBatchIsolated( batchIsolated );
  82. }
  83. //-----------------------------------------------------------------------------
  84. ConsoleMethod(CompositeSprite, getBatchIsolated, bool, 2, 2, "() - Gets whether the sprites are rendered, isolated from other renderings as one batch or not.\n"
  85. "@return Whether the sprites are rendered, isolated from other renderings as one batch or not." )
  86. {
  87. return object->getBatchIsolated();
  88. }
  89. //-----------------------------------------------------------------------------
  90. ConsoleMethod(CompositeSprite, setBatchCulling, void, 3, 3, "(bool batchCulling) - Sets whether the sprites are culled.\n"
  91. "For sprites that are off-screen this is considerably faster during render at the expense of memory.\n"
  92. "For small composites with a few sprites, the overhead is probably not worth it.\n"
  93. "@return No return value." )
  94. {
  95. // Fetch batch culling..
  96. const bool batchCulling = dAtob(argv[2]);
  97. STATIC_VOID_CAST_TO(CompositeSprite, SpriteBatch, object)->setBatchCulling( batchCulling );
  98. }
  99. //-----------------------------------------------------------------------------
  100. ConsoleMethod(CompositeSprite, getBatchCulling, bool, 2, 2, "() - Gets whether the sprites are render culled or not\n"
  101. "@return Whether the sprites are rendered culled or not." )
  102. {
  103. return object->getBatchCulling();
  104. }
  105. //-----------------------------------------------------------------------------
  106. ConsoleMethod(CompositeSprite, setBatchSortMode, void, 3, 3, "(renderSortMode) - Sets the batch render sort mode.\n"
  107. "The render sort mode is used when isolated batch mode is on.\n"
  108. "@return No return value." )
  109. {
  110. // Fetch render sort mode.
  111. SceneRenderQueue::RenderSort batchSortMode = SceneRenderQueue::getRenderSortEnum( argv[2] );
  112. // Sanity!
  113. if ( batchSortMode == SceneRenderQueue::RENDER_SORT_INVALID )
  114. {
  115. // Warn.
  116. Con::warnf( "CompositeSprite::setBatchSortMode() - Unknown batch sort mode of '%s'.", argv[2] );
  117. return;
  118. }
  119. object->setBatchSortMode( batchSortMode );
  120. }
  121. //-----------------------------------------------------------------------------
  122. ConsoleMethod(CompositeSprite, getBatchSortMode, const char*, 2, 2, "() - Gets the batch render sort mode.\n"
  123. "@return The render sort mode." )
  124. {
  125. return SceneRenderQueue::getRenderSortDescription( object->getBatchSortMode() );
  126. }
  127. //-----------------------------------------------------------------------------
  128. ConsoleMethod(CompositeSprite, setDefaultSpriteStride, void, 3, 4, "(float strideX, [float strideY]]) - Sets the stride which scales the position at which sprites are created.\n"
  129. "@param strideX The default stride of the local X axis.\n"
  130. "@param strideY The default stride of the local Y axis.\n"
  131. "@return No return value.")
  132. {
  133. Vector2 stride;
  134. // Fetch element count.
  135. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  136. // ("strideX strideY")
  137. if ( (elementCount == 2) && (argc == 3) )
  138. {
  139. stride.x = dAtof(Utility::mGetStringElement(argv[2], 0));
  140. stride.y = dAtof(Utility::mGetStringElement(argv[2], 1));
  141. }
  142. // (strideX, [strideY])
  143. else if (elementCount == 1)
  144. {
  145. stride.x = dAtof(argv[2]);
  146. if (argc > 3)
  147. stride.y = dAtof(argv[3]);
  148. else
  149. stride.y = stride.x;
  150. }
  151. // Invalid
  152. else
  153. {
  154. Con::warnf("CompositeSprite::setDefaultSpriteStride() - Invalid number of parameters!");
  155. return;
  156. }
  157. object->setDefaultSpriteStride( stride );
  158. }
  159. //-----------------------------------------------------------------------------
  160. ConsoleMethod(CompositeSprite, getDefaultSpriteStride, const char*, 2, 2, "() - Gets the stride which scales the position at which sprites are created.\n"
  161. "@return (float strideX/float strideY) The stride which scales the position at which sprites are created.")
  162. {
  163. return object->getDefaultSpriteStride().scriptThis();
  164. }
  165. //-----------------------------------------------------------------------------
  166. ConsoleMethod(CompositeSprite, setDefaultSpriteSize, void, 3, 4, "(float width, [float height]) - Sets the size at which sprites are created.\n"
  167. "@param width The default width of sprites.\n"
  168. "@param height The default height of sprites\n"
  169. "@return No return value.")
  170. {
  171. Vector2 size;
  172. // Fetch element count.
  173. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  174. // ("width height")
  175. if ( (elementCount == 2) && (argc == 3) )
  176. {
  177. size.x = dAtof(Utility::mGetStringElement(argv[2], 0));
  178. size.y = dAtof(Utility::mGetStringElement(argv[2], 1));
  179. }
  180. // (width, [height])
  181. else if (elementCount == 1)
  182. {
  183. size.x = dAtof(argv[2]);
  184. if (argc > 3)
  185. size.y = dAtof(argv[3]);
  186. else
  187. size.y = size.x;
  188. }
  189. // Invalid
  190. else
  191. {
  192. Con::warnf("CompositeSprite::setDefaultSpriteSize() - Invalid number of parameters!");
  193. return;
  194. }
  195. object->setDefaultSpriteSize( size );
  196. }
  197. //-----------------------------------------------------------------------------
  198. ConsoleMethod(CompositeSprite, getDefaultSpriteSize, const char*, 2, 2, "() - Gets the size at which sprites are created.\n"
  199. "@return (float width/float height) The size at which sprites are created.")
  200. {
  201. return object->getDefaultSpriteSize().scriptThis();
  202. }
  203. //-----------------------------------------------------------------------------
  204. ConsoleMethod(CompositeSprite, setDefaultSpriteAngle, void, 3, 3, "(float angle) - Sets the angle at which sprites are created.\n"
  205. "@param angle The angle at which sprites are created.\n"
  206. "@return No return value.")
  207. {
  208. // Fetch angle.
  209. const F32 angle = mDegToRad( dAtof(argv[2]) );
  210. static_cast<SpriteBatch*>(object)->setDefaultSpriteAngle( angle );
  211. }
  212. //-----------------------------------------------------------------------------
  213. ConsoleMethod(CompositeSprite, getDefaultSpriteAngle, F32, 3, 3, "() - Gets the angle at which sprites are created.\n"
  214. "@return (float angle) The angle at which sprites are created.")
  215. {
  216. return mRadToDeg( static_cast<SpriteBatch*>(object)->getDefaultSpriteAngle() );
  217. }
  218. //-----------------------------------------------------------------------------
  219. ConsoleMethod(CompositeSprite, selectSprite, bool, 3, 3, "( a b [c] [d] [e] [f] ) - Selects a sprite at the specified logical position.\n"
  220. "@param a b c d e f Logical positions #1 & #2 and four additional and optional arguments.\n"
  221. "@return Whether the sprite was selected or not." )
  222. {
  223. return object->selectSprite( SpriteBatchItem::LogicalPosition(argv[2]) );
  224. }
  225. //-----------------------------------------------------------------------------
  226. ConsoleMethod(CompositeSprite, selectSpriteId, bool, 3, 3, "( int batchId ) - Selects a sprite with the specified batch Id.\n"
  227. "@param batchId The batch Id of the sprite to select.\n"
  228. "@return Whether the sprite was selected or not." )
  229. {
  230. return object->selectSpriteId( dAtoi(argv[2]) );
  231. }
  232. //-----------------------------------------------------------------------------
  233. ConsoleMethod(CompositeSprite, selectSpriteName, bool, 3, 3, "( name ) - Selects a sprite with the specified name.\n"
  234. "@param name The name of the sprite.\n"
  235. "@return Whether the sprite was selected or not." )
  236. {
  237. return object->selectSpriteName( argv[2] );
  238. }
  239. //-----------------------------------------------------------------------------
  240. ConsoleMethod(CompositeSprite, deselectSprite, void, 2, 2, "() - Deselects any selected sprite.\n"
  241. "This is not required but can be used to stop accidental changes to sprites.\n"
  242. "@return No return value." )
  243. {
  244. return object->deselectSprite();
  245. }
  246. //-----------------------------------------------------------------------------
  247. ConsoleMethod(CompositeSprite, isSpriteSelected, bool, 2, 2, "() - Checks whether a sprite is selected or not.\n"
  248. "@return Whether a sprite is selected or not." )
  249. {
  250. return object->isSpriteSelected();
  251. }
  252. //-----------------------------------------------------------------------------
  253. ConsoleMethod(CompositeSprite, setSpriteImage, void, 3, 4, "(imageAssetId, [int imageFrame]) - Sets the sprite image and optional frame.\n"
  254. "@param imageAssetId The image to set the sprite to.\n"
  255. "@param imageFrame The image frame of the imageAssetId to set the sprite to.\n"
  256. "@return No return value." )
  257. {
  258. // Fetch frame.
  259. const U32 frame = argc >=4 ? dAtoi(argv[3]) : 0;
  260. object->setSpriteImage( argv[2], frame );
  261. }
  262. //-----------------------------------------------------------------------------
  263. ConsoleMethod(CompositeSprite, getSpriteImage, const char*, 2, 2, "() - Gets the sprite image.\n"
  264. "@return The sprite image." )
  265. {
  266. return object->getSpriteImage();
  267. }
  268. //-----------------------------------------------------------------------------
  269. ConsoleMethod(CompositeSprite, setSpriteImageFrame, void, 3, 3, "(int imageFrame) - Sets the sprite image frame.\n"
  270. "@param imageFrame The image frame to set the sprite to.\n"
  271. "@return No return value." )
  272. {
  273. // Fetch frame.
  274. const U32 frame = dAtoi(argv[2]);
  275. object->setSpriteImageFrame( frame );
  276. }
  277. //-----------------------------------------------------------------------------
  278. ConsoleMethod(CompositeSprite, getSpriteImageFrame, S32, 2, 2, "() - Gets the sprite image frame.\n"
  279. "@return The sprite image frame." )
  280. {
  281. return object->getSpriteImageFrame();
  282. }
  283. //-----------------------------------------------------------------------------
  284. ConsoleMethod(CompositeSprite, setSpriteAnimation, void, 3, 4, "(animationAssetId) - Sets the sprite animation.\n"
  285. "@param imageAssetId The animation to set the sprite to.\n"
  286. "@return No return value." )
  287. {
  288. object->setSpriteAnimation( argv[2] );
  289. }
  290. //-----------------------------------------------------------------------------
  291. ConsoleMethod(CompositeSprite, getSpriteAnimation, const char*, 2, 2, "() - Gets the sprite animation.\n"
  292. "@return The sprite animation." )
  293. {
  294. return object->getSpriteAnimation();
  295. }
  296. //-----------------------------------------------------------------------------
  297. ConsoleMethod(CompositeSprite, clearSpriteAsset, void, 2, 2, "() - Clears any image or animation asset from the sprite.\n"
  298. "@return No return value." )
  299. {
  300. return object->clearSpriteAsset();
  301. }
  302. //-----------------------------------------------------------------------------
  303. ConsoleMethod(CompositeSprite, setSpriteVisible, void, 3, 3, "(bool visible) - Sets whether the sprite is visible or not.\n"
  304. "@param visible Whether the sprite is visible or not.\n"
  305. "@return No return value." )
  306. {
  307. // Fetch visible.
  308. const bool visible = dAtob(argv[2]);
  309. object->setSpriteVisible( visible );
  310. }
  311. //-----------------------------------------------------------------------------
  312. ConsoleMethod(CompositeSprite, getSpriteVisible, bool, 2, 2, "() - Gets whether the sprite is visible or not.\n"
  313. "@return Whether the sprite is visible or not." )
  314. {
  315. return object->getSpriteVisible();
  316. }
  317. //-----------------------------------------------------------------------------
  318. ConsoleMethod(CompositeSprite, setSpriteLocalPosition, void, 3, 4, "(float localX, float localY) - Sets the sprites local position.\n"
  319. "@param localX The local position X.\n"
  320. "@param localY The local position Y.\n"
  321. "@return No return value." )
  322. {
  323. Vector2 localPosition;
  324. // Fetch element count.
  325. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  326. // ("x y")
  327. if ( (elementCount == 2) && (argc == 3) )
  328. {
  329. localPosition.x = dAtof(Utility::mGetStringElement(argv[2], 0));
  330. localPosition.y = dAtof(Utility::mGetStringElement(argv[2], 1));
  331. }
  332. // (x, y)
  333. else if ( elementCount == 1 && (argc > 3) )
  334. {
  335. localPosition.x = dAtof(argv[2]);
  336. localPosition.y = dAtof(argv[3]);
  337. }
  338. // Invalid
  339. else
  340. {
  341. Con::warnf("CompositeSprite::setSpriteLocalPosition() - Invalid number of parameters!");
  342. return;
  343. }
  344. object->setSpriteLocalPosition( localPosition );
  345. }
  346. //-----------------------------------------------------------------------------
  347. ConsoleMethod(CompositeSprite, getSpriteLocalPosition, const char*, 2, 2, "() - Gets the sprite local position.\n"
  348. "@return The sprite local position." )
  349. {
  350. return object->getSpriteLocalPosition().scriptThis();
  351. }
  352. //-----------------------------------------------------------------------------
  353. ConsoleMethod(CompositeSprite, setSpriteAngle, void, 3, 3, "(float localAngle) - Sets the sprites local angle.\n"
  354. "@param localAngle The sprite local angle.\n"
  355. "@return No return value." )
  356. {
  357. // Fetch angle.
  358. const F32 angle = mDegToRad( dAtof(argv[2]) );
  359. object->setSpriteAngle( angle );
  360. }
  361. //-----------------------------------------------------------------------------
  362. ConsoleMethod(CompositeSprite, getSpriteAngle, F32, 2, 2, "() - Gets the sprite local angle.\n"
  363. "@return The sprite local angle." )
  364. {
  365. return mRadToDeg( object->getSpriteAngle() );
  366. }
  367. //-----------------------------------------------------------------------------
  368. ConsoleMethod(CompositeSprite, setSpriteDepth, void, 3, 3, "(float depth) - Sets the sprites depth.\n"
  369. "@param depth The sprite depth.\n"
  370. "@return No return value." )
  371. {
  372. // Fetch depth.
  373. const F32 depth = dAtof(argv[2]);
  374. object->setSpriteDepth( depth );
  375. }
  376. //-----------------------------------------------------------------------------
  377. ConsoleMethod(CompositeSprite, getSpriteDepth, F32, 2, 2, "() - Gets the sprite depth.\n"
  378. "@return The sprite depth." )
  379. {
  380. return object->getSpriteDepth();
  381. }
  382. //-----------------------------------------------------------------------------
  383. ConsoleMethod(CompositeSprite, setSpriteSize, void, 3, 4, "(float width, [float height]) - Sets the sprite size.\n"
  384. "@param width The sprite width.\n"
  385. "@param height The sprite height\n"
  386. "@return No return value.")
  387. {
  388. Vector2 size;
  389. // Fetch element count.
  390. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  391. // ("width height")
  392. if ( (elementCount == 2) && (argc == 3) )
  393. {
  394. size.x = dAtof(Utility::mGetStringElement(argv[2], 0));
  395. size.y = dAtof(Utility::mGetStringElement(argv[2], 1));
  396. }
  397. // (width, [height])
  398. else if (elementCount == 1)
  399. {
  400. size.x = dAtof(argv[2]);
  401. if (argc > 3)
  402. size.y = dAtof(argv[3]);
  403. else
  404. size.y = size.x;
  405. }
  406. // Invalid
  407. else
  408. {
  409. Con::warnf("CompositeSprite::setSpriteSize() - Invalid number of parameters!");
  410. return;
  411. }
  412. object->setSpriteSize( size );
  413. }
  414. //-----------------------------------------------------------------------------
  415. ConsoleMethod(CompositeSprite, getSpriteSize, const char*, 2, 2, "() - Gets the sprite size.\n"
  416. "@return (float width/float height) The sprite size.")
  417. {
  418. return object->getSpriteSize().scriptThis();
  419. }
  420. //-----------------------------------------------------------------------------
  421. ConsoleMethod(CompositeSprite, setSpriteFlipX, void, 3, 3, "(bool flipX) - Sets whether the sprite is flipped along its local X axis or not.\n"
  422. "@param flipX Whether the sprite is flipped along its local X axis or not.\n"
  423. "@return No return value." )
  424. {
  425. // Fetch flipX.
  426. const bool flipX = dAtob(argv[2]);
  427. object->setSpriteFlipX( flipX );
  428. }
  429. //-----------------------------------------------------------------------------
  430. ConsoleMethod(CompositeSprite, getSpriteFlipX, bool, 2, 2, "() - Gets whether the sprite is flipped along its local X axis or not.\n"
  431. "@return Whether the sprite is flipped along its local X axis or not." )
  432. {
  433. return object->getSpriteFlipX();
  434. }
  435. //-----------------------------------------------------------------------------
  436. ConsoleMethod(CompositeSprite, setSpriteFlipY, void, 3, 3, "(bool flipY) - Sets whether the sprite is flipped along its local Y axis or not.\n"
  437. "@param flipY Whether the sprite is flipped along its local Y axis or not.\n"
  438. "@return No return value." )
  439. {
  440. const bool flipY = dAtob(argv[2]);
  441. object->setSpriteFlipY( flipY );
  442. }
  443. //-----------------------------------------------------------------------------
  444. ConsoleMethod(CompositeSprite, getSpriteFlipY, bool, 2, 2, "() - Gets whether the sprite is flipped along its local Y axis or not.\n"
  445. "@return Whether the sprite is flipped along its local Y axis or not." )
  446. {
  447. return object->getSpriteFlipY();
  448. }
  449. //-----------------------------------------------------------------------------
  450. ConsoleMethod(CompositeSprite, setSpriteSortPoint, void, 3, 4, "(float localX, float localY) - Sets the sprites sort point.\n"
  451. "@param localX The local sort point X.\n"
  452. "@param localY The local sort point Y.\n"
  453. "@return No return value." )
  454. {
  455. Vector2 sortPoint;
  456. // Fetch element count.
  457. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  458. // ("x y")
  459. if ( (elementCount == 2) && (argc == 3) )
  460. {
  461. sortPoint.x = dAtof(Utility::mGetStringElement(argv[2], 0));
  462. sortPoint.y = dAtof(Utility::mGetStringElement(argv[2], 1));
  463. }
  464. // (x, y)
  465. else if ( elementCount == 1 && (argc > 3) )
  466. {
  467. sortPoint.x = dAtof(argv[2]);
  468. sortPoint.y = dAtof(argv[3]);
  469. }
  470. // Invalid
  471. else
  472. {
  473. Con::warnf("CompositeSprite::setSpriteSortPoint() - Invalid number of parameters!");
  474. return;
  475. }
  476. object->setSpriteSortPoint( sortPoint );
  477. }
  478. //-----------------------------------------------------------------------------
  479. ConsoleMethod(CompositeSprite, getSpriteSortPoint, const char*, 2, 2, "() - Gets the sprite local sort point.\n"
  480. "@return The sprite local sort point." )
  481. {
  482. return object->getSpriteSortPoint().scriptThis();
  483. }
  484. //-----------------------------------------------------------------------------
  485. ConsoleMethod(CompositeSprite, setSpriteRenderGroup, void, 3, 3, "(renderGroup) Sets the name of the render group used to sort the sprite during rendering.\n"
  486. "@param renderGroup The name of the render group to use. Defaults to nothing.\n"
  487. "@return No return value.")
  488. {
  489. object->setSpriteRenderGroup( argv[2] );
  490. }
  491. //-----------------------------------------------------------------------------
  492. ConsoleMethod(CompositeSprite, getSpriteRenderGroup, const char*, 2, 2, "() Gets the name of the render group used to sort the sprite during rendering.\n"
  493. "@return The render group used to sort the object during rendering.")
  494. {
  495. return object->getSpriteRenderGroup();
  496. }
  497. //-----------------------------------------------------------------------------
  498. ConsoleMethod(CompositeSprite, setSpriteBlendMode, void, 3, 3, "(bool blendMode) - Sets whether sprite blending is on or not.\n"
  499. "@blendMode Whether sprite blending is on or not.\n"
  500. "@return No return Value.")
  501. {
  502. // Fetch blend mode.
  503. const bool blendMode = dAtob(argv[2]);
  504. object->setSpriteBlendMode( blendMode );
  505. }
  506. //-----------------------------------------------------------------------------
  507. ConsoleMethod(CompositeSprite, getSpriteBlendMode, bool, 2, 2, "() - Gets whether sprite blending is on or not.\n"
  508. "@return (bool blendMode) Whether sprite blending is on or not.")
  509. {
  510. return object->getSpriteBlendMode();
  511. }
  512. //-----------------------------------------------------------------------------
  513. ConsoleMethod(CompositeSprite, setSpriteSrcBlendFactor, void, 3, 3, "(srcBlend) - Sets the sprite source blend factor.\n"
  514. "@param srcBlend The sprite source blend factor.\n"
  515. "@return No return Value.")
  516. {
  517. // Fetch source blend factor.
  518. GLenum blendFactor = SceneObject::getSrcBlendFactorEnum(argv[2]);
  519. object->setSpriteSrcBlendFactor( blendFactor );
  520. }
  521. //-----------------------------------------------------------------------------
  522. ConsoleMethod(CompositeSprite, getSpriteSrcBlendFactor, const char*, 2, 2, "() - Gets the sprite source blend factor.\n"
  523. "@return (srcBlend) The sprite source blend factor.")
  524. {
  525. return SceneObject::getSrcBlendFactorDescription( object->getSpriteSrcBlendFactor() );
  526. }
  527. //-----------------------------------------------------------------------------
  528. ConsoleMethod(CompositeSprite, setSpriteDstBlendFactor, void, 3, 3, "(dstBlend) - Sets the sprite destination blend factor.\n"
  529. "@param dstBlend The sprite destination blend factor.\n"
  530. "@return No return Value.")
  531. {
  532. // Fetch destination blend factor.
  533. GLenum blendFactor = SceneObject::getDstBlendFactorEnum(argv[2]);
  534. object->setSpriteDstBlendFactor( blendFactor );
  535. }
  536. //-----------------------------------------------------------------------------
  537. ConsoleMethod(CompositeSprite, getSpriteDstBlendFactor, const char*, 2, 2, "() - Gets the sprite destination blend factor.\n"
  538. "@return (dstBlend) The sprite destination blend factor.")
  539. {
  540. return SceneObject::getDstBlendFactorDescription( object->getSpriteDstBlendFactor() );
  541. }
  542. //-----------------------------------------------------------------------------
  543. ConsoleMethod(CompositeSprite, setSpriteBlendColor, void, 3, 6, "(float red, float green, float blue, [float alpha = 1.0]) or ( stockColorName ) - Sets the sprite blend color."
  544. "@param red The red value.\n"
  545. "@param green The green value.\n"
  546. "@param blue The blue value.\n"
  547. "@param alpha The alpha value.\n"
  548. "@return No return Value.")
  549. {
  550. // The colors.
  551. F32 red;
  552. F32 green;
  553. F32 blue;
  554. F32 alpha = 1.0f;
  555. // Space separated.
  556. if (argc == 3 )
  557. {
  558. // Grab the element count.
  559. const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  560. // Has a single argument been specified?
  561. if ( elementCount == 1 )
  562. {
  563. // Is a sprite selected?
  564. if ( !object->isSpriteSelected() )
  565. {
  566. // No, so warn.
  567. Con::warnf("CompositeSprite::setSpriteBlendColor() - Cannot set sprite blend color as no sprite is selected." );
  568. return;
  569. }
  570. Con::setData( TypeColorF, &const_cast<ColorF&>(object->getSpriteBlendColor()), 0, 1, &(argv[2]) );
  571. return;
  572. }
  573. // ("R G B [A]")
  574. if ((elementCount == 3) || (elementCount == 4))
  575. {
  576. // Extract the color.
  577. red = dAtof(Utility::mGetStringElement(argv[2], 0));
  578. green = dAtof(Utility::mGetStringElement(argv[2], 1));
  579. blue = dAtof(Utility::mGetStringElement(argv[2], 2));
  580. // Grab the alpha if it's there.
  581. if (elementCount > 3)
  582. alpha = dAtof(Utility::mGetStringElement(argv[2], 3));
  583. }
  584. // Invalid.
  585. else
  586. {
  587. Con::warnf("SceneObject::setBlendColor() - Invalid Number of parameters!");
  588. return;
  589. }
  590. }
  591. // (R, G, B)
  592. else if (argc >= 5)
  593. {
  594. red = dAtof(argv[2]);
  595. green = dAtof(argv[3]);
  596. blue = dAtof(argv[4]);
  597. // Grab the alpha if it's there.
  598. if (argc > 5)
  599. alpha = dAtof(argv[5]);
  600. }
  601. // Invalid.
  602. else
  603. {
  604. Con::warnf("SceneObject::setBlendColor() - Invalid Number of parameters!");
  605. return;
  606. }
  607. // Set blend color.
  608. object->setSpriteBlendColor(ColorF(red, green, blue, alpha));
  609. }
  610. //-----------------------------------------------------------------------------
  611. ConsoleMethod(CompositeSprite, getSpriteBlendColor, const char*, 2, 3, "(allowColorNames) Gets the sprite blend color\n"
  612. "@param allowColorNames Whether to allow stock color names to be returned or not. Optional: Defaults to false.\n"
  613. "@return (float red / float green / float blue / float alpha) The sprite blend color.")
  614. {
  615. // Get Blend color.
  616. ColorF blendColor = object->getSpriteBlendColor();
  617. // Fetch allow color names flag.
  618. const bool allowColorNames = (argc > 2) ? dAtob(argv[2] ) : false;
  619. // Are color names allowed?
  620. if ( allowColorNames )
  621. {
  622. // Yes, so fetch the field value.
  623. return Con::getData( TypeColorF, &blendColor, 0 );
  624. }
  625. // No, so fetch the raw color values.
  626. return blendColor.scriptThis();
  627. }
  628. //-----------------------------------------------------------------------------
  629. ConsoleMethod(CompositeSprite, setSpriteBlendAlpha, void, 3, 3, "(float alpha) - Sets the sprite color alpha (transparency).\n"
  630. "The alpha value specifies directly the transparency of the image. A value of 1.0 will not affect the object and a value of 0.0 will make the object completely transparent.\n"
  631. "@param alpha The alpha value.\n"
  632. "@return No return Value.")
  633. {
  634. object->setSpriteBlendAlpha( dAtof(argv[2]) );
  635. }
  636. //-----------------------------------------------------------------------------
  637. ConsoleMethod(CompositeSprite, getSpriteBlendAlpha, F32, 2, 2, "() - Gets the sprite color alpha (transparency).\n"
  638. "@return (float alpha) The alpha value, a range from 0.0 to 1.0. Less than zero if alpha testing is disabled.")
  639. {
  640. return object->getSpriteBlendAlpha();
  641. }
  642. //-----------------------------------------------------------------------------
  643. ConsoleMethod(CompositeSprite, setSpriteAlphaTest, void, 3, 3, "(float alpha) - Set the sprite alpha test.\n"
  644. "@param value Numeric value of 0.0 to 1.0 to turn on alpha testing. Less than zero to disable alpha testing."
  645. "@return No return Value.")
  646. {
  647. object->setSpriteAlphaTest(dAtof(argv[2]));
  648. }
  649. //-----------------------------------------------------------------------------
  650. ConsoleMethod(CompositeSprite, getSpriteAlphaTest, F32, 2, 2, "() - Gets the sprite alpha test.\n"
  651. "@return (S32) A value of 0 to 255 if alpha testing is enabled. <0 represents disabled alpha testing.")
  652. {
  653. return object->getSpriteAlphaTest();
  654. }
  655. //-----------------------------------------------------------------------------
  656. ConsoleMethod(CompositeSprite, setSpriteDataObject, void, 3, 3, "(object) - Set the sprite data object.\n"
  657. "NOTE: This object will be persisted alongside the composite sprite.\n"
  658. "To clear the object you can pass an empty string.\n"
  659. "@return No return Value.")
  660. {
  661. object->setSpriteDataObject( Sim::findObject( argv[2] ) );
  662. }
  663. //-----------------------------------------------------------------------------
  664. ConsoleMethod(CompositeSprite, getSpriteDataObject, const char*, 2, 2, "() - Gets the sprite data object.\n"
  665. "@return The sprite data object.")
  666. {
  667. return object->getSpriteDataObject()->getIdString();
  668. }
  669. //-----------------------------------------------------------------------------
  670. ConsoleMethod(CompositeSprite, setSpriteName, void, 3, 3, "(name) - Set the sprite name.\n"
  671. "This must be unique within this composite sprite instance. To clear the name you can pass an empty string.\n"
  672. "@return No return Value.")
  673. {
  674. object->setSpriteName( argv[2] );
  675. }
  676. //-----------------------------------------------------------------------------
  677. ConsoleMethod(CompositeSprite, getSpriteName, const char*, 2, 2, "() - Gets the sprite name.\n"
  678. "@return The sprite name.")
  679. {
  680. return object->getSpriteName();
  681. }
  682. //-----------------------------------------------------------------------------
  683. ConsoleMethod(CompositeSprite, pickPoint, const char*, 3, 4, "(x / y ) Picks sprites intersecting the specified point with optional group/layer masks.\n"
  684. "@param x/y The coordinate of the point as either (\"x y\") or (x,y)\n"
  685. "@return Returns list of sprite Ids.")
  686. {
  687. // Fetch sprite batch query and clear results.
  688. SpriteBatchQuery* pSpriteBatchQuery = object->getSpriteBatchQuery( true );
  689. // Is the sprite batch query available?
  690. if ( pSpriteBatchQuery == NULL )
  691. {
  692. // No, so warn.
  693. Con::warnf( "CompositeSprite::pickPoint() - Cannot pick sprites if clipping mode is off." );
  694. // Return nothing.
  695. return NULL;
  696. }
  697. // The point.
  698. Vector2 point;
  699. // The index of the first optional parameter.
  700. U32 firstArg;
  701. // Grab the number of elements in the first parameter.
  702. U32 elementCount = Utility::mGetStringElementCount(argv[2]);
  703. // ("x y")
  704. if ((elementCount == 2) && (argc < 8))
  705. {
  706. point = Utility::mGetStringElementVector(argv[2]);
  707. firstArg = 3;
  708. }
  709. // (x, y)
  710. else if ((elementCount == 1) && (argc > 3))
  711. {
  712. point = Vector2(dAtof(argv[2]), dAtof(argv[3]));
  713. firstArg = 4;
  714. }
  715. // Invalid
  716. else
  717. {
  718. Con::warnf("CompositeSprite::pickPoint() - Invalid number of parameters!");
  719. return NULL;
  720. }
  721. // Fetch the render transform.
  722. const b2Transform& renderTransform = object->getRenderTransform();
  723. // Transform into local space.
  724. point = b2MulT( renderTransform, point );
  725. // Perform query.
  726. pSpriteBatchQuery->queryPoint( point, true );
  727. // Fetch result count.
  728. const U32 resultCount = pSpriteBatchQuery->getQueryResultsCount();
  729. // Finish if no results.
  730. if (resultCount == 0 )
  731. return NULL;
  732. // Fetch results.
  733. typeSpriteBatchQueryResultVector& queryResults = pSpriteBatchQuery->getQueryResults();
  734. // Set Max Buffer Size.
  735. const U32 maxBufferSize = 4096;
  736. // Create Returnable Buffer.
  737. char* pBuffer = Con::getReturnBuffer(maxBufferSize);
  738. // Set Buffer Counter.
  739. U32 bufferCount = 0;
  740. // Add picked sprites.
  741. for ( U32 n = 0; n < resultCount; n++ )
  742. {
  743. // Output Object ID.
  744. bufferCount += dSprintf( pBuffer + bufferCount, maxBufferSize-bufferCount, "%d ", queryResults[n].mpSpriteBatchItem->getBatchId() );
  745. // Finish early if we run out of buffer space.
  746. if ( bufferCount >= maxBufferSize )
  747. {
  748. // Warn.
  749. Con::warnf("CompositeSprite::pickPoint() - Too many items picked to return to scripts!");
  750. break;
  751. }
  752. }
  753. // Clear sprite batch query.
  754. pSpriteBatchQuery->clearQuery();
  755. // Return buffer.
  756. return pBuffer;
  757. }
  758. //-----------------------------------------------------------------------------
  759. ConsoleMethod(CompositeSprite, pickArea, const char*, 4, 6, "(startx/y, endx/y ) Picks sprites intersecting the specified area with optional group/layer masks.\n"
  760. "@param startx/y The coordinates of the start point as either (\"x y\") or (x,y)\n"
  761. "@param endx/y The coordinates of the end point as either (\"x y\") or (x,y)\n"
  762. "@return Returns list of sprite Ids.")
  763. {
  764. // Fetch sprite batch query and clear results.
  765. SpriteBatchQuery* pSpriteBatchQuery = object->getSpriteBatchQuery( true );
  766. // Is the sprite batch query available?
  767. if ( pSpriteBatchQuery == NULL )
  768. {
  769. // No, so warn.
  770. Con::warnf( "CompositeSprite::pickArea() - Cannot pick sprites if clipping mode is off." );
  771. // Return nothing.
  772. return NULL;
  773. }
  774. // Upper left and lower right bound.
  775. Vector2 v1, v2;
  776. // The index of the first optional parameter.
  777. U32 firstArg;
  778. // Grab the number of elements in the first two parameters.
  779. U32 elementCount1 = Utility::mGetStringElementCount(argv[2]);
  780. U32 elementCount2 = 1;
  781. if (argc > 3)
  782. elementCount2 = Utility::mGetStringElementCount(argv[3]);
  783. // ("x1 y1 x2 y2")
  784. if ((elementCount1 == 4) && (argc < 9))
  785. {
  786. v1 = Utility::mGetStringElementVector(argv[2]);
  787. v2 = Utility::mGetStringElementVector(argv[2], 2);
  788. firstArg = 3;
  789. }
  790. // ("x1 y1", "x2 y2")
  791. else if ((elementCount1 == 2) && (elementCount2 == 2) && (argc > 3) && (argc < 10))
  792. {
  793. v1 = Utility::mGetStringElementVector(argv[2]);
  794. v2 = Utility::mGetStringElementVector(argv[3]);
  795. firstArg = 4;
  796. }
  797. // (x1, y1, x2, y2)
  798. else if (argc > 5)
  799. {
  800. v1 = Vector2(dAtof(argv[2]), dAtof(argv[3]));
  801. v2 = Vector2(dAtof(argv[4]), dAtof(argv[5]));
  802. firstArg = 6;
  803. }
  804. // Invalid
  805. else
  806. {
  807. Con::warnf("CompositeSprite::pickArea() - Invalid number of parameters!");
  808. return NULL;
  809. }
  810. // Calculate normalized AABB.
  811. b2AABB aabb;
  812. aabb.lowerBound.x = getMin( v1.x, v2.x );
  813. aabb.lowerBound.y = getMin( v1.y, v2.y );
  814. aabb.upperBound.x = getMax( v1.x, v2.x );
  815. aabb.upperBound.y = getMax( v1.y, v2.y );
  816. // Calculate local OOBB.
  817. b2Vec2 localOOBB[4];
  818. CoreMath::mAABBtoOOBB( aabb, localOOBB );
  819. CoreMath::mCalculateInverseOOBB( localOOBB, object->getRenderTransform(), localOOBB );
  820. // Calculate local AABB.
  821. b2AABB localAABB;
  822. CoreMath::mOOBBtoAABB( localOOBB, localAABB );
  823. // Convert OOBB to a PolygonShape
  824. b2PolygonShape oobb_polygon;
  825. oobb_polygon.Set(localOOBB, 4);
  826. // Perform query.
  827. pSpriteBatchQuery->queryOOBB( localAABB, oobb_polygon, true );
  828. // Fetch result count.
  829. const U32 resultCount = pSpriteBatchQuery->getQueryResultsCount();
  830. // Finish if no results.
  831. if (resultCount == 0 )
  832. return NULL;
  833. // Fetch results.
  834. typeSpriteBatchQueryResultVector& queryResults = pSpriteBatchQuery->getQueryResults();
  835. // Set Max Buffer Size.
  836. const U32 maxBufferSize = 4096;
  837. // Create Returnable Buffer.
  838. char* pBuffer = Con::getReturnBuffer(maxBufferSize);
  839. // Set Buffer Counter.
  840. U32 bufferCount = 0;
  841. // Add picked objects.
  842. for ( U32 n = 0; n < resultCount; n++ )
  843. {
  844. // Output Object ID.
  845. bufferCount += dSprintf( pBuffer + bufferCount, maxBufferSize-bufferCount, "%d ", queryResults[n].mpSpriteBatchItem->getBatchId() );
  846. // Finish early if we run out of buffer space.
  847. if ( bufferCount >= maxBufferSize )
  848. {
  849. // Warn.
  850. Con::warnf("CompositeSprite::pickArea() - Too many items picked to return to scripts!");
  851. break;
  852. }
  853. }
  854. // Clear sprite batch query.
  855. pSpriteBatchQuery->clearQuery();
  856. // Return buffer.
  857. return pBuffer;
  858. }
  859. //-----------------------------------------------------------------------------
  860. ConsoleMethod(CompositeSprite, pickRay, const char*, 4, 6, "(startx/y, endx/y) Picks sprites intersecting the specified ray with optional group/layer masks.\n"
  861. "@param startx/y The coordinates of the start point as either (\"x y\") or (x,y)\n"
  862. "@param endx/y The coordinates of the end point as either (\"x y\") or (x,y)\n"
  863. "@return Returns list of sprite Ids")
  864. {
  865. // Fetch sprite batch query and clear results.
  866. SpriteBatchQuery* pSpriteBatchQuery = object->getSpriteBatchQuery( true );
  867. // Is the sprite batch query available?
  868. if ( pSpriteBatchQuery == NULL )
  869. {
  870. // No, so warn.
  871. Con::warnf( "CompositeSprite::pickRay() - Cannot pick sprites if clipping mode is off." );
  872. // Return nothing.
  873. return NULL;
  874. }
  875. // Upper left and lower right bound.
  876. Vector2 v1, v2;
  877. // The index of the first optional parameter.
  878. U32 firstArg;
  879. // Grab the number of elements in the first two parameters.
  880. U32 elementCount1 = Utility::mGetStringElementCount(argv[2]);
  881. U32 elementCount2 = 1;
  882. if (argc > 3)
  883. elementCount2 = Utility::mGetStringElementCount(argv[3]);
  884. // ("x1 y1 x2 y2")
  885. if ((elementCount1 == 4) && (argc < 9))
  886. {
  887. v1 = Utility::mGetStringElementVector(argv[2]);
  888. v2 = Utility::mGetStringElementVector(argv[2], 2);
  889. firstArg = 3;
  890. }
  891. // ("x1 y1", "x2 y2")
  892. else if ((elementCount1 == 2) && (elementCount2 == 2) && (argc > 3) && (argc < 10))
  893. {
  894. v1 = Utility::mGetStringElementVector(argv[2]);
  895. v2 = Utility::mGetStringElementVector(argv[3]);
  896. firstArg = 4;
  897. }
  898. // (x1, y1, x2, y2)
  899. else if (argc > 5)
  900. {
  901. v1 = Vector2(dAtof(argv[2]), dAtof(argv[3]));
  902. v2 = Vector2(dAtof(argv[4]), dAtof(argv[5]));
  903. firstArg = 6;
  904. }
  905. // Invalid
  906. else
  907. {
  908. Con::warnf("CompositeSprite::pickRay() - Invalid number of parameters!");
  909. return NULL;
  910. }
  911. // Fetch the render transform.
  912. const b2Transform& renderTransform = object->getRenderTransform();
  913. // Transform into local space.
  914. v1 = b2MulT( renderTransform, v1 );
  915. v2 = b2MulT( renderTransform, v2 );
  916. // Perform query.
  917. pSpriteBatchQuery->queryRay( v1, v2, true );
  918. // Sanity!
  919. AssertFatal( pSpriteBatchQuery->getIsRaycastQueryResult(), "Invalid non-ray-cast query result returned." );
  920. // Fetch result count.
  921. const U32 resultCount = pSpriteBatchQuery->getQueryResultsCount();
  922. // Finish if no results.
  923. if (resultCount == 0 )
  924. return NULL;
  925. // Sort ray-cast result.
  926. pSpriteBatchQuery->sortRaycastQueryResult();
  927. // Fetch results.
  928. typeSpriteBatchQueryResultVector& queryResults = pSpriteBatchQuery->getQueryResults();
  929. // Set Max Buffer Size.
  930. const U32 maxBufferSize = 4096;
  931. // Create Returnable Buffer.
  932. char* pBuffer = Con::getReturnBuffer(maxBufferSize);
  933. // Set Buffer Counter.
  934. U32 bufferCount = 0;
  935. // Add Picked Objects to List.
  936. for ( U32 n = 0; n < resultCount; n++ )
  937. {
  938. // Output Object ID.
  939. bufferCount += dSprintf( pBuffer + bufferCount, maxBufferSize-bufferCount, "%d ", queryResults[n].mpSpriteBatchItem->getBatchId() );
  940. // Finish early if we run out of buffer space.
  941. if ( bufferCount >= maxBufferSize )
  942. {
  943. // Warn.
  944. Con::warnf("CompositeSprite::pickRay() - Too many items picked to return to scripts!");
  945. break;
  946. }
  947. }
  948. // Clear sprite batch query.
  949. pSpriteBatchQuery->clearQuery();
  950. // Return buffer.
  951. return pBuffer;
  952. }