Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10053 for code/branches


Ignore:
Timestamp:
May 13, 2014, 11:45:47 AM (11 years ago)
Author:
noep
Message:

Fixed yet another segfault (which we hadn't seen yet).
Cleared emptyLevel, created two testlevels (testing with boxes)

Location:
code/branches/modularships
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/modularships/data/levels/emptyLevel.oxw

    r10029 r10053  
    1616  include("templates/spaceshipPirate.oxt")
    1717  include("templates/spaceshipEscort.oxt")
    18   include("templates/HeavyCruiser.oxt")
    1918?>
    2019
     
    3332    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
    3433   
    35     <MovableEntity position="0,0,0" collisionType=dynamic scale=1 linearDamping=0.8 angularDamping=0  collisiondamage=0.005 enablecollisiondamage=true>
    36     <attached>
    37         <Model position="0,0,0" mesh="cube.mesh" scale3D="40,40,40" />
    38         <StaticEntity position="0,90,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
    39             <attached>
    40                 <Model position="0,0,0" mesh="cube.mesh" scale3D="30,30,30" />
    41             </attached>
    42             <collisionShapes>
    43                 <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
    44             </collisionShapes>
    45         </StaticEntity>
    46     </attached>
    47     <collisionShapes>
    48         <BoxCollisionShape position="0,0,0" halfExtents="40,40,40" />
    49     </collisionShapes>
    50     </MovableEntity>
    51    
    52     <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,-100" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Pawn 0" >
    53         <attached>
    54             <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
    55             <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
    56             <StaticEntity position="0,-120,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
    57                 <attached>
    58                     <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
    59                     <Model position="0,0,60" mesh="cube.mesh" scale3D="30,30,30" />
    60                 </attached>
    61                 <collisionShapes>
    62                     <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
    63                     <BoxCollisionShape position="0,0,60" halfExtents="30,30,30" />
    64                 </collisionShapes>
    65             </StaticEntity>
    66             <StaticEntity position="0,-180,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
    67                 <attached>
    68                     <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
    69                     <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
    70                 </attached>
    71                 <collisionShapes>
    72                     <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
    73                     <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
    74                 </collisionShapes>
    75             </StaticEntity>
    76         </attached>
    77         <collisionShapes>
    78             <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
    79             <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
    80         </collisionShapes>
    81     </Pawn>
    82 
    83     <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,100" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Pawn 1" >
    84         <attached>
    85             <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
    86             <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
    87         </attached>
    88         <collisionShapes>
    89             <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
    90             <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
    91         </collisionShapes>
    92     </Pawn>
    93    
    94     <ModularSpaceShip position="0,-100,-200">
    95       <templates>
    96         <Template link=spaceshippirate />
    97       </templates>
    98     </ModularSpaceShip>
    99    
    100     <ModularSpaceShip position="0,-1000,-200" health="2000" maxhealth="4000" initialhealth="2000">
    101       <templates>
    102         <Template link=HeavyCruiser />
    103       </templates>
    104     </ModularSpaceShip>
    105    
    10634  </Scene>
    10735</Level>
  • code/branches/modularships/data/levels/templates/HeavyCruiser.oxt

    r10052 r10053  
    5252    <parts>
    5353        <ShipPart name="frontL" initialhealth="10" damageabsorption="0.5">
    54             <destructionevents>
    55                 <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
    56             </destructionevents>
    57         </ShipPart>
    58         <ShipPart name="frontR" initialhealth="10" damageabsorption="0.5" />
     54            <destructionevents>
     55                <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
     56            </destructionevents>
     57        </ShipPart>
     58        <ShipPart name="frontR" initialhealth="10" damageabsorption="0.5">
     59            <destructionevents>
     60                <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
     61            </destructionevents>
     62        </ShipPart>
    5963        <ShipPart name="partL" initialhealth="10" damageabsorption="0.5" />
    6064        <ShipPart name="partR" initialhealth="10" damageabsorption="0.5" />
  • code/branches/modularships/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp

    r8393 r10053  
    2121#include "LinearMath/btAabbUtil2.h"
    2222#include "btManifoldResult.h"
     23#include <iostream>
    2324
    2425btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
     
    115116        void    ProcessChildShape(btCollisionShape* childShape,int index)
    116117        {
    117                 btAssert(index>=0);
     118                // std::cout << "PCS: " << childShape << std::endl; // FIXME: (noep) remove DEBUG
     119            btAssert(index>=0);
    118120                btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());
    119121                btAssert(index<compoundShape->getNumChildShapes());
  • code/branches/modularships/src/orxonox/Scene.cc

    r10036 r10053  
    345345                                             int index0, const btCollisionObject* colObj1, int partId1, int index1)
    346346    {
    347         orxout() << "collisionCb()" << endl;
    348 
    349347        // get the WorldEntity pointers
    350348        SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
     
    362360            modified |= object1->collidesAgainst(object0, cs0, cp);
    363361
    364         orxout() << "collisionCb() completed." << endl;
    365 
    366362        return modified;
    367363    }
  • code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc

    r10052 r10053  
    4949    {
    5050        RegisterObject(PartDestructionEvent);
    51         this->isValid_ = false;
     51        this->setValid(true);
    5252    }
    5353
     
    7676    void PartDestructionEvent::execute()
    7777    {
    78         if(!this->isValid_)
     78        // Do not execute if this event is invalid
     79        if(!isValid())
    7980        {
    80             //orxout(internal_warning) <<
     81            orxout(internal_warning) << "Attempted to execute an invalid PartDestructionEvent!" << endl;
    8182            return;
    8283        }
    8384
     85        if (this->targetType_ == "ship")
     86        {
     87            switch (this->targetParam_) {
     88            case shieldhealth:
     89                this->parent_->getParent()->setShieldHealth(operate(this->parent_->getParent()->getShieldHealth()));
     90                break;
     91            default:
     92                break;
     93            }
     94            this->setValid(false);
     95            return;
     96        }
     97    }
    8498
     99    void PartDestructionEvent::setParent(ShipPart* part)
     100    {
     101        this->parent_ = part;
    85102    }
    86103
     
    95112
    96113        // Error, if invalid target-type was entered.
    97         orxout(internal_warning) << type << " is not a valid target-type for a PartDestructionEvent. Valid types are: ship engine weapon" << endl;
    98         this->isValid_ = false;
     114        orxout(internal_warning) << "\"" << type << "\" is not a valid target-type for a PartDestructionEvent. Valid types are: ship engine weapon" << endl;
     115        this->setValid(false);
    99116        return;
    100117    }
     
    117134        {
    118135            orxout(internal_warning) << "No valid target-type defined. Cannot set target-param for this PartDestructionEvent." << endl;
    119             this->isValid_ = false;
     136            this->setValid(false);
    120137            return;
    121138        }
     
    131148            if (param == "shieldhealth")
    132149            {
    133                 this->targetParam_ = param;
     150                this->targetParam_ = shieldhealth;
    134151                return;
    135152            }
    136153
    137             orxout(internal_warning) << param << " is not a valid target-param for a PartDestructionEvent with target-type \"ship\". Valid types are: shieldhealth maxshieldhealth shieldabsorption shieldrechargerate" << endl;
     154            orxout(internal_warning) << "\"" << param << "\" is not a valid target-param for a PartDestructionEvent with target-type \"ship\". Valid types are: shieldhealth maxshieldhealth shieldabsorption shieldrechargerate" << endl;
    138155            return;
    139156        }
     157
     158        orxout(internal_warning) << "No valid target-param defined. The chosen param is either invalid or not available for this target-type." << endl;
     159        this->setValid(false);
    140160    }
    141161
     
    143163    {
    144164        // * + - destroy
    145         this->operation_ = operation;
     165        if ((operation == "*") || (operation == "+") || (operation == "-") || (operation == "destroy"))
     166        {
     167            this->operation_ = operation;
     168            return;
     169        }
     170        this->operation_ = "NULL";
     171        orxout(internal_warning) << "\"" << operation << "\" is not a valid operation for a PartDestructionEvent. Valid operations are: * + - destroy" << endl;
     172    }
     173
     174    float PartDestructionEvent::operate(float input)
     175    {
     176        if (this->operation_ == "*")
     177            return input * this->value_;
     178        if (this->operation_ == "+")
     179            return input + this->value_;
     180        if (this->operation_ == "-")
     181            return input - this->value_;
     182        if (this->operation_ == "destroy")
     183        {
     184            return 0;
     185        }
     186        return 0;
    146187    }
    147188
  • code/branches/modularships/src/orxonox/items/PartDestructionEvent.h

    r10052 r10053  
    4444        public:
    4545
     46            enum TargetParam
     47            {
     48                shieldhealth,
     49                maxshieldhealth,
     50                shieldabsorption,
     51                shieldrechargerate,
     52                null
     53            };
     54
    4655            PartDestructionEvent(Context* context);
    4756            virtual ~PartDestructionEvent();
     
    5059
    5160            void execute();
     61
     62            inline void setValid(bool valid)
     63                { this->valid_ = valid; }
     64            inline bool isValid()
     65                { return this->valid_; }
     66
     67            void setParent(ShipPart* parent);
     68            inline ShipPart* getParent()
     69                { return this->parent_; }
    5270
    5371            void setTargetType(std::string type);
     
    6785                { return this->operation_; }
    6886
     87            float operate(float input);
     88
    6989            void setEventValue(float value);
    7090            inline float getEventValue()
     
    7595        private:
    7696
    77             bool isValid_;
     97            ShipPart* parent_;
     98            bool valid_;
    7899
    79100            std::string targetType_;
    80101            std::string targetName_;
    81             std::string targetParam_;
     102            TargetParam targetParam_;
    82103            std::string operation_;
    83104
  • code/branches/modularships/src/orxonox/items/ShipPart.cc

    r10052 r10053  
    5151    {
    5252        RegisterObject(ShipPart);
     53        this->setAlive(true);
    5354    }
    5455
     
    9192    void ShipPart::death()
    9293    {
     94        if (!(this->isAlive()))
     95            return;
     96
     97        this->setAlive(false);
     98
     99        // Execute all destruction events
     100        for (unsigned int i = 0; i < this->eventList_.size(); i++)
     101        {
     102            orxout() << "executing" << endl;
     103            this->getDestructionEvent(i)->execute();
     104        }
     105
     106        // Remove this ShipPart from the parent.
    93107        this->parent_->removeShipPart(this);
    94108        orxout() << this->getName() << " has died." << endl;
     
    105119        OrxAssert(entity != NULL, "The Entity cannot be NULL.");
    106120        this->entityList_.push_back(entity);
    107         //part->addToSpaceShip(this); //FIXME: (noep) add
    108121    }
    109122
     
    153166        A pointer to the PartDestructionEvent to be added.
    154167    */
    155     void ShipPart::addDestructionEvent(PartDestructionEvent* part)
    156     {
    157         OrxAssert(part != NULL, "The PartDestructionEvent cannot be NULL.");
    158         this->eventList_.push_back(part);
    159         //part->setParent(this);
     168    void ShipPart::addDestructionEvent(PartDestructionEvent* event)
     169    {
     170        OrxAssert(event != NULL, "The PartDestructionEvent cannot be NULL.");
     171        event->setParent(this);
     172        this->eventList_.push_back(event);
    160173    }
    161174
     
    168181    PartDestructionEvent* ShipPart::getDestructionEvent(unsigned int index)
    169182    {
    170         if(this->eventList_.size() >= index)
     183        if(this->eventList_.size() <= index)
    171184            return NULL;
    172185        else
     
    200213    {
    201214        orxout() << "ShipPart " <<this->getName() << " is handling a hit!" << endl;
     215
    202216        if (parent_->getGametype() && parent_->getGametype()->allowPawnDamage(parent_, originator))
    203217        {
  • code/branches/modularships/src/orxonox/items/ShipPart.h

    r10052 r10053  
    7373                { return this->parent_; }
    7474
     75            inline void setAlive(bool var)
     76                { this->alive_ = var; }
     77            inline bool isAlive()
     78                { return this->alive_; }
     79
    7580            virtual void setHealth(float health);
    7681            inline void addHealth(float health)
     
    108113            std::vector<PartDestructionEvent*> eventList_;  // The list of all PartDestructionEvent assigned to this ShipPart.
    109114
     115            bool alive_;
     116
    110117
    111118    }; // tolua_export
  • code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc

    r10052 r10053  
    119119    WorldEntity::~WorldEntity()
    120120    {
    121         orxout() << "destroying " << this->getIdentifier()->getName() << endl;
    122121        if (this->isInitialized())
    123122        {
     
    581580    {
    582581        // Note: The collision shapes may not be detached with this function!
    583         orxout() << "WE: detachCS()" << endl;
    584582        this->collisionShape_->detach(shape);
    585583        // Note: this->collisionShape_ already notifies us of any changes.
  • code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc

    r10052 r10053  
    133133        this->entityPtrList_.push_back(one);
    134134
    135         this->createCSPtrList(this->getWorldEntityCollisionShape());
     135        //this->createCSPtrList(this->getWorldEntityCollisionShape());
    136136
    137137        orxout() << "New entity-part assignment created!" << endl;
     
    139139
    140140    // This should add smartPointers to all (Orxonox)Collisionshapes of this SpaceShip, preventing them fromg etting deleted. Might not work due to weird acting getAttachedShape
    141     void ModularSpaceShip::createCSPtrList(CompoundCollisionShape* cs)
     141    void ModularSpaceShip::createCSPtrList(CompoundCollisionShape* cs) // FIXME: (noep) remove debug
    142142    {
    143143        for (int i=0; i < cs->getNumChildShapes(); i++)
     
    208208        //orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl;
    209209
    210         orxout() << "CP before handleHit" << endl;
    211 
    212210        if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL)
    213211            this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator);
     
    255253        this->partList_.push_back(part);
    256254        part->setParent(this);
    257         //part->addToSpaceShip(this); //FIXME: (noep) add
    258255        this->updatePartAssignment();
    259256    }
     
    267264    ShipPart* ModularSpaceShip::getShipPart(unsigned int index)
    268265    {
    269         if(this->partList_.size() >= index)
     266        if(this->partList_.size() <= index)
    270267            return NULL;
    271268        else
     
    339336        this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
    340337        this->detachCollisionShape(object->collisionShape_);  // after succeeding, causes a crash in the collision handling
    341         this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
     338        //this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
    342339
    343340        // mass
Note: See TracChangeset for help on using the changeset viewer.