[Orxonox-commit 5614] r10274 - in code/trunk: data/levels src/orxonox/worldentities

landauf at orxonox.net landauf at orxonox.net
Sun Feb 15 23:12:00 CET 2015


Author: landauf
Date: 2015-02-15 23:11:59 +0100 (Sun, 15 Feb 2015)
New Revision: 10274

Modified:
   code/trunk/data/levels/iJohnVane_TriptoArea51.oxw
   code/trunk/src/orxonox/worldentities/WorldEntity.cc
Log:
fixed #419 http://www.orxonox.net/ticket/419
physics is only activated if a WorldEntity is active. so we should toggle physics if activity changes.

Modified: code/trunk/data/levels/iJohnVane_TriptoArea51.oxw
===================================================================
--- code/trunk/data/levels/iJohnVane_TriptoArea51.oxw	2015-02-15 20:46:31 UTC (rev 10273)
+++ code/trunk/data/levels/iJohnVane_TriptoArea51.oxw	2015-02-15 22:11:59 UTC (rev 10274)
@@ -375,26 +375,25 @@
    ?>
 
    <MovableEntity    
-      position = "<?lua print(math.random()* 600-300) ?>,<?lua print(math.random() * 40000 + 110000) ?>,<?lua print(math.random() * 600-300) ?>"
+      position = "<?lua print(math.random()* 600-300) ?>,<?lua print(math.random() * 40000 + 97000) ?>,<?lua print(math.random() * 600-300) ?>"
       scale = "<?lua print(j * 40)?>"
       velocity = "<?lua print(x*20-10)?>, <?lua print(y*60-160)?>, <?lua print(z*20-10)?>"
       collisionType = dynamic
       collisiondamage = 0.05
       enablecollisiondamage = true 
-      active = true
+      active = false
    >                 
           <attached>           
-              <Model mass="<?lua print(j * 1000) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" >
-                  <events>           
-                    <visibility>           
-                      <EventListener event="portal3" />           
-                    </visibility>           
-                  </events>
-              </Model>                          
+              <Model mass="<?lua print(j * 1000) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
           </attached> 
          <collisionShapes>
              <SphereCollisionShape radius="<?lua print(j * 50) ?>" />
          </collisionShapes>   
+         <events>           
+           <activity>           
+             <EventListener event="portal3" />           
+           </activity>           
+         </events>
    </MovableEntity>
 
    <?lua
@@ -413,27 +412,25 @@
       z = math.random()
    ?>
    <MovableEntity    
-      position = "<?lua print(math.random()* 240-120) ?>,<?lua print(math.random() * 40000 + 110000) ?>,<?lua print(math.random()* 240-120) ?>"
+      position = "<?lua print(math.random()* 240-120) ?>,<?lua print(math.random() * 40000 + 97000) ?>,<?lua print(math.random()* 240-120) ?>"
       scale = "10"
       velocity = "0, -160, 0"
       collisionType = dynamic
       collisiondamage = 0.05
       enablecollisiondamage = true 
-      active = true
-      visible = false
+      active = false
    >                     
           <attached>           
-              <Model mass="2000" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" >
-                  <events>           
-                    <visibility>           
-                      <EventListener event="portal3" />           
-                    </visibility>           
-                  </events>
-              </Model>                    
+              <Model mass="2000" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
           </attached> 
          <collisionShapes>
              <SphereCollisionShape radius="10" />
          </collisionShapes>   
+         <events>           
+           <activity>           
+             <EventListener event="portal3" />           
+           </activity>           
+         </events>
    </MovableEntity>
    <?lua
       end

Modified: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc	2015-02-15 20:46:31 UTC (rev 10273)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc	2015-02-15 22:11:59 UTC (rev 10274)
@@ -220,6 +220,13 @@
 
         if(GameMode::isMaster())
         {
+            // physics is only enabled if the WorldEntity is active
+            if (this->isActive())
+                this->activatePhysics();
+            else
+                this->deactivatePhysics();
+
+            // iterate over all children and change their activity as well
             for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
             {
                 if(!this->isActive())
@@ -245,6 +252,7 @@
 
         if(GameMode::isMaster())
         {
+            // iterate over all children and change their visibility as well
             for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
             {
                 if(!this->isVisible())




More information about the Orxonox-commit mailing list