[Orxonox-commit 5390] r10053 - in code/branches/modularships: data/levels data/levels/templates src/external/bullet/BulletCollision/CollisionDispatch src/orxonox src/orxonox/items src/orxonox/worldentities src/orxonox/worldentities/pawns
noep at orxonox.net
noep at orxonox.net
Tue May 13 11:45:48 CEST 2014
Author: noep
Date: 2014-05-13 11:45:47 +0200 (Tue, 13 May 2014)
New Revision: 10053
Added:
code/branches/modularships/data/levels/ModularShipsTest0.oxw
code/branches/modularships/data/levels/ModularShipsTest1.oxw
code/branches/modularships/data/levels/templates/ModularSpaceShipTest.oxt
Modified:
code/branches/modularships/data/levels/emptyLevel.oxw
code/branches/modularships/data/levels/templates/HeavyCruiser.oxt
code/branches/modularships/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
code/branches/modularships/src/orxonox/Scene.cc
code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc
code/branches/modularships/src/orxonox/items/PartDestructionEvent.h
code/branches/modularships/src/orxonox/items/ShipPart.cc
code/branches/modularships/src/orxonox/items/ShipPart.h
code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
Log:
Fixed yet another segfault (which we hadn't seen yet).
Cleared emptyLevel, created two testlevels (testing with boxes)
Added: code/branches/modularships/data/levels/ModularShipsTest0.oxw
===================================================================
--- code/branches/modularships/data/levels/ModularShipsTest0.oxw (rev 0)
+++ code/branches/modularships/data/levels/ModularShipsTest0.oxw 2014-05-13 09:45:47 UTC (rev 10053)
@@ -0,0 +1,76 @@
+<LevelInfo
+ name = "Modular Ships - Test 0"
+ description = "A level to test the basic functions of modular spaceships using simple boxes."
+ tags = "test"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("HUDTemplates3.oxo")
+ include("templates/lodInformation.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipAssff2.oxt")
+ include("templates/spaceshipPirate.oxt")
+ include("templates/spaceshipEscort.oxt")
+ include("templates/HeavyCruiser.oxt")
+ include("templates/ModularSpaceShipTest.oxt")
+?>
+
+<Level>
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
+
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+
+ <ModularSpaceShip position="0,0,0" health="2000" maxhealth="4000" initialhealth="2000">
+ <templates>
+ <Template link=ModularSpaceShipTest />
+ </templates>
+ </ModularSpaceShip>
+
+ <StaticEntity position="0,0,60" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="10,10,10" />
+ </attached>
+ <collisionShapes>
+ </collisionShapes>
+ </StaticEntity>
+
+ <StaticEntity position="0,60,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="10,10,10" />
+ </attached>
+ <collisionShapes>
+ </collisionShapes>
+ </StaticEntity>
+
+ <StaticEntity position="0,0,-60" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="10,10,10" />
+ </attached>
+ <collisionShapes>
+ </collisionShapes>
+ </StaticEntity>
+
+ <StaticEntity position="0,-60,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="10,10,10" />
+ </attached>
+ <collisionShapes>
+ </collisionShapes>
+ </StaticEntity>
+
+ </Scene>
+</Level>
+
Added: code/branches/modularships/data/levels/ModularShipsTest1.oxw
===================================================================
--- code/branches/modularships/data/levels/ModularShipsTest1.oxw (rev 0)
+++ code/branches/modularships/data/levels/ModularShipsTest1.oxw 2014-05-13 09:45:47 UTC (rev 10053)
@@ -0,0 +1,108 @@
+<LevelInfo
+ name = "Modular Ships - Test 1"
+ description = "A level to test the implementation of HeavyCruiser as modular spaceship."
+ tags = "test"
+ screenshot = "emptylevel.png"
+/>
+
+<?lua
+ include("stats.oxo")
+ include("HUDTemplates3.oxo")
+ include("templates/lodInformation.oxt")
+?>
+
+<?lua
+ include("templates/spaceshipAssff2.oxt")
+ include("templates/spaceshipPirate.oxt")
+ include("templates/spaceshipEscort.oxt")
+ include("templates/HeavyCruiser.oxt")
+?>
+
+<Level>
+ <templates>
+ <Template link=lodtemplate_default />
+ </templates>
+ <?lua include("includes/notifications.oxi") ?>
+
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+ <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+
+ <MovableEntity position="0,0,0" collisionType=dynamic scale=1 linearDamping=0.8 angularDamping=0 collisiondamage=0.005 enablecollisiondamage=true>
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="40,40,40" />
+ <StaticEntity position="0,90,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="30,30,30" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ </collisionShapes>
+ </StaticEntity>
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="40,40,40" />
+ </collisionShapes>
+ </MovableEntity>
+
+ <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,-100" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Pawn 0" >
+ <attached>
+ <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
+ <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
+ <StaticEntity position="0,-120,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
+ <Model position="0,0,60" mesh="cube.mesh" scale3D="30,30,30" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ <BoxCollisionShape position="0,0,60" halfExtents="30,30,30" />
+ </collisionShapes>
+ </StaticEntity>
+ <StaticEntity position="0,-180,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
+ <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
+ </collisionShapes>
+ </StaticEntity>
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
+ </collisionShapes>
+ </Pawn>
+
+ <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,100" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Pawn 1" >
+ <attached>
+ <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
+ <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
+ </collisionShapes>
+ </Pawn>
+
+ <ModularSpaceShip position="0,-100,-200">
+ <templates>
+ <Template link=spaceshippirate />
+ </templates>
+ </ModularSpaceShip>
+
+ <ModularSpaceShip position="0,-1000,-200" health="2000" maxhealth="4000" initialhealth="2000">
+ <templates>
+ <Template link=HeavyCruiser />
+ </templates>
+ </ModularSpaceShip>
+
+ </Scene>
+</Level>
+
Modified: code/branches/modularships/data/levels/emptyLevel.oxw
===================================================================
--- code/branches/modularships/data/levels/emptyLevel.oxw 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/data/levels/emptyLevel.oxw 2014-05-13 09:45:47 UTC (rev 10053)
@@ -15,7 +15,6 @@
include("templates/spaceshipAssff2.oxt")
include("templates/spaceshipPirate.oxt")
include("templates/spaceshipEscort.oxt")
- include("templates/HeavyCruiser.oxt")
?>
<Level>
@@ -32,77 +31,6 @@
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
<SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
- <MovableEntity position="0,0,0" collisionType=dynamic scale=1 linearDamping=0.8 angularDamping=0 collisiondamage=0.005 enablecollisiondamage=true>
- <attached>
- <Model position="0,0,0" mesh="cube.mesh" scale3D="40,40,40" />
- <StaticEntity position="0,90,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
- <attached>
- <Model position="0,0,0" mesh="cube.mesh" scale3D="30,30,30" />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
- </collisionShapes>
- </StaticEntity>
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="40,40,40" />
- </collisionShapes>
- </MovableEntity>
-
- <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,-100" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Pawn 0" >
- <attached>
- <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
- <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
- <StaticEntity position="0,-120,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
- <attached>
- <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
- <Model position="0,0,60" mesh="cube.mesh" scale3D="30,30,30" />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
- <BoxCollisionShape position="0,0,60" halfExtents="30,30,30" />
- </collisionShapes>
- </StaticEntity>
- <StaticEntity position="0,-180,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
- <attached>
- <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
- <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
- <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
- </collisionShapes>
- </StaticEntity>
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
- <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
- </collisionShapes>
- </Pawn>
-
- <Pawn health=1000 initialhealth=1000 maxhealth=1000 position="0,-100,100" direction="0,0,0" collisionType=dynamic mass=1000 name=box radarname = "Pawn 1" >
- <attached>
- <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
- <Model position="0,-60,0" mesh="cube.mesh" scale3D="30,30,30" />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
- <BoxCollisionShape position="0,-60,0" halfExtents="30,30,30" />
- </collisionShapes>
- </Pawn>
-
- <ModularSpaceShip position="0,-100,-200">
- <templates>
- <Template link=spaceshippirate />
- </templates>
- </ModularSpaceShip>
-
- <ModularSpaceShip position="0,-1000,-200" health="2000" maxhealth="4000" initialhealth="2000">
- <templates>
- <Template link=HeavyCruiser />
- </templates>
- </ModularSpaceShip>
-
</Scene>
</Level>
Modified: code/branches/modularships/data/levels/templates/HeavyCruiser.oxt
===================================================================
--- code/branches/modularships/data/levels/templates/HeavyCruiser.oxt 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/data/levels/templates/HeavyCruiser.oxt 2014-05-13 09:45:47 UTC (rev 10053)
@@ -51,11 +51,15 @@
<parts>
<ShipPart name="frontL" initialhealth="10" damageabsorption="0.5">
- <destructionevents>
- <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
- </destructionevents>
- </ShipPart>
- <ShipPart name="frontR" initialhealth="10" damageabsorption="0.5" />
+ <destructionevents>
+ <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
+ </destructionevents>
+ </ShipPart>
+ <ShipPart name="frontR" initialhealth="10" damageabsorption="0.5">
+ <destructionevents>
+ <PartDestructionEvent targetType="ship" targetParam="shieldhealth" operation="*" value="0.5"/>
+ </destructionevents>
+ </ShipPart>
<ShipPart name="partL" initialhealth="10" damageabsorption="0.5" />
<ShipPart name="partR" initialhealth="10" damageabsorption="0.5" />
<ShipPart name="sidearmL" initialhealth="20" damageabsorption="0.2" />
Added: code/branches/modularships/data/levels/templates/ModularSpaceShipTest.oxt
===================================================================
--- code/branches/modularships/data/levels/templates/ModularSpaceShipTest.oxt (rev 0)
+++ code/branches/modularships/data/levels/templates/ModularSpaceShipTest.oxt 2014-05-13 09:45:47 UTC (rev 10053)
@@ -0,0 +1,146 @@
+<Template name=ModularSpaceShipTest>
+ <ModularSpaceShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipassffcameras
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 1000
+ maxhealth = 2000
+ initialhealth = 1000
+
+ shieldhealth = 30
+ initialshieldhealth = 30
+ maxshieldhealth = 50
+ shieldabsorption = 0.8
+ reloadrate = 1
+ reloadwaittime = 1
+
+ primaryThrust = 100
+ auxilaryThrust = 30
+ rotationThrust = 50
+
+ lift = 1;
+ stallSpeed = 220;
+
+ boostPower = 15
+ boostPowerRate = 1
+ boostRate = 5
+ boostCooldownDuration = 10
+
+ shakeFrequency = 15
+ shakeAmplitude = 9
+
+ collisionType = "dynamic"
+ mass = 100
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+
+ explosionSound = "sounds/Explosion2.ogg"
+ >
+ <engines>
+ <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine />
+ <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine />
+ </engines>
+ <attached>
+
+ <Model position="0,0,0" mesh="crate.mesh" scale3D="6,6,6" />
+
+ <StaticEntity name="one" position="0,60,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="30,30,30" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ </collisionShapes>
+ </StaticEntity>
+
+ <StaticEntity name="two" position="0,0,60" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="30,30,30" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ </collisionShapes>
+ </StaticEntity>
+
+ <StaticEntity name="three" position="0,-60,0" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="30,30,30" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ </collisionShapes>
+ </StaticEntity>
+
+ <StaticEntity name="four" position="0,0,-60" direction="0,0,0" collisionType=static mass=100 friction=0.01 >
+ <attached>
+ <Model position="0,0,0" mesh="cube.mesh" scale3D="30,30,30" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ </collisionShapes>
+ </StaticEntity>
+
+ </attached>
+
+ <parts>
+ <ShipPart name="one" initialhealth="15" damageabsorption="1" />
+ <ShipPart name="two" initialhealth="15" damageabsorption="1" />
+ <ShipPart name="three" initialhealth="18" damageabsorption="1" />
+ <ShipPart name="four" initialhealth="20" damageabsorption="1" />
+ </parts>
+
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="30,30,30" />
+ </collisionShapes>
+<?lua
+ include("../includes/weaponSettingsAssff.oxi")
+?>
+ </ModularSpaceShip>
+</Template>
+
+<Template name=spaceshipassffcameras defaults=0>
+ <ModularSpaceShip>
+ <camerapositions>
+ <CameraPosition position="0,10, 40" drag=true mouselook=true />
+ </camerapositions>
+ </ModularSpaceShip>
+</Template>
+
+<Template name=spaceshipassffengine baseclass=MultiStateEngine>
+ <MultiStateEngine
+ boostfactor = 2
+
+ speedfront = 150
+ speedback = 50
+ speedleftright = 50
+ speedupdown = 50
+
+ defEngineSndNormal = "sounds/Engine_low.ogg"
+ defEngineSndBoost = "sounds/Engine_high.ogg"
+
+ accelerationfront = 500
+ accelerationbrake = 500
+ accelerationback = 125
+ accelerationleftright = 125
+ accelerationupdown = 125
+ >
+ <EffectContainer condition="idle">
+
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
+
+ </EffectContainer>
+ <EffectContainer condition="boost">
+
+ </EffectContainer>
+ </MultiStateEngine>
+</Template>
Modified: code/branches/modularships/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
===================================================================
--- code/branches/modularships/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp 2014-05-13 09:45:47 UTC (rev 10053)
@@ -20,6 +20,7 @@
#include "LinearMath/btIDebugDraw.h"
#include "LinearMath/btAabbUtil2.h"
#include "btManifoldResult.h"
+#include <iostream>
btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
:btActivatingCollisionAlgorithm(ci,body0,body1),
@@ -114,7 +115,8 @@
void ProcessChildShape(btCollisionShape* childShape,int index)
{
- btAssert(index>=0);
+ // std::cout << "PCS: " << childShape << std::endl; // FIXME: (noep) remove DEBUG
+ btAssert(index>=0);
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());
btAssert(index<compoundShape->getNumChildShapes());
Modified: code/branches/modularships/src/orxonox/Scene.cc
===================================================================
--- code/branches/modularships/src/orxonox/Scene.cc 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/src/orxonox/Scene.cc 2014-05-13 09:45:47 UTC (rev 10053)
@@ -344,8 +344,6 @@
/*static*/ bool Scene::collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
int index0, const btCollisionObject* colObj1, int partId1, int index1)
{
- orxout() << "collisionCb()" << endl;
-
// get the WorldEntity pointers
SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
@@ -361,8 +359,6 @@
if (object1->isCollisionCallbackActive())
modified |= object1->collidesAgainst(object0, cs0, cp);
- orxout() << "collisionCb() completed." << endl;
-
return modified;
}
}
Modified: code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc
===================================================================
--- code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/src/orxonox/items/PartDestructionEvent.cc 2014-05-13 09:45:47 UTC (rev 10053)
@@ -48,7 +48,7 @@
: Item(context)
{
RegisterObject(PartDestructionEvent);
- this->isValid_ = false;
+ this->setValid(true);
}
PartDestructionEvent::~PartDestructionEvent()
@@ -75,13 +75,30 @@
void PartDestructionEvent::execute()
{
- if(!this->isValid_)
+ // Do not execute if this event is invalid
+ if(!isValid())
{
- //orxout(internal_warning) <<
+ orxout(internal_warning) << "Attempted to execute an invalid PartDestructionEvent!" << endl;
return;
}
+ if (this->targetType_ == "ship")
+ {
+ switch (this->targetParam_) {
+ case shieldhealth:
+ this->parent_->getParent()->setShieldHealth(operate(this->parent_->getParent()->getShieldHealth()));
+ break;
+ default:
+ break;
+ }
+ this->setValid(false);
+ return;
+ }
+ }
+ void PartDestructionEvent::setParent(ShipPart* part)
+ {
+ this->parent_ = part;
}
void PartDestructionEvent::setTargetType(std::string type)
@@ -94,8 +111,8 @@
}
// Error, if invalid target-type was entered.
- orxout(internal_warning) << type << " is not a valid target-type for a PartDestructionEvent. Valid types are: ship engine weapon" << endl;
- this->isValid_ = false;
+ orxout(internal_warning) << "\"" << type << "\" is not a valid target-type for a PartDestructionEvent. Valid types are: ship engine weapon" << endl;
+ this->setValid(false);
return;
}
@@ -116,7 +133,7 @@
if (this->targetType_ == "NULL")
{
orxout(internal_warning) << "No valid target-type defined. Cannot set target-param for this PartDestructionEvent." << endl;
- this->isValid_ = false;
+ this->setValid(false);
return;
}
@@ -130,21 +147,45 @@
{
if (param == "shieldhealth")
{
- this->targetParam_ = param;
+ this->targetParam_ = shieldhealth;
return;
}
- 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;
+ 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;
return;
}
+
+ orxout(internal_warning) << "No valid target-param defined. The chosen param is either invalid or not available for this target-type." << endl;
+ this->setValid(false);
}
void PartDestructionEvent::setOperation(std::string operation)
{
// * + - destroy
- this->operation_ = operation;
+ if ((operation == "*") || (operation == "+") || (operation == "-") || (operation == "destroy"))
+ {
+ this->operation_ = operation;
+ return;
+ }
+ this->operation_ = "NULL";
+ orxout(internal_warning) << "\"" << operation << "\" is not a valid operation for a PartDestructionEvent. Valid operations are: * + - destroy" << endl;
}
+ float PartDestructionEvent::operate(float input)
+ {
+ if (this->operation_ == "*")
+ return input * this->value_;
+ if (this->operation_ == "+")
+ return input + this->value_;
+ if (this->operation_ == "-")
+ return input - this->value_;
+ if (this->operation_ == "destroy")
+ {
+ return 0;
+ }
+ return 0;
+ }
+
void PartDestructionEvent::setEventValue(float value)
{
this->value_ = value;
Modified: code/branches/modularships/src/orxonox/items/PartDestructionEvent.h
===================================================================
--- code/branches/modularships/src/orxonox/items/PartDestructionEvent.h 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/src/orxonox/items/PartDestructionEvent.h 2014-05-13 09:45:47 UTC (rev 10053)
@@ -43,6 +43,15 @@
public:
+ enum TargetParam
+ {
+ shieldhealth,
+ maxshieldhealth,
+ shieldabsorption,
+ shieldrechargerate,
+ null
+ };
+
PartDestructionEvent(Context* context);
virtual ~PartDestructionEvent();
@@ -50,6 +59,15 @@
void execute();
+ inline void setValid(bool valid)
+ { this->valid_ = valid; }
+ inline bool isValid()
+ { return this->valid_; }
+
+ void setParent(ShipPart* parent);
+ inline ShipPart* getParent()
+ { return this->parent_; }
+
void setTargetType(std::string type);
inline std::string getTargetType()
{ return this->targetType_; }
@@ -66,6 +84,8 @@
inline std::string getOperation()
{ return this->operation_; }
+ float operate(float input);
+
void setEventValue(float value);
inline float getEventValue()
{ return this->value_; }
@@ -74,11 +94,12 @@
private:
- bool isValid_;
+ ShipPart* parent_;
+ bool valid_;
std::string targetType_;
std::string targetName_;
- std::string targetParam_;
+ TargetParam targetParam_;
std::string operation_;
float value_;
Modified: code/branches/modularships/src/orxonox/items/ShipPart.cc
===================================================================
--- code/branches/modularships/src/orxonox/items/ShipPart.cc 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/src/orxonox/items/ShipPart.cc 2014-05-13 09:45:47 UTC (rev 10053)
@@ -50,6 +50,7 @@
: Item(context)
{
RegisterObject(ShipPart);
+ this->setAlive(true);
}
ShipPart::~ShipPart()
@@ -90,6 +91,19 @@
void ShipPart::death()
{
+ if (!(this->isAlive()))
+ return;
+
+ this->setAlive(false);
+
+ // Execute all destruction events
+ for (unsigned int i = 0; i < this->eventList_.size(); i++)
+ {
+ orxout() << "executing" << endl;
+ this->getDestructionEvent(i)->execute();
+ }
+
+ // Remove this ShipPart from the parent.
this->parent_->removeShipPart(this);
orxout() << this->getName() << " has died." << endl;
}
@@ -104,7 +118,6 @@
{
OrxAssert(entity != NULL, "The Entity cannot be NULL.");
this->entityList_.push_back(entity);
- //part->addToSpaceShip(this); //FIXME: (noep) add
}
/**
@@ -152,11 +165,11 @@
@param engine
A pointer to the PartDestructionEvent to be added.
*/
- void ShipPart::addDestructionEvent(PartDestructionEvent* part)
+ void ShipPart::addDestructionEvent(PartDestructionEvent* event)
{
- OrxAssert(part != NULL, "The PartDestructionEvent cannot be NULL.");
- this->eventList_.push_back(part);
- //part->setParent(this);
+ OrxAssert(event != NULL, "The PartDestructionEvent cannot be NULL.");
+ event->setParent(this);
+ this->eventList_.push_back(event);
}
/**
@@ -167,7 +180,7 @@
*/
PartDestructionEvent* ShipPart::getDestructionEvent(unsigned int index)
{
- if(this->eventList_.size() >= index)
+ if(this->eventList_.size() <= index)
return NULL;
else
return this->eventList_[index];
@@ -199,6 +212,7 @@
void ShipPart::handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator)
{
orxout() << "ShipPart " <<this->getName() << " is handling a hit!" << endl;
+
if (parent_->getGametype() && parent_->getGametype()->allowPawnDamage(parent_, originator))
{
if (shielddamage >= parent_->getShieldHealth())
Modified: code/branches/modularships/src/orxonox/items/ShipPart.h
===================================================================
--- code/branches/modularships/src/orxonox/items/ShipPart.h 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/src/orxonox/items/ShipPart.h 2014-05-13 09:45:47 UTC (rev 10053)
@@ -72,6 +72,11 @@
inline ModularSpaceShip* getParent()
{ return this->parent_; }
+ inline void setAlive(bool var)
+ { this->alive_ = var; }
+ inline bool isAlive()
+ { return this->alive_; }
+
virtual void setHealth(float health);
inline void addHealth(float health)
{ this->setHealth(this->health_ + health); }
@@ -107,7 +112,9 @@
std::vector<StaticEntity*> entityList_; // list of all entities which belong to this part
std::vector<PartDestructionEvent*> eventList_; // The list of all PartDestructionEvent assigned to this ShipPart.
+ bool alive_;
+
}; // tolua_export
} // tolua_export
Modified: code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/src/orxonox/worldentities/WorldEntity.cc 2014-05-13 09:45:47 UTC (rev 10053)
@@ -118,7 +118,6 @@
*/
WorldEntity::~WorldEntity()
{
- orxout() << "destroying " << this->getIdentifier()->getName() << endl;
if (this->isInitialized())
{
if (this->parent_)
@@ -580,7 +579,6 @@
void WorldEntity::detachCollisionShape(CollisionShape* shape)
{
// Note: The collision shapes may not be detached with this function!
- orxout() << "WE: detachCS()" << endl;
this->collisionShape_->detach(shape);
// Note: this->collisionShape_ already notifies us of any changes.
}
Modified: code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc 2014-05-08 14:20:26 UTC (rev 10052)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc 2014-05-13 09:45:47 UTC (rev 10053)
@@ -132,13 +132,13 @@
SmartPtr<StaticEntity>* one = &newSmartPtr;
this->entityPtrList_.push_back(one);
- this->createCSPtrList(this->getWorldEntityCollisionShape());
+ //this->createCSPtrList(this->getWorldEntityCollisionShape());
orxout() << "New entity-part assignment created!" << endl;
}
// This should add smartPointers to all (Orxonox)Collisionshapes of this SpaceShip, preventing them fromg etting deleted. Might not work due to weird acting getAttachedShape
- void ModularSpaceShip::createCSPtrList(CompoundCollisionShape* cs)
+ void ModularSpaceShip::createCSPtrList(CompoundCollisionShape* cs) // FIXME: (noep) remove debug
{
for (int i=0; i < cs->getNumChildShapes(); i++)
{
@@ -207,8 +207,6 @@
//orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl;
- orxout() << "CP before handleHit" << endl;
-
if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL)
this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator);
else
@@ -254,7 +252,6 @@
OrxAssert(part != NULL, "The ShipPart cannot be NULL.");
this->partList_.push_back(part);
part->setParent(this);
- //part->addToSpaceShip(this); //FIXME: (noep) add
this->updatePartAssignment();
}
@@ -266,7 +263,7 @@
*/
ShipPart* ModularSpaceShip::getShipPart(unsigned int index)
{
- if(this->partList_.size() >= index)
+ if(this->partList_.size() <= index)
return NULL;
else
return this->partList_[index];
@@ -338,7 +335,7 @@
this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
this->detachCollisionShape(object->collisionShape_); // after succeeding, causes a crash in the collision handling
- this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
+ //this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0);
// mass
if (object->getMass() > 0.0f)
More information about the Orxonox-commit
mailing list