Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10196


Ignore:
Timestamp:
Jan 13, 2015, 10:55:12 PM (10 years ago)
Author:
landauf
Message:

added BulletDebugDrawer to Scene.
added console command to enable/disable debug drawing of bullet objects.

Location:
code/trunk/src/orxonox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/Scene.cc

    r10192 r10196  
    4444#include "core/GUIManager.h"
    4545#include "core/XMLPort.h"
     46#include "core/command/ConsoleCommand.h"
    4647#include "tools/BulletConversions.h"
     48#include "tools/BulletDebugDrawer.h"
     49#include "tools/DebugDrawer.h"
    4750#include "Radar.h"
    4851#include "worldentities/WorldEntity.h"
     
    5356    RegisterClass(Scene);
    5457
     58    SetConsoleCommand("Scene", "debugDrawPhysics", &Scene::consoleCommand_debugDrawPhysics).addShortcut().defaultValue(1, true).defaultValue(2, 0.5f);
     59
    5560    Scene::Scene(Context* context) : BaseObject(context), Synchronisable(context), Context(context)
    5661    {
     
    5964        this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN);
    6065        this->bShadows_ = true;
     66        this->bDebugDrawPhysics_ = false;
     67        this->debugDrawer_ = NULL;
    6168        this->soundReferenceDistance_ = 20.0;
    6269
     
    198205            this->physicalWorld_->setGravity(multi_cast<btVector3>(this->gravity_));
    199206
     207            this->debugDrawer_ = new BulletDebugDrawer(this->sceneManager_);
     208            this->physicalWorld_->setDebugDrawer(this->debugDrawer_);
     209
    200210            // also set the collision callback variable.
    201211            // Note: This is a global variable which we assign a static function.
     
    214224            this->physicalObjects_.clear();
    215225
     226            delete this->debugDrawer_;
    216227            delete this->physicalWorld_;
    217228            delete this->solver_;
     
    253264            //       Under that mark, the simulation will "loose time" and get unusable.
    254265            physicalWorld_->stepSimulation(dt, 60);
     266
     267            if (this->bDebugDrawPhysics_)
     268                physicalWorld_->debugDrawWorld();
    255269        }
    256270    }
     
    358372        return modified;
    359373    }
     374
     375    void Scene::setDebugDrawPhysics(bool bDraw, bool bFill, float fillAlpha)
     376    {
     377        this->bDebugDrawPhysics_ = bDraw;
     378        if (this->debugDrawer_)
     379            this->debugDrawer_->configure(bFill, fillAlpha);
     380    }
     381
     382    /*static*/ void Scene::consoleCommand_debugDrawPhysics(bool bDraw, bool bFill, float fillAlpha)
     383    {
     384        for (ObjectListIterator<Scene> it = ObjectList<Scene>::begin(); it != ObjectList<Scene>::end(); ++it)
     385            it->setDebugDrawPhysics(bDraw, bFill, fillAlpha);
     386    }
    360387}
  • code/trunk/src/orxonox/Scene.h

    r9667 r10196  
    129129            void removePhysicalObject(WorldEntity* object);
    130130
     131            void setDebugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
     132
     133            static void consoleCommand_debugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
     134
    131135        private:
    132136            inline void networkcallback_hasPhysics()
     
    156160            Vector3                              positiveWorldRange_;
    157161            Vector3                              gravity_;
     162
     163            BulletDebugDrawer*                   debugDrawer_;
     164            bool                                 bDebugDrawPhysics_;
    158165    };
    159166}
Note: See TracChangeset for help on using the changeset viewer.