Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "scratchpad_gamedll_helpers.h"
  8. #include "iscratchpad3d.h"
  9. #include "player.h"
  10. #include "collisionproperty.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. void ScratchPad_DrawWorldToScratchPad(
  14. IScratchPad3D *pPad,
  15. unsigned long flags )
  16. {
  17. pPad->SetRenderState( IScratchPad3D::RS_FillMode, IScratchPad3D::FillMode_Wireframe );
  18. if ( flags & SPDRAWWORLD_DRAW_WORLD )
  19. {
  20. engine->DrawMapToScratchPad( pPad, 0 );
  21. }
  22. if ( flags & (SPDRAWWORLD_DRAW_PLAYERS | SPDRAWWORLD_DRAW_ENTITIES) )
  23. {
  24. CBaseEntity *pCur = gEntList.FirstEnt();
  25. while ( pCur )
  26. {
  27. bool bPlayer = ( dynamic_cast< CBasePlayer* >( pCur ) != 0 );
  28. if ( (bPlayer && !( flags & SPDRAWWORLD_DRAW_PLAYERS )) ||
  29. (!bPlayer && !( flags & SPDRAWWORLD_DRAW_ENTITIES )) )
  30. {
  31. pCur = gEntList.NextEnt( pCur );
  32. continue;
  33. }
  34. ScratchPad_DrawEntityToScratchPad(
  35. pPad,
  36. flags,
  37. pCur,
  38. bPlayer ? Vector( 1.0, 0.5, 0 ) : Vector( 0.3, 0.3, 1.0 )
  39. );
  40. pCur = gEntList.NextEnt( pCur );
  41. }
  42. }
  43. }
  44. void ScratchPad_DrawEntityToScratchPad(
  45. IScratchPad3D *pPad,
  46. unsigned long flags,
  47. CBaseEntity *pEnt,
  48. const Vector &vColor )
  49. {
  50. // Draw the entity's bbox [todo: draw OBBs here too].
  51. Vector mins, maxs;
  52. pEnt->CollisionProp()->WorldSpaceAABB( &mins, &maxs );
  53. pPad->DrawWireframeBox( mins, maxs, vColor );
  54. // Draw the edict's index or class?
  55. char str[512];
  56. str[0] = 0;
  57. if ( flags & SPDRAWWORLD_DRAW_EDICT_INDICES )
  58. {
  59. char tempStr[512];
  60. Q_snprintf( tempStr, sizeof( tempStr ), "edict: %d", pEnt->entindex() );
  61. Q_strncat( str, tempStr, sizeof( str ), COPY_ALL_CHARACTERS );
  62. }
  63. if ( flags & SPDRAWWORLD_DRAW_ENTITY_CLASSNAMES )
  64. {
  65. if ( str[0] != 0 )
  66. Q_strncat( str, ", ", sizeof( str ), COPY_ALL_CHARACTERS );
  67. char tempStr[512];
  68. Q_snprintf( tempStr, sizeof( tempStr ), "class: %s", pEnt->GetClassname() );
  69. Q_strncat( str, tempStr, sizeof( str ), COPY_ALL_CHARACTERS );
  70. }
  71. if ( str[0] != 0 )
  72. {
  73. CTextParams params;
  74. params.m_vPos = (mins + maxs) * 0.5f;
  75. params.m_bCentered = true;
  76. params.m_flLetterWidth = 2;
  77. pPad->DrawText( str, params );
  78. }
  79. }