- Timestamp:
- Dec 16, 2005, 7:13:57 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 2 deleted
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/defs/debug.h
r5996 r6142 110 110 #endif 111 111 #ifndef NO_SHELL 112 #define PRINT_EXEC printf //ShellBuffer::addBufferLineStatic112 #define PRINT_EXEC ShellBuffer::addBufferLineStatic 113 113 #else /* NO_SHELL */ 114 114 #define PRINT_EXEC printf -
trunk/src/lib/collision_detection/cd_engine.cc
r6022 r6142 65 65 be able to enhance iteration speed. 66 66 */ 67 void CDEngine::checkCollisions()68 {69 this->checkCollisionObjects();67 //void CDEngine::checkCollisions() 68 //{ 69 // this->checkCollisionObjects(); 70 70 //this->checkCollisionGround(); 71 } 72 73 #include "class_list.h" 74 #include "state.h" 71 //} 72 75 73 /** 76 74 * this checks the collisions with the objects 77 75 */ 78 void CDEngine::checkCollisionObjects() 76 //void CDEngine::checkCollisionObjects() 77 //{ 78 // BVTree* tree; 79 // tIterator<WorldEntity>* iterator1 = entityList->getIterator(); 80 // tIterator<WorldEntity>* iterator2 = entityList->getIterator(); 81 // WorldEntity* entity1 = iterator1->firstElement(); 82 // WorldEntity* entity2 = iterator2->iteratorElement(iterator1); 83 // PRINTF(3)("checking for collisions\n"); 84 // while( entity1 != NULL) 85 // { 86 // if( likely(entity1 != this->terrain)) 87 // { 88 // entity2 = iterator2->nextElement(); 89 // 90 // while( entity2 != NULL) 91 // { 92 // if( likely(entity2 != this->terrain)) 93 // { 94 // PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName()); 95 // tree = entity1->getOBBTree(); 96 // if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1, entity2); 97 // } 98 // entity2 = iterator2->nextElement(); 99 // } 100 // } 101 // entity1 = iterator1->nextElement(); 102 // entity2 = iterator2->iteratorElement(iterator1); 103 // entity2 = iterator2->nextElement(); 104 // } 105 // delete iterator1; 106 // delete iterator2; 107 //} 108 109 void CDEngine::checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2) 79 110 { 80 111 BVTree* tree; 81 tIterator<WorldEntity>* iterator1 = entityList->getIterator(); 82 tIterator<WorldEntity>* iterator2 = entityList->getIterator(); 83 WorldEntity* entity1 = iterator1->firstElement(); 84 WorldEntity* entity2 = iterator2->iteratorElement(iterator1); 112 std::list<WorldEntity*>::iterator entity1, entity2, pre1, pre2; 85 113 PRINTF(3)("checking for collisions\n"); 86 while( entity1 != NULL) 114 115 pre1 = list1.begin(); 116 while (pre1 != list1.end()) 87 117 { 88 if( likely(entity1 != this->terrain)) 118 entity1 = pre1++; 119 if( likely((*entity1) != this->terrain)) 89 120 { 90 entity2 = iterator2->nextElement(); 91 92 while( entity2 != NULL) 121 pre2 = list2.begin(); 122 while (pre2 != list2.end()) 93 123 { 94 if( likely(entity2 != this->terrain)) 124 entity2 = pre2++; 125 if( likely((*entity2) != this->terrain)) 95 126 { 96 PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName());97 tree = entity1->getOBBTree();98 if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1,entity2);127 PRINTF(4)("checking object %s against %s\n", (*entity1)->getName(), (*entity2)->getName()); 128 tree = (*entity1)->getOBBTree(); 129 if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL) tree->collideWith(*entity1, *entity2); 99 130 } 100 entity2 = iterator2->nextElement();101 131 } 102 132 } 103 entity1 = iterator1->nextElement();104 entity2 = iterator2->iteratorElement(iterator1);105 entity2 = iterator2->nextElement();106 133 } 107 delete iterator1;108 delete iterator2;109 134 } 110 135 … … 134 159 /* this would operate on worldList bases, for testing purposes, we only use one OBBTree */ 135 160 //this->rootTree->drawBV(depth, drawMode); 136 137 tIterator<WorldEntity>* iterator = entityList->getIterator();161 /// FIXME 162 /* tIterator<WorldEntity>* iterator = entityList->getIterator(); 138 163 WorldEntity* entity = iterator->firstElement(); 139 164 while( entity != NULL) … … 142 167 entity = iterator->nextElement(); 143 168 } 144 delete iterator; 169 delete iterator;*/ 145 170 } 146 171 -
trunk/src/lib/collision_detection/cd_engine.h
r6022 r6142 12 12 #include "model.h" 13 13 14 #include <list> 14 15 15 template<class T> class tList;16 16 class WorldEntity; 17 17 class OBBTree; … … 49 49 inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; } 50 50 51 inline void setEntityList(tList<WorldEntity>* entityList) { this->entityList = entityList; }52 51 inline void setTerrain(Terrain* terrain) { this->terrain = terrain; } 53 52 // inline void setPlayer(Player* player) { this->player = player; } /* only for debug purposes \todo: delete*/ … … 55 54 void drawBV(int depth, int drawMode) const; 56 55 57 void checkCollisions(); 56 // void checkCollisions(); 57 void checkCollisions(std::list<WorldEntity*>& list1, std::list<WorldEntity*>& list2); 58 58 59 59 void debug(); … … 75 75 private: 76 76 int state; //!< the current state of the cd engine 77 tList<WorldEntity>* entityList; //!< pointer to the world entity list78 77 OBBTree* rootTree; //!< for testing purposes a root tree 79 78 -
trunk/src/lib/coord/p_node.cc
r6078 r6142 81 81 { 82 82 deleteNode = tmp; 83 ++tmp;83 tmp++; 84 84 // printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName()); 85 85 if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) || … … 470 470 this->getClassName(), this->getName(), child->getClassName(), child->getName()); 471 471 child->parent = NULL; 472 child->parentCoorChanged(); 472 473 } 473 474 } … … 536 537 if (this->parentMode & PNODE_REPARENT_CHILDREN_ON_REMOVE || 537 538 (*reparenter)->parentMode & PNODE_REPARENT_ON_PARENTS_REMOVE) 538 { printf("TEST----------------%s ---- %s\n", this->getClassName(), (*reparenter)->getClassName()); 539 { 540 printf("TEST----------------%s ---- %s\n", this->getClassName(), (*reparenter)->getClassName()); 539 541 (*reparenter)->reparent(); 540 542 printf("REPARENTED TO: %s::%s\n",(*reparenter)->getParent()->getClassName(),(*reparenter)->getParent()->getName()); … … 542 544 } 543 545 if (this->parent != NULL) 546 { 544 547 this->parent->eraseChild(this); 548 this->parent = NULL; 549 } 545 550 } 546 551 -
trunk/src/lib/coord/p_node.h
r6078 r6142 79 79 80 80 // ACTIVATION // 81 inline void activateNode() { this->bActive = t rue; };81 inline void activateNode() { this->bActive = this->bRelCoorChanged = this->bRelDirChanged = true; }; 82 82 inline void deactivateNode() { this->bActive = false; }; 83 83 inline bool getNodeActiveState() { return this->bActive; }; -
trunk/src/lib/graphics/graphics_engine.cc
r6011 r6142 19 19 #include "resource_manager.h" 20 20 #include "event_handler.h" 21 22 #include "world_entity.h" 21 23 22 24 #include "render_2d.h" … … 573 575 } 574 576 577 void GraphicsEngine::draw(const std::list<WorldEntity*>& drawList ) const 578 { 579 std::list<WorldEntity*>::const_iterator entity; 580 for (entity = drawList.begin(); entity != drawList.end(); entity++) 581 if ((*entity)->isVisible()) 582 (*entity)->draw(); 583 } 584 585 575 586 /** 576 587 * displays the Frames per second -
trunk/src/lib/graphics/graphics_engine.h
r5857 r6142 15 15 #include "glincl.h" 16 16 17 #include <list> 18 17 19 // Forward Declaration 18 20 class Text; 19 21 class IniParser; 20 22 class SubString; 23 class WorldEntity; 21 24 22 25 //! class to handle graphics … … 66 69 void tick(float dt); 67 70 void draw() const; 71 void draw(const std::list<WorldEntity*>& drawList) const; 68 72 void displayFPS(bool display); 69 73 -
trunk/src/lib/graphics/render2D/element_2d.cc
r5944 r6142 18 18 #include "element_2d.h" 19 19 #include "render_2d.h" 20 21 #include <algorithm> 20 22 21 23 #include "p_node.h" … … 82 84 if (this->parent != NULL) 83 85 { 84 this->parent-> children.remove(this);86 this->parent->eraseChild(this); 85 87 this->parent = NULL; 86 88 } … … 512 514 { 513 515 PRINTF(5)("Element2D::addChild() - reparenting node: removing it and adding it again\n"); 514 child->parent-> children.remove(child);516 child->parent->eraseChild(child); 515 517 } 516 518 child->parent = this; … … 581 583 if (this->parent != NULL) 582 584 { 583 this->parent-> children.remove(this);585 this->parent->eraseChild(this); 584 586 this->parent = NULL; 585 587 } … … 655 657 if (parentNode != NULL) 656 658 this->setParentSoft2D(parentNode, bias); 659 } 660 661 /** @param child the child to be erased from this Nodes List */ 662 void Element2D::eraseChild(Element2D* child) 663 { 664 std::list<Element2D*>::iterator childIT = std::find(this->children.begin(), this->children.end(), child); 665 this->children.erase(childIT); 657 666 } 658 667 … … 733 742 else if (unlikely(this->bindNode != NULL)) 734 743 { 735 GLdouble projectPos[3] ;744 GLdouble projectPos[3] = {0, 0, 0}; 736 745 gluProject(this->bindNode->getAbsCoor().x, 737 746 this->bindNode->getAbsCoor().y, -
trunk/src/lib/graphics/render2D/element_2d.h
r5775 r6142 195 195 196 196 private: 197 void eraseChild(Element2D* child); 197 198 /** tells the child that the parent's Coordinate has changed */ 198 199 inline void parentCoorChanged () { this->bRelCoorChanged = true; } -
trunk/src/lib/sound/sound_engine.cc
r6076 r6142 141 141 if (!this->ALSources.empty()) 142 142 { 143 144 143 source = this->ALSources.top(); 145 printf("test: : %d\n", source);146 144 this->ALSources.pop(); 147 145 } -
trunk/src/lib/sound/sound_source.cc
r6139 r6142 69 69 SoundEngine::getInstance()->popALSource(this->sourceID); 70 70 71 //printf("%d\n",sourceID);72 71 alSourceStop(this->sourceID); 73 72 alSourcei (this->sourceID, AL_BUFFER, buffer->getID()); -
trunk/src/orxonox.cc
r6139 r6142 43 43 #include "text_engine.h" 44 44 #include "event_handler.h" 45 #include "garbage_collector.h"46 45 47 46 #include "factory.h" … … 96 95 // game-specific 97 96 delete GameLoader::getInstance(); 98 delete GarbageCollector::getInstance();99 97 100 98 // class-less services/factories -
trunk/src/story_entities/network_world.cc
r6139 r6142 38 38 #include "shell.h" 39 39 40 #include "garbage_collector.h"41 40 #include "fast_factory.h" 42 41 #include "animation_player.h" … … 123 122 PRINTF(3)("NetworkWorld::~NetworkWorld() - deleting current world\n"); 124 123 125 126 // here everything that is alocated by the NetworkWorld is deleted127 delete this->entities;128 State::setWorldEntityList(NULL);129 130 124 delete this->localPlayer; 131 125 … … 141 135 SoundEngine::getInstance()->flushAllSources(); 142 136 143 137 if (State::getObjectManager() == &this->objectManager) 138 State::setObjectManager(NULL); 144 139 // erease everything that is left. 145 140 delete PNode::getNullParent(); … … 180 175 this->music = NULL; 181 176 this->shell = NULL; 182 this->entities = NULL;183 177 this->localPlayer = NULL; 184 178 this->localCamera = NULL; … … 214 208 ErrorMessage NetworkWorld::preLoad() 215 209 { 216 State::set WorldEntityList(this->entities = new tList<WorldEntity>());210 State::setObjectManager(&this->objectManager); 217 211 this->cycle = 0; 218 212 … … 233 227 234 228 GraphicsEngine::getInstance()->displayFPS(true); 235 236 CDEngine::getInstance()->setEntityList( this->entities);237 229 } 238 230 … … 630 622 631 623 /** 632 * gets the list of entities from the world633 * @returns entity list634 */635 tList<WorldEntity>* NetworkWorld::getEntities()636 {637 return this->entities;638 }639 640 641 /**642 624 * this returns the current game time 643 625 * @returns elapsed game time … … 648 630 } 649 631 650 651 632 /** 652 633 * function to put your own debug stuff into it. it can display informations about 653 634 the current class/procedure 654 635 */ 655 void NetworkWorld::debug()656 {657 PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");658 tIterator<WorldEntity>* iterator = this->entities->getIterator();659 WorldEntity* entity = iterator->firstElement();660 while( entity != NULL)661 {662 PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());663 entity = iterator->nextElement();664 }665 delete iterator;666 }636 // void NetworkWorld::debug() 637 // { 638 // PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n"); 639 // tIterator<WorldEntity>* iterator = this->entities->getIterator(); 640 // WorldEntity* entity = iterator->firstElement(); 641 // while( entity != NULL) 642 // { 643 // PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName()); 644 // entity = iterator->nextElement(); 645 // } 646 // delete iterator; 647 // } 667 648 668 649 … … 682 663 { 683 664 ++this->cycle; 684 PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());665 // PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize()); 685 666 // Network 686 667 this->synchronize (); … … 727 708 } 728 709 710 void NetworkWorld::tick(std::list<WorldEntity*> entityList, float dt) 711 { 712 std::list<WorldEntity*>::iterator entity; 713 for (entity = entityList.begin(); entity != entityList.end(); entity++) 714 (*entity)->tick(dt); 715 716 } 729 717 730 718 /** … … 763 751 this->gameTime += this->dtS; 764 752 765 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 766 WorldEntity* entity = iterator->firstElement(); 767 while( entity != NULL) 768 { 769 entity->tick (this->dtS); 770 entity = iterator->nextElement(); 771 } 772 delete iterator; 753 /* this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS); 754 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS); 755 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/ 756 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS); 757 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS); 773 758 774 759 /* update tick the rest */ … … 780 765 781 766 ParticleEngine::getInstance()->tick(this->dtS); 782 GarbageCollector::getInstance()->tick(this->dtS);783 767 784 768 … … 805 789 void NetworkWorld::update() 806 790 { 807 GarbageCollector::getInstance()->update();808 791 GraphicsEngine::getInstance()->update(this->dtS); 809 792 PNode::getNullParent()->updateNode (this->dtS); … … 816 799 void NetworkWorld::collide() 817 800 { 818 CDEngine::getInstance()->checkCollisions(); 801 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00), 802 this->objectManager.getObjectList(OM_GROUP_01_PROJ)); 803 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01), 804 this->objectManager.getObjectList(OM_COMMON)); 819 805 } 820 806 … … 846 832 void NetworkWorld::draw () 847 833 { 848 /* draw entities */ 849 WorldEntity* entity; 850 glLoadIdentity(); 851 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 852 entity = iterator->firstElement(); 853 while( entity != NULL ) 854 { 855 if( entity->isVisible() ) entity->draw(); 856 if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 857 entity = iterator->nextElement(); 858 } 859 delete iterator; 834 GraphicsEngine* engine = GraphicsEngine::getInstance(); 835 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 836 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON)); 837 engine->draw(State::getObjectManager()->getObjectList(OM_COMMON)); 838 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00)); 839 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01)); 840 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 841 842 // { 843 // if( entity->isVisible() ) entity->draw(); 844 //FIXME 845 // if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 846 // entity = iterator->nextElement(); 847 // } 860 848 861 849 glCallList (objectList); … … 866 854 PNode::getNullParent()->debugDraw(0); 867 855 868 GraphicsEngine::getInstance()->draw();856 engine->draw(); 869 857 //TextEngine::getInstance()->draw(); 870 858 } … … 876 864 void NetworkWorld::spawn(WorldEntity* entity) 877 865 { 878 this->entities->add (entity);866 // this->entities->add (entity); 879 867 entity->postSpawn (); 880 868 } … … 889 877 void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir) 890 878 { 891 this->entities->add (entity);879 // this->entities->add (entity); 892 880 893 881 entity->setAbsCoor (*absCoor); … … 915 903 entity->setRelDir (*relDir); 916 904 917 this->entities->add (entity);905 // this->entities->add (entity); 918 906 919 907 entity->postSpawn (); -
trunk/src/story_entities/network_world.h
r6139 r6142 11 11 #include "story_entity.h" 12 12 #include "p_node.h" 13 #include "object_manager.h" 13 14 14 15 class NetworkWorld; 16 15 17 class WorldEntity; 16 18 class Camera; … … 18 20 class GLMenuImageScreen; 19 21 class Terrain; 20 class GarbageCollector;21 class Text;22 22 class TiXmlElement; 23 23 24 24 class Shell; 25 25 class OggPlayer; 26 template<class T> class tList;27 26 28 27 //! The game world … … 61 60 bool command (Command* cmd); 62 61 63 tList<WorldEntity>* getEntities();64 65 62 /* interface to world */ 66 63 void spawn (WorldEntity* entity); … … 84 81 void synchronize (); 85 82 void handleInput (); 83 void tick (std::list<WorldEntity*> worldEntity, float dt); 86 84 void tick (); 87 85 void update (); … … 104 102 bool bPause; //!< pause mode 105 103 104 ObjectManager objectManager; //!< The ObjectManager of this World. 105 106 106 GLMenuImageScreen* glmis; //!< The Level-Loader Display 107 107 … … 118 118 119 119 GLuint objectList; //!< temporary: @todo this will be ereased soon 120 tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. 120 121 121 Player* localPlayer; //!< The Player, you fly through the level. 122 122 }; -
trunk/src/story_entities/world.cc
r6074 r6142 38 38 #include "shell.h" 39 39 40 #include "garbage_collector.h"41 40 #include "fast_factory.h" 42 41 #include "animation_player.h" … … 123 122 PRINTF(3)("World::~World() - deleting current world\n"); 124 123 125 126 // here everything that is alocated by the World is deleted127 delete this->entities;128 State::setWorldEntityList(NULL);129 130 124 delete this->localPlayer; 131 125 … … 141 135 SoundEngine::getInstance()->flushAllSources(); 142 136 143 137 if (State::getObjectManager() == &this->objectManager) 138 State::setObjectManager(NULL); 144 139 // erease everything that is left. 145 140 delete PNode::getNullParent(); … … 180 175 this->music = NULL; 181 176 this->shell = NULL; 182 this->entities = NULL;183 177 this->localPlayer = NULL; 184 178 this->localCamera = NULL; … … 214 208 ErrorMessage World::preLoad() 215 209 { 216 State::set WorldEntityList(this->entities = new tList<WorldEntity>());210 State::setObjectManager(&this->objectManager); 217 211 this->cycle = 0; 218 212 … … 233 227 234 228 GraphicsEngine::getInstance()->displayFPS(true); 235 236 CDEngine::getInstance()->setEntityList( this->entities);237 229 } 238 230 … … 588 580 589 581 /** 590 * gets the list of entities from the world591 * @returns entity list592 */593 tList<WorldEntity>* World::getEntities()594 {595 return this->entities;596 }597 598 599 /**600 582 * this returns the current game time 601 583 * @returns elapsed game time … … 605 587 return this->gameTime; 606 588 } 607 608 609 /**610 * function to put your own debug stuff into it. it can display informations about611 the current class/procedure612 */613 void World::debug()614 {615 PRINTF(0)("Printing out the List of alive WorldEntities:\n");616 tIterator<WorldEntity>* iterator = this->entities->getIterator();617 WorldEntity* entity = iterator->firstElement();618 while( entity != NULL)619 {620 PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());621 entity = iterator->nextElement();622 }623 delete iterator;624 }625 626 589 627 590 /** … … 640 603 { 641 604 ++this->cycle; 642 PRINTF(4)("World::mainloop() - number of entities: %i\n", this->entities->getSize());643 605 // Network 644 606 this->synchronize (); … … 685 647 } 686 648 649 void World::tick(std::list<WorldEntity*> entityList, float dt) 650 { 651 std::list<WorldEntity*>::iterator entity; 652 for (entity = entityList.begin(); entity != entityList.end(); entity++) 653 (*entity)->tick(dt); 654 655 } 687 656 688 657 /** … … 721 690 this->gameTime += this->dtS; 722 691 723 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 724 WorldEntity* entity = iterator->firstElement(); 725 while( entity != NULL) 726 { 727 entity->tick (this->dtS); 728 entity = iterator->nextElement(); 729 } 730 delete iterator; 692 /* this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS); 693 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS); 694 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/ 695 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS); 696 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS); 731 697 732 698 /* update tick the rest */ … … 738 704 739 705 ParticleEngine::getInstance()->tick(this->dtS); 740 GarbageCollector::getInstance()->tick(this->dtS);741 706 742 707 … … 763 728 void World::update() 764 729 { 765 GarbageCollector::getInstance()->update();766 730 GraphicsEngine::getInstance()->update(this->dtS); 767 731 PNode::getNullParent()->updateNode (this->dtS); … … 774 738 void World::collide() 775 739 { 776 CDEngine::getInstance()->checkCollisions(); 740 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00), 741 this->objectManager.getObjectList(OM_GROUP_01_PROJ)); 742 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01), 743 this->objectManager.getObjectList(OM_COMMON)); 777 744 } 778 745 … … 804 771 void World::draw () 805 772 { 806 /* draw entities */ 807 WorldEntity* entity; 808 glLoadIdentity(); 809 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 810 entity = iterator->firstElement(); 811 while( entity != NULL ) 812 { 813 if( entity->isVisible() ) entity->draw(); 814 if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 815 entity = iterator->nextElement(); 816 } 817 delete iterator; 773 GraphicsEngine* engine = GraphicsEngine::getInstance(); 774 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 775 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON)); 776 engine->draw(State::getObjectManager()->getObjectList(OM_COMMON)); 777 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00)); 778 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01)); 779 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 780 781 // { 782 // if( entity->isVisible() ) entity->draw(); 783 //FIXME 784 // if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 785 // entity = iterator->nextElement(); 786 // } 818 787 819 788 glCallList (objectList); … … 824 793 PNode::getNullParent()->debugDraw(0); 825 794 826 GraphicsEngine::getInstance()->draw();795 engine->draw(); 827 796 //TextEngine::getInstance()->draw(); 828 797 } … … 834 803 void World::spawn(WorldEntity* entity) 835 804 { 836 this->entities->add (entity);805 // this->entities->add (entity); 837 806 entity->postSpawn (); 838 807 } … … 847 816 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir) 848 817 { 849 this->entities->add (entity);818 // this->entities->add (entity); 850 819 851 820 entity->setAbsCoor (*absCoor); … … 873 842 entity->setRelDir (*relDir); 874 843 875 this->entities->add (entity);844 // this->entities->add (entity); 876 845 877 846 entity->postSpawn (); -
trunk/src/story_entities/world.h
r6048 r6142 11 11 #include "story_entity.h" 12 12 #include "p_node.h" 13 #include "object_manager.h" 13 14 14 class World; 15 15 16 class WorldEntity; 16 17 class Camera; … … 18 19 class GLMenuImageScreen; 19 20 class Terrain; 20 class GarbageCollector;21 class Text;22 21 class TiXmlElement; 23 22 24 23 class Shell; 25 24 class OggPlayer; 26 template<class T> class tList;27 25 28 26 //! The game world … … 61 59 bool command (Command* cmd); 62 60 63 tList<WorldEntity>* getEntities();64 65 61 /* interface to world */ 66 62 void spawn (WorldEntity* entity); … … 84 80 void synchronize (); 85 81 void handleInput (); 82 void tick (std::list<WorldEntity*> worldEntity, float dt); 86 83 void tick (); 87 84 void update (); … … 104 101 bool bPause; //!< pause mode 105 102 103 ObjectManager objectManager; //!< The ObjectManager of this World. 104 106 105 GLMenuImageScreen* glmis; //!< The Level-Loader Display 107 106 … … 118 117 119 118 GLuint objectList; //!< temporary: @todo this will be ereased soon 120 tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. 119 121 120 Player* localPlayer; //!< The Player, you fly through the level. 122 121 }; -
trunk/src/util/Makefile.am
r5750 r6142 7 7 object_manager.cc \ 8 8 loading/factory.cc \ 9 garbage_collector.cc \10 9 state.cc \ 11 10 user_control.cc \ … … 19 18 track/pilot_node.cc \ 20 19 track/track_manager.cc \ 21 track/track_node.cc 20 track/track_node.cc 22 21 23 22 noinst_HEADERS = fast_factory.h \ 24 23 object_manager.h \ 25 garbage_collector.h \26 24 state.h \ 27 25 user_control.h \ -
trunk/src/util/object_manager.cc
r5828 r6142 10 10 11 11 ### File Specific: 12 main-programmer: ...12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 14 */ … … 19 19 #include "class_list.h" 20 20 21 #include "p_node.h"22 21 #include "world_entity.h" 23 #include "list.h" 22 23 #include "shell_command.h" 24 25 #include <assert.h> 24 26 25 27 using namespace std; 26 27 28 /** 29 * standard constructor 28 SHELL_COMMAND(debug, ObjectManager, debug) 29 ->defaultValues(2, NULL, 0); 30 31 /** 32 * @brief standard constructor 30 33 */ 31 34 ObjectManager::ObjectManager () … … 37 40 } 38 41 39 /** 40 * the singleton reference to this class 41 */ 42 ObjectManager* ObjectManager::singletonRef = NULL; 43 44 /** 45 @brief standard deconstructor 42 43 /** 44 * @brief standard deconstructor 45 * 46 * this also removes ALL entitites in existence. 46 47 */ 47 48 ObjectManager::~ObjectManager () 48 49 { 49 ObjectManager::singletonRef = NULL; 50 } 50 this->flush(); 51 } 52 53 /** 54 * @brief flushes all entities 55 * 56 * this function deletes all entities that exist within the ObjectManager. 57 * It does this by poping each list from the front, and delete the given object. 58 * 59 * automatically called by a destructor. 60 */ 61 void ObjectManager::flush() 62 { 63 for (unsigned int i = 0; i < OM_SIZE; ++i) 64 while(!this->objectLists[i].empty()) 65 delete this->objectLists[i].front(); 66 } 67 68 69 /** 70 * @brief moves an Entity from an old list to a new One 71 * @param entity the entity to move. 72 * @param omList the new List to move the entity to. 73 * 74 * this will erase the entity from the old list 75 */ 76 void ObjectManager::toList (WorldEntity* entity, OM_LIST omList) 77 { 78 assert (omList != OM_SIZE); 79 80 if (likely(entity->getOMListNumber() != OM_INIT)) 81 this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator()); 82 83 if (likely(omList != OM_INIT)) 84 { 85 this->objectLists[omList].push_back(entity); 86 entity->getEntityIterator() = --this->objectLists[omList].end(); 87 entity->getOMListNumber() = omList; 88 } 89 } 90 91 92 /** 93 * @see ObjectManager::toList(WorldEntity* OM_LIST) 94 * @param entity the entity to move. 95 * @param omList the new List to move the entity to. 96 * 97 * this function also does a transformation from omList as char* to OM_LIST. 98 */ 99 void ObjectManager::toList (WorldEntity* entity, const char* omList) 100 { 101 this->toList(entity, ObjectManager::StringToOMList(omList)); 102 } 103 104 51 105 52 106 /** … … 68 122 return NULL; 69 123 } 124 125 126 /** 127 * @brief print out nice debug information about Elements in the list OM_LIST 128 * @param omList the List to debug. 129 * @param level: level 0: only show list info; level 1: also show entities and their names. 130 */ 131 void ObjectManager::debug(OM_LIST omList, unsigned int level) const 132 { 133 if (omList != OM_INIT || omList == OM_SIZE) 134 { 135 PRINT(0)(" +ObjectManager-LIST: '%s'==size='%d'==---\n", ObjectManager::OMListToString((OM_LIST)omList), this->objectLists[omList].size()); 136 // if (level >= 1) 137 { 138 std::list<WorldEntity*>::const_iterator entity; 139 for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++) 140 { 141 PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName()); 142 } 143 } 144 } 145 else 146 PRINTF(2)("Invalid query. for OM_INIT-LIST or OM_SIZE\n"); 147 } 148 149 150 /** 151 * @brief prints out very nice debug information 152 * @param listName the Name of the list to get Debug information from 153 * @param level: level 0: only show list info; level 1: also show entities and their names. 154 */ 155 void ObjectManager::debug(const char* listName, unsigned int level) 156 { 157 PRINT(0)("=================================\n"); 158 PRINT(0)("=ObjectManager-DEBUG=============\n"); 159 PRINT(0)("=================================\n"); 160 if (listName == NULL || listName[0] == '\0') 161 for (unsigned int i = 0; i < OM_SIZE; ++i) 162 debug((OM_LIST) i, level); 163 else 164 debug(ObjectManager::StringToOMList(listName)); 165 PRINT(0)("=========================== OM ==\n"); 166 } 167 168 169 170 /** 171 * @brief transforms an omList into a String (usefull for debugging). 172 * @param omList the OM_LIST to be transformed into a String. 173 * @returns the String transformed from omList. 174 */ 175 const char* ObjectManager::OMListToString(OM_LIST omList) 176 { 177 if (omList == OM_INIT || omList == OM_SIZE) 178 return "===invalid==="; 179 180 printf("%d\n", omList); 181 return ObjectManager::objectManagerListNames[omList]; 182 } 183 184 185 186 /** 187 * @brief transforms a String into an OM_LIST (usefull for debugging/Loading). 188 * @param listName the OM_LIST-name to be transformed into an OM_LIST. 189 * @returns the OM_LIST transformed from listName. or the default, if not found or NULL. 190 */ 191 OM_LIST ObjectManager::StringToOMList(const char* listName) 192 { 193 if (unlikely(listName == NULL)) return OM_DEFAULT_LIST; 194 195 for(unsigned int i = 0; i < OM_SIZE; ++i) { 196 if(!strcmp(listName, ObjectManager::objectManagerListNames[i])) { 197 return (OM_LIST)i; 198 } 199 } 200 return OM_DEFAULT_LIST; 201 } 202 203 204 205 const char* ObjectManager::objectManagerListNames[] = { 206 "null", 207 "dead", 208 "dead-tick", 209 "environ-notick", 210 "environ", 211 "common", 212 213 "group00", 214 "group00-proj", 215 "group01", 216 "group01-proj", 217 "group02", 218 "group02-proj", 219 "group03", 220 "group03-proj", 221 "group04", 222 "group04-proj", 223 "group05", 224 "group05-proj", 225 "group06", 226 "group06-proj", 227 "group07", 228 "group07-proj", 229 "group08", 230 "group08-proj", 231 "group09", 232 "group09-proj", 233 "group10", 234 "group10-proj", 235 "group11", 236 "group11-proj", 237 "group12", 238 "group12-proj", 239 "group13", 240 "group13-proj", 241 "group14", 242 "group14-proj", 243 "group15", 244 "group15-proj" 245 }; -
trunk/src/util/object_manager.h
r5795 r6142 1 1 /*! 2 2 * @file object_manager.h 3 * @brief Definition of the ... singleton Class4 */3 * @brief Definition of the ObjectManager. 4 */ 5 5 6 6 #ifndef _OBJECT_MANAGER_H … … 9 9 #include "base_object.h" 10 10 #include <list> 11 #include <vector> 12 13 /// Enumerator for Managed Object Lists 14 typedef enum { 15 OM_NULL = 0, 16 OM_DEAD, 17 OM_DEAD_TICK, 18 OM_ENVIRON_NOTICK, 19 OM_ENVIRON, 20 OM_COMMON, 21 22 OM_GROUP_00, 23 OM_GROUP_00_PROJ, 24 OM_GROUP_01, 25 OM_GROUP_01_PROJ, 26 OM_GROUP_02, 27 OM_GROUP_02_PROJ, 28 OM_GROUP_03, 29 OM_GROUP_03_PROJ, 30 OM_GROUP_04, 31 OM_GROUP_04_PROJ, 32 OM_GROUP_05, 33 OM_GROUP_05_PROJ, 34 OM_GROUP_06, 35 OM_GROUP_06_PROJ, 36 OM_GROUP_07, 37 OM_GROUP_07_PROJ, 38 OM_GROUP_08, 39 OM_GROUP_08_PROJ, 40 OM_GROUP_09, 41 OM_GROUP_09_PROJ, 42 OM_GROUP_10, 43 OM_GROUP_10_PROJ, 44 OM_GROUP_11, 45 OM_GROUP_11_PROJ, 46 OM_GROUP_12, 47 OM_GROUP_12_PROJ, 48 OM_GROUP_13, 49 OM_GROUP_13_PROJ, 50 OM_GROUP_14, 51 OM_GROUP_14_PROJ, 52 OM_GROUP_15, 53 OM_GROUP_15_PROJ, 54 55 OM_SIZE, 56 57 58 OM_INIT = -1, //!< DO NOT USE THIS. (WorldEntity Internal). 59 } OM_LIST; 60 61 #define OM_DEFAULT_LIST OM_NULL 62 11 63 12 64 // FORWARD DECLARATION … … 14 66 class WorldEntity; 15 67 16 class ObjectGroupList 17 { 18 19 20 21 }; 22 23 24 //! A default singleton class. 68 //! A powerfull handler for the Object (WorldEntities) in the World. 25 69 class ObjectManager : public BaseObject { 26 70 27 71 public: 28 virtual ~ObjectManager(void); 29 /** @returns a Pointer to the only object of this Class */ 30 inline static ObjectManager* getInstance(void) { if (!ObjectManager::singletonRef) ObjectManager::singletonRef = new ObjectManager(); return ObjectManager::singletonRef; }; 72 ObjectManager(); 73 virtual ~ObjectManager(); 31 74 75 void flush(); 76 77 void toList (WorldEntity* entity, OM_LIST omList = OM_DEFAULT_LIST); 78 void toList (WorldEntity* entity, const char* omList); 79 80 81 std::list<WorldEntity*>& getObjectList(OM_LIST listNumber) { return this->objectLists[listNumber]; } 82 const std::list<WorldEntity*>& getObjectList(OM_LIST listNumber) const { return this->objectLists[listNumber]; } 32 83 33 84 static std::list<WorldEntity*>* distanceFromObject(const PNode& center, float radius, ClassID classID); 34 85 35 ObjectGroupList* getGroupList( ); 86 void debug(OM_LIST omList, unsigned int level = 0) const; 87 void debug(const char* listName = NULL, unsigned int level = 0); 88 89 static OM_LIST StringToOMList(const char* listName); 90 static const char* OMListToString(OM_LIST omList); 36 91 37 92 private: 38 ObjectManager(void); 39 static ObjectManager* singletonRef; 40 41 std::list<ObjectGroupList> groupList; 42 43 const std::list<BaseObject>* pNodeList; 93 const std::list<BaseObject>* pNodeList; 44 94 45 95 96 std::list<WorldEntity*> objectLists[OM_SIZE]; 97 98 static const char* objectManagerListNames[]; //!< Names of all the lists 46 99 }; 47 100 -
trunk/src/util/state.cc
r4836 r6142 29 29 const PNode* State::cameraTarget = NULL; 30 30 31 tList<WorldEntity>* State::worldEntityList= NULL;31 ObjectManager* State::objectManager = NULL; 32 32 33 33 /** -
trunk/src/util/state.h
r5405 r6142 10 10 class PNode; 11 11 class WorldEntity; 12 template<class T> class tList; 13 //template<class T> class tStack; 12 class ObjectManager; 14 13 15 14 //! handles states about orxonox's most importatn objects … … 22 21 23 22 public: 24 // CAMERA // 23 ////////////// 24 /// CAMERA /// 25 ////////////// 25 26 /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */ 26 27 static void setCamera(const PNode* camera, const PNode* cameraTarget); … … 30 31 static inline const PNode* getCameraTarget() { return State::cameraTarget; }; 31 32 32 // WORLD_ENTITY_LIST // 33 /** @param worldEntityList The World's List of WorldEntities */ 34 static inline void setWorldEntityList(tList<WorldEntity>* worldEntityList) { State::worldEntityList = worldEntityList; }; 35 /** @returns the List of WorldEntities */ 36 static inline tList<WorldEntity>* getWorldEntityList() { return State::worldEntityList; }; 33 ////////////////////// 34 /// OBJECT-MANAGER /// 35 ////////////////////// 36 /** @param objectManager the new Current ObjectManager */ 37 static inline void setObjectManager(ObjectManager* objectManager) { State::objectManager = objectManager; }; 38 /** @returns the current ObjectManager. */ 39 static inline ObjectManager* getObjectManager() { return State::objectManager; }; 40 41 ///////////////////////// 42 /// WORLD_ENTITY_LIST /// 43 ///////////////////////// 37 44 38 45 private: … … 42 49 static const PNode* cameraTarget; //!< A reference to the cameraTarget 43 50 static PNode* nullParent; //!< A reference to the Null-PNode. 51 static ObjectManager* objectManager; //!< A referenct to the current ObjectManager 44 52 45 static tList<WorldEntity>* worldEntityList; //!< The List of the worldEntities46 47 //tStack<48 53 }; 49 54 -
trunk/src/world_entities/environment.cc
r5994 r6142 62 62 { 63 63 this->setClassID(CL_ENVIRONMENT, "Environment"); 64 this->toList(OM_ENVIRON); 64 65 } 65 66 -
trunk/src/world_entities/npcs/npc.cc
r6054 r6142 33 33 { 34 34 this->setClassID(CL_NPC, "NPC"); 35 35 this->toList(OM_GROUP_00); 36 36 } 37 37 … … 50 50 WorldEntity* powerUp = new TurretPowerUp(); 51 51 powerUp->setAbsCoor(this->getAbsCoor()); 52 State::getWorldEntityList()->add(powerUp);52 // powerUp->toList(OM_COMMON); 53 53 } 54 54 else if ((float)rand()/RAND_MAX < .3) … … 56 56 WorldEntity* powerUp = new LaserPowerUp(); 57 57 powerUp->setAbsCoor(this->getAbsCoor()); 58 State::getWorldEntityList()->add(powerUp);58 powerUp->toList(OM_COMMON); 59 59 } 60 State::getWorldEntityList()->remove(this);60 this->toList(OM_DEAD); 61 61 this->removeNode(); 62 62 … … 68 68 { 69 69 this->setVisibiliy(false); 70 State::getWorldEntityList()->remove(this);70 this->toList(OM_DEAD); 71 71 this->removeNode(); 72 72 } -
trunk/src/world_entities/playable.cc
r5915 r6142 46 46 PRINTF(4)("PLAYABLE INIT\n"); 47 47 48 this->toList(OM_GROUP_01); 48 49 this->weaponMan = new WeaponManager(this); 49 50 -
trunk/src/world_entities/power_ups/laser_power_up.cc
r6113 r6142 80 80 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 81 81 if (entity->isA(CL_PLAYABLE)) 82 State::getWorldEntityList()->remove(this);82 this->toList(OM_DEAD); 83 83 } 84 84 -
trunk/src/world_entities/power_ups/power_up.cc
r6113 r6142 38 38 { 39 39 delete this->sphereMaterial; 40 this->toList(OM_COMMON); 40 41 } 41 42 -
trunk/src/world_entities/power_ups/turret_power_up.cc
r6113 r6142 80 80 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 81 81 if (entity->isA(CL_PLAYABLE)) 82 State::getWorldEntityList()->remove(this);82 this->toList(OM_DEAD); 83 83 } 84 84 -
trunk/src/world_entities/skybox.cc
r6022 r6142 65 65 { 66 66 this->setClassID(CL_SKYBOX, "SkyBox"); 67 67 this->toList(OM_ENVIRON_NOTICK); 68 68 this->size = 100.0; 69 69 -
trunk/src/world_entities/skysphere.cc
r5511 r6142 42 42 { 43 43 this->setClassID(CL_SKYSPHERE, "SkySphere"); 44 44 this->toList(OM_ENVIRON_NOTICK); 45 45 if (fileName == NULL) 46 46 this->initialize("pictures/sky-replace.jpg"); -
trunk/src/world_entities/terrain.cc
r6022 r6142 93 93 { 94 94 this->setClassID(CL_TERRAIN, "Terrain"); 95 this->toList(OM_ENVIRON_NOTICK); 95 96 96 97 this->objectList = 0; -
trunk/src/world_entities/test_entity.cc
r5994 r6142 33 33 { 34 34 this->setClassID(CL_TEST_ENTITY, "TestEntity"); 35 // TO SOME LIST!! 35 36 36 37 this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx"); … … 70 71 PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z); 71 72 this->setVisibiliy(false); 72 State::getWorldEntityList()->remove(this);73 this->toList(OM_DEAD); 73 74 } 74 75 } -
trunk/src/world_entities/weapons/aim.cc
r6078 r6142 104 104 void Aim::searchTarget(float range) 105 105 { 106 tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator(); 106 //FIXME// 107 /* tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator(); 107 108 WorldEntity* entity = iterator->firstElement(); 108 109 while (likely(entity != NULL)) … … 121 122 } 122 123 123 delete iterator; 124 delete iterator;*/ 124 125 } 125 126 -
trunk/src/world_entities/weapons/bomb.cc
r5994 r6142 174 174 void Bomb::activate() 175 175 { 176 State::getWorldEntityList()->add(this);177 176 178 177 } … … 180 179 void Bomb::deactivate() 181 180 { 182 State::getWorldEntityList()->remove(this);181 this->toList(OM_DEAD); 183 182 this->lifeCycle = 0.0f; 184 183 Bomb::fastFactory->kill(this); -
trunk/src/world_entities/weapons/ground_turret.cc
r5994 r6142 89 89 { 90 90 this->left->setParent(this); 91 this->left->toList(this->getOMListNumber()); 91 92 this->left->setRelCoor(0,10,-5); 92 93 } … … 98 99 { 99 100 this->right->setParent(this); 101 this->right->toList(this->getOMListNumber()); 100 102 this->right->setRelCoor(0,10,5); 101 103 } -
trunk/src/world_entities/weapons/guided_missile.cc
r6078 r6142 85 85 void GuidedMissile::activate() 86 86 { 87 State::getWorldEntityList()->add(this);88 87 if (unlikely(GuidedMissile::trailParticles == NULL)) 89 88 { … … 129 128 this->lifeCycle = 0.0; 130 129 131 // GarbageCollector::getInstance()->collect(this); 132 State::getWorldEntityList()->remove(this); 130 this->toList(OM_DEAD); 133 131 this->removeNode(); 134 132 GuidedMissile::fastFactory->kill(this); … … 152 150 if (this->target != NULL && this->target->getParent() != PNode::getNullParent()) 153 151 { 154 printf("========%s::%s\n", target->getParent()->getClassName(), target->getParent()->getName() );155 152 velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility; 156 153 float speed = velocity.len(); -
trunk/src/world_entities/weapons/laser.cc
r6056 r6142 77 77 void Laser::activate() 78 78 { 79 State::getWorldEntityList()->add(this);80 79 if (unlikely(Laser::explosionParticles == NULL)) 81 80 { … … 98 97 this->lifeCycle = 0.0; 99 98 100 // GarbageCollector::getInstance()->collect(this); 101 State::getWorldEntityList()->remove(this); 99 this->toList(OM_NULL); 102 100 this->removeNode(); 103 101 Laser::fastFactory->kill(this); … … 134 132 this->lifeCycle = .95; //!< @todo calculate this usefully. 135 133 ParticleEngine::getInstance()->addConnection(this->emitter, Laser::explosionParticles); 136 137 134 } 138 135 -
trunk/src/world_entities/weapons/projectile.cc
r6078 r6142 22 22 #include "weapon.h" 23 23 #include "model.h" 24 25 #include "garbage_collector.h"26 24 27 25 using namespace std; -
trunk/src/world_entities/weapons/rocket.cc
r6056 r6142 82 82 void Rocket::activate() 83 83 { 84 State::getWorldEntityList()->add(this);85 84 if (unlikely(Rocket::trailParticles == NULL)) 86 85 { … … 125 124 ParticleEngine::getInstance()->breakConnections(this->emitter); 126 125 this->lifeCycle = 0.0; 126 this->toList(OM_NULL); 127 127 128 128 // GarbageCollector::getInstance()->collect(this); 129 State::getWorldEntityList()->remove(this);129 this->toList(OM_DEAD); 130 130 Rocket::fastFactory->kill(this); 131 131 } -
trunk/src/world_entities/weapons/test_bullet.cc
r5994 r6142 82 82 void TestBullet::activate() 83 83 { 84 State::getWorldEntityList()->add(this);85 84 if (unlikely(TestBullet::trailParticles == NULL)) 86 85 { … … 119 118 ParticleEngine::getInstance()->breakConnections(this->emitter); 120 119 this->lifeCycle = 0.0; 120 this->toList(OM_NULL); 121 121 122 // GarbageCollector::getInstance()->collect(this);123 State::getWorldEntityList()->remove(this);124 122 TestBullet::fastFactory->kill(this); 125 123 } -
trunk/src/world_entities/weapons/weapon.cc
r6054 r6142 192 192 { 193 193 if (likely (this->projectileFactory != NULL)) 194 return dynamic_cast<Projectile*>(this->projectileFactory->resurrect()); 194 { 195 Projectile* pj = dynamic_cast<Projectile*>(this->projectileFactory->resurrect()); 196 pj->toList((OM_LIST)(this->getOMListNumber()+1)); 197 return pj; 198 } 195 199 else 196 200 { -
trunk/src/world_entities/weapons/weapon_manager.cc
r6074 r6142 35 35 * @param number of weapon slots of the model/ship <= 8 (limitied) 36 36 */ 37 WeaponManager::WeaponManager( PNode* parent)37 WeaponManager::WeaponManager(WorldEntity* parent) 38 38 { 39 39 this->init(); … … 155 155 * a PNode. 156 156 */ 157 void WeaponManager::setParent(PNode* parent) 158 { 159 if (parent == NULL) 160 parent = PNode::getNullParent(); 157 void WeaponManager::setParent(WorldEntity* parent) 158 { 161 159 this->parent = parent; 162 160 if (this->parent != NULL) … … 247 245 this->configs[configID][slotID] = weapon; 248 246 if (this->parent != NULL) 249 weapon->setParent(parent); 247 { 248 this->parent->addChild(weapon); 249 } 250 250 PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID); 251 251 } … … 373 373 else 374 374 { 375 if (this->currentSlotConfig[i].currentWeapon != NULL) 376 this->currentSlotConfig[i].currentWeapon->toList(OM_NULL); 375 377 tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon; 376 378 if (tickWeapon != NULL) … … 378 380 tickWeapon->requestAction(WA_ACTIVATE); 379 381 tickWeapon->setParent(&this->currentSlotConfig[i].position); 382 tickWeapon->toList(this->parent->getOMListNumber()); 380 383 this->currentSlotConfig[i].position.activateNode(); 381 384 } -
trunk/src/world_entities/weapons/weapon_manager.h
r6055 r6142 45 45 46 46 public: 47 WeaponManager( PNode* parent);47 WeaponManager(WorldEntity* parent); 48 48 WeaponManager(const TiXmlElement* root); 49 49 ~WeaponManager(); … … 63 63 long getSlotCapability(int slot) const { return this->currentSlotConfig[slot].capability; }; 64 64 65 void setParent( PNode* parent);65 void setParent(WorldEntity* parent); 66 66 /** @returns the Parent (carrier) of this WeaponManager */ 67 67 PNode* getParent() const { return this->parent; }; … … 93 93 94 94 private: 95 PNode*parent; //!< The parent, this WeaponManager is connected to.95 WorldEntity* parent; //!< The parent, this WeaponManager is connected to. 96 96 97 97 int slotCount; //!< number of weapon slots the ship has. -
trunk/src/world_entities/world_entity.cc
r6005 r6142 53 53 54 54 this->setVisibiliy(true); 55 56 this->objectListNumber = OM_INIT; 57 this->objectListIterator = NULL; 58 59 this->toList(OM_NULL); 55 60 } 56 61 … … 67 72 for (unsigned int i = 0; i < this->models.size(); i++) 68 73 this->setModel(NULL, i); 74 75 State::getObjectManager()->toList(this, OM_INIT); 69 76 } 70 77 … … 95 102 { 96 103 if (fileName != NULL) 97 { 104 { 98 105 // search for the special character # in the LoadParam 99 106 if (strchr(fileName, '#') != NULL) 100 107 { 101 102 103 104 105 106 107 108 109 110 111 112 108 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName); 109 char* lodFile = new char[strlen(fileName)+1]; 110 strcpy(lodFile, fileName); 111 char* depth = strchr(lodFile, '#'); 112 for (unsigned int i = 0; i < 5; i++) 113 { 114 *depth = 48+(int)i; 115 printf("-------%s\n", lodFile); 116 if (ResourceManager::isInDataDir(lodFile)) 117 this->loadModel(lodFile, scaling, i); 118 } 119 return; 113 120 } 114 121 … … 174 181 } 175 182 } 183 184 /** 185 * @brief moves this entity to the List OM_List 186 * @param list the list to set this Entity to. 187 * 188 * this is the same as a call to State::getObjectManager()->toList(entity , list); 189 * directly, but with an easier interface. 190 * 191 * @todo inline this (peut etre) 192 */ 193 void WorldEntity::toList(OM_LIST list) 194 { 195 State::getObjectManager()->toList(this, list); 196 } 197 176 198 177 199 -
trunk/src/world_entities/world_entity.h
r6005 r6142 11 11 #include "model.h" 12 12 13 #include "object_manager.h" 13 14 #include "glincl.h" 14 15 #include <vector> … … 65 66 // CharacterAttributes* getCharacterAttributes(); 66 67 68 void toList(OM_LIST list); 67 69 70 /** @returns a Reference to the objectListNumber to set. */ 71 OM_LIST& getOMListNumber() { return this->objectListNumber; } 72 /** @returns a Reference to the Iterator */ 73 std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; } 68 74 protected: 69 75 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity 70 76 71 77 private: 72 std::vector<Model*> models; //!< The model that should be loaded for this entity.73 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection78 std::vector<Model*> models; //!< The model that should be loaded for this entity. 79 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 74 80 75 bool bCollide; //!< If it should be considered for the collisiontest. 76 bool bVisible; //!< If it should be visible. 81 bool bCollide; //!< If it should be considered for the collisiontest. 82 bool bVisible; //!< If it should be visible. 83 84 OM_LIST objectListNumber; //!< The ObjectList from ObjectManager this Entity is in. 85 std::list<WorldEntity*>::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager. 86 77 87 }; 78 88
Note: See TracChangeset
for help on using the changeset viewer.