@@ -41,7 +41,7 @@ ConsoleGetType( Typeb2AABB )
4141
4242 // Format AABB.
4343 char * pBuffer = Con::getReturnBuffer (64 );
44- dSprintf (pBuffer, 64 , " %.5g %.5g" , pAABB->lowerBound .x , pAABB->lowerBound .y , pAABB->upperBound .x , pAABB->upperBound .y );
44+ dSprintf (pBuffer, 64 , " %.5g %.5g %.5g %.5g " , pAABB->lowerBound .x , pAABB->lowerBound .y , pAABB->upperBound .x , pAABB->upperBound .y );
4545 return pBuffer;
4646}
4747
@@ -327,4 +327,71 @@ U32 mGetStringElementCount( const char* inString )
327327 return wordCount;
328328}
329329
330+ // -----------------------------------------------------------------------------
331+
332+ U32 mConvertStringToMask ( const char * string )
333+ {
334+ // Grab the element count of the first parameter.
335+ const U32 elementCount = Utility::mGetStringElementCount (string);
336+
337+ // Make sure we get at least one number.
338+ if (elementCount < 1 )
339+ return MASK_ALL;
340+ else if ( elementCount == 1 )
341+ {
342+ if ( dStricmp ( string, " all" ) == 0 )
343+ return MASK_ALL;
344+ else if ( dStricmp ( string, " none" ) == 0 || dStricmp ( string, " off" ) == 0 )
345+ return 0 ;
346+ }
347+
348+ // The mask.
349+ U32 mask = 0 ;
350+
351+ // Convert the string to a mask.
352+ for (U32 i = 0 ; i < elementCount; i++)
353+ {
354+ S32 bit = dAtoi (Utility::mGetStringElement (string, i));
355+
356+ // Make sure the group is valid.
357+ if ((bit < 0 ) || (bit >= MASK_BITCOUNT))
358+ {
359+ Con::warnf (" Utility::mConvertStringToMask() - Invalid group specified (%d); skipped!" , bit);
360+ continue ;
361+ }
362+
363+ mask |= (1 << bit);
364+ }
365+
366+ return mask;
367+ }
368+
369+ // -----------------------------------------------------------------------------
370+
371+ const char * mConvertMaskToString ( const U32 mask )
372+ {
373+ bool first = true ;
374+ static char bits[128 ];
375+ bits[0 ] = ' \0 ' ;
376+
377+ if (!mask)
378+ {
379+ dSprintf (bits, 8 , " none" );
380+ return bits;
381+ }
382+
383+ for (S32 i = 0 ; i < MASK_BITCOUNT; i++)
384+ {
385+ if (mask & BIT (i))
386+ {
387+ char bit[4 ];
388+ dSprintf (bit, 4 , " %s%d" , first ? " " : " " , i);
389+ first = false ;
390+ dStrcat (bits, bit);
391+ }
392+ }
393+
394+ return bits;
395+ }
396+
330397} // Namespace Utility
0 commit comments