Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5398 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Oct 18, 2005, 6:28:54 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: fixed a bug in the allocation of Element2D

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_detection/lin_alg.h

    r5039 r5398  
    117117    }
    118118  } //end of main i loop
    119   printf("\n 50 iterations !\n");
     119//  printf("\n 50 iterations !\n");
    120120  return;  //too many iterations
    121121}
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5397 r5398  
    113113  this->setActiveness(true);
    114114  this->setAlignment(E2D_ALIGN_NONE);
    115   this->layer = E2D_TOP;
     115  this->layer = E2D_DEFAULT_LAYER;
    116116  this->bindNode = NULL;
    117117
     
    214214{
    215215  if (!strcmp(layer, "top"))
    216     this->setLayer(E2D_TOP);
     216    this->setLayer(E2D_LAYER_TOP);
    217217  else if (!strcmp(layer, "medium"))
    218     this->setLayer(E2D_MEDIUM);
     218    this->setLayer(E2D_LAYER_MEDIUM);
    219219  else if (!strcmp(layer, "bottom"))
    220     this->setLayer(E2D_BOTTOM);
     220    this->setLayer(E2D_LAYER_BOTTOM);
    221221  else if (!strcmp(layer, "below-all"))
    222     this->setLayer(E2D_BELOW_ALL);
     222    this->setLayer(E2D_LAYER_BELOW_ALL);
    223223}
    224224
  • trunk/src/lib/graphics/render2D/element_2d.h

    r5397 r5398  
    2121typedef enum
    2222{
    23   E2D_BELOW_ALL,       //!< Will be rendered below the 3D-scene. @todo make this work.
    24   E2D_BOTTOM,          //!< Will be rendered on the bottom Layer
    25   E2D_MEDIUM,          //!< Will be rendered on the medium Layer.
    26   E2D_TOP,             //!< Will be rendered on top of everything else
    27 
    28   E2D_LAYER_COUNT,     //!< The count of Layers.
    29 
    30   E2D_LAYER_ALL,
     23  E2D_LAYER_BELOW_ALL           =     0,        //!< Will be rendered below the 3D-scene. @todo make this work.
     24  E2D_LAYER_BOTTOM              =     1,        //!< Will be rendered on the bottom Layer
     25  E2D_LAYER_MEDIUM              =     2,        //!< Will be rendered on the medium Layer.
     26  E2D_LAYER_TOP                 =     3,        //!< Will be rendered on top of everything else
     27
     28  E2D_LAYER_COUNT               =     4,         //!< The count of Layers.
     29
     30  E2D_LAYER_ALL                 =     5,
    3131} E2D_LAYER;
    32 #define E2D_DEFAULT_LAYER       E2D_TOP
     32#define E2D_DEFAULT_LAYER       E2D_LAYER_MEDIUM
    3333
    3434typedef enum
     
    8181    void setLayer(const char* layer);
    8282    /** @returns the Layer this Element is drawn to */
    83     inline E2D_LAYER getLayer() { return this->layer; };
     83    inline E2D_LAYER getLayer() const { return this->layer; };
    8484
    8585    /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
  • trunk/src/lib/graphics/render2D/render_2d.cc

    r5397 r5398  
    1414*/
    1515
    16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
    1717
    1818#include "render_2d.h"
     
    6666void Render2D::registerElement2D(Element2D* element2D)
    6767{
    68   if (likely(element2D != NULL))
    69     this->element2DList[E2D_DEFAULT_LAYER]->add(element2D);
     68  if (likely(element2D != NULL) && element2D->getLayer() < E2D_LAYER_COUNT)
     69    this->element2DList[element2D->getLayer()]->add(element2D);
     70  // DEBUG printf("::::%p, %d %d \n", element2D, element2D->getLayer(), this->element2DList[element2D->getLayer()]->getSize());
    7071}
    7172
     
    7980void Render2D::unregisterElement2D(Element2D* element2D)
    8081{
    81   this->element2DList[element2D->getLayer()]->remove(element2D);
     82  if (likely(element2D != NULL) && element2D->getLayer() < E2D_LAYER_COUNT)
     83    this->element2DList[element2D->getLayer()]->remove(element2D);
     84    // DEBUG  printf(":::%s layer: %d, %d\n", element2D->getClassName(), element2D->getLayer(), this->element2DList[element2D->getLayer()]->getSize());
    8285}
    8386
     
    9396    return;
    9497
    95   if (E2D_LAYER_COUNT  > to)
     98  if (E2D_LAYER_COUNT  < to)
    9699    to = E2D_DEFAULT_LAYER;
    97   if (element2D->getLayer() != to)
     100  if (likely(element2D->getLayer() != to))
    98101  {
    99102    this->element2DList[element2D->getLayer()]->remove(element2D);
     
    127130 * @param layer the Layer to draw (if E2D_LAYER_ALL then all layers will be drawn)
    128131 */
    129 void Render2D::draw(unsigned int layer) const
     132void Render2D::draw(E2D_LAYER layer) const
    130133{
    131134  GraphicsEngine::enter2DMode();
     
    133136  if (layer != E2D_LAYER_ALL)
    134137  {
    135     if ( this->element2DList[layer]->getSize() > 0)
     138    if (likely(this->element2DList[layer]->getSize() > 0))
    136139    {
    137140      tIterator<Element2D>* iterator = this->element2DList[layer]->getIterator();
  • trunk/src/lib/graphics/render2D/render_2d.h

    r5397 r5398  
    2323
    2424    void tick(float dt);
    25     void draw(unsigned int layer) const;
     25    void draw(E2D_LAYER layer) const;
    2626
    2727
  • trunk/src/lib/shell/shell.cc

    r5397 r5398  
    125125  if (this->bActive == true)
    126126    PRINTF(3)("The shell is already active\n");
    127 
    128   printf("ACT\n");
    129127  this->bActive = true;
    130128
  • trunk/src/world_entities/weapons/crosshair.cc

    r5396 r5398  
    6363  this->setName("Crosshair");
    6464
    65   this->setLayer(E2D_TOP);
     65  this->setLayer(E2D_LAYER_TOP);
    6666  this->setRotationSpeed(5);
    6767  this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0);
Note: See TracChangeset for help on using the changeset viewer.