Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8213 in orxonox.OLD for branches/bsp_model/src/lib


Ignore:
Timestamp:
Jun 7, 2006, 9:06:41 PM (18 years ago)
Author:
patrick
Message:

bsp: integrating the bspmanager fully into the collision detection/reaction system

Location:
branches/bsp_model/src/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/collision_detection/cd_engine.cc

    r8186 r8213  
    1919#include "obb_tree.h"
    2020#include "debug.h"
     21
     22#include "class_list.h"
    2123
    2224#include "model.h"
     
    9799void CDEngine::checkCollisionGround(std::list<WorldEntity*>& list1)
    98100{
    99   if( likely( this->terrain != NULL))
    100   {
    101     Quadtree* q = dynamic_cast<Terrain*>(this->terrain)->ssp->getQuadtree();
    102 //    QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor());
    103   }
    104  
    105   if( likely( this->bspManager != NULL))
    106   {
    107     std::list<WorldEntity*>::iterator iterator;
    108     PRINTF(3)("checking for collisions\n");
    109101
    110     iterator = list1.begin();
    111     while (iterator != list1.end())
    112     {
    113       bspManager->checkCollision(*iterator);
    114       iterator++;
    115     }
     102  std::list<WorldEntity*>::iterator entityIterator;
     103  std::list<BaseObject*>::const_iterator bspIterator;
     104  const std::list<BaseObject*>* list = ClassList::getList(CL_BSP_MODEL);
     105
     106  // for all bsp managers check all entities
     107  for( bspIterator = list->begin(); bspIterator != list->end(); bspIterator++) {
     108      for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
     109        static_cast<BspManager*>(*bspIterator)->checkCollision(*entityIterator);
    116110  }
    117111}
  • branches/bsp_model/src/lib/collision_reaction/collision_handle.cc

    r8190 r8213  
    2424
    2525#include "cr_object_damage.h"
     26#include "cr_physics_ground_walk.h"
    2627
    2728using namespace std;
     
    4243  this->bDispatched = false;
    4344
    44   if( this->type == CREngine::CR_PHYSICS_STEP_BACK)
    45     this->bContinuousPoll = false;
    46   else
    47     this->bContinuousPoll = true;
    48 
    49   if( this->type == CREngine::CR_OBJECT_DAMAGE)
    50     this->bStopOnFirstCollision = true;
    51   else
    52    this->bStopOnFirstCollision = false;
     45  this->collisionReaction = NULL;
     46  this->bContinuousPoll = true;
     47  this->bStopOnFirstCollision = false;
     48
    5349
    5450  switch( type)
    5551  {
     52    case CREngine::CR_PHYSICS_STEP_BACK:
     53//       this->collisionReaction = new CRPhysicsGroundWalk();
     54      this->bContinuousPoll = true;
     55      break;
     56    case CREngine::CR_PHYSICS_GROUND_WALK:
     57      this->collisionReaction = new CRPhysicsGroundWalk();
     58      break;
    5659    case CREngine::CR_OBJECT_DAMAGE:
    5760      this->collisionReaction = new CRObjectDamage();
     61      this->bStopOnFirstCollision = true;
    5862      break;
    5963    default:
     
    6973{
    7074  // delete what has to be deleted here
     75  if( this->collisionReaction != NULL)
     76    delete this->collisionReaction;
    7177}
    7278
  • branches/bsp_model/src/lib/collision_reaction/cr_engine.cc

    r8190 r8213  
    124124{
    125125  std::vector<CollisionHandle*>::iterator it;
    126   for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)
    127   {
    128     if( *it == collisionHandle)
    129     {
     126  for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)  {
     127    if( *it == collisionHandle) {
    130128      this->collisionHandles.erase(it);
    131129      delete collisionHandle;
  • branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc

    r8204 r8213  
    7777void BspManager::load(const char* fileName, float scale)
    7878{
    79   //this->setClassID(CL_BSP_MODEL, "BspManager");
     79  this->setClassID(CL_BSP_MODEL, "BspManager");
    8080  // open a BSP file
    8181  this->bspFile = new BspFile();
  • branches/bsp_model/src/lib/graphics/importer/bsp_manager.h

    r8195 r8213  
    11/*
    22   orxonox - the future of 3D-vertical-scrollers
    3  
     3
    44   Copyright (C) 2006 orx
    5  
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 2, or (at your option)
    99   any later version.
    10  
     10
    1111   ### File Specific:
    1212   main-programmer: bottac@ee.ethz.ch
    13    
     13
    1414   Inspired by:
    1515   Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
    1616   Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
    17    
     17
    1818   Collision detection adapted from:
    1919   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
     
    2222#include <vector>
    2323#include <deque>
     24
     25#include "base_object.h"
    2426
    2527// FORWARD DECLARATIONS
     
    4143};
    4244
    43 class BspManager
     45class BspManager : public BaseObject
    4446{
    4547public:
    4648  // Constructors
    4749  BspManager();
    48  
     50
    4951  BspManager(const char* fileName, float scale = 0.4f);
    5052  void load(const char* fileName, float scale);
     
    5355  const void draw();
    5456  const void tick(float time);
    55   void draw_debug_face(int Face); 
     57  void draw_debug_face(int Face);
    5658  void draw_face(int Face);
    5759  void draw_patch(face* Face);
    58  
     60
    5961
    6062  void checkCollision(WorldEntity* worldEntity); /*!< WorldEntities use this function to check wheter they collided with the BSPEntity.
     
    6567  BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
    6668  void  checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only!
    67   void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end); 
     69  void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
    6870  void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
    6971  void TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
     
    7476  bool isAlreadyVisible(int Face);
    7577  void addFace(int Face);
    76  
     78
    7779  // Data
    7880  BspFile*  bspFile;
     
    8385  plane* collPlane;
    8486  int lastTex;
    85  
     87
    8688  //obsolete: global variables for collision detection
    8789  bool  outputStartsOut;
     
    9092  Vector traceMins; //!< Mins of current bbox
    9193  Vector traceMaxs; //!< Maxs of current bbox
    92   Vector traceExtents; /*!< Stores the maximum of the absolute value of each axis in the box. 
     94  Vector traceExtents; /*!< Stores the maximum of the absolute value of each axis in the box.
    9395                            For example, if traceMins was (-100,-3,-15) and traceMaxs was (55,22,7), traceExtents */
    94  
    95  
     96
     97
    9698  bool * alreadyVisible;
    9799  // Deques to store the visible faces
     
    100102
    101103  Vector out;  //!< For debugging only
    102   Vector out1; //!< For debugging only 
     104  Vector out1; //!< For debugging only
    103105  Vector out2; //!< For debugging only
    104106};
Note: See TracChangeset for help on using the changeset viewer.