Explorar el Código

refactor shitty clamping

Johann Woelper hace 8 años
padre
commit
c549de3829
Se han modificado 1 ficheros con 5 adiciones y 17 borrados
  1. 5 17
      server/src/main.rs

+ 5 - 17
server/src/main.rs

@@ -68,23 +68,11 @@ impl Biome {
                 lifeform.mass = 0.0;
             }
 
-
-
-            //keep lifeform in bounds
-            //TODO: clamp
-            if lifeform.position[0] < 0.0 {
-                lifeform.position[0] = 0.0;
-            }
-            if lifeform.position[0] > self.width {
-                lifeform.position[0] = self.width;
-            }
-
-            if lifeform.position[2] > self.height {
-                lifeform.position[2] = self.height;
-            }
-            if lifeform.position[2] < 0.0 {
-                lifeform.position[2] = 0.0;
-            }
+            //keep lifeform in bounds - clamp does not work on f32? why?
+            if lifeform.position[0] > self.width {lifeform.position[0] = self.width};
+            if lifeform.position[2] > self.height {lifeform.position[2] = self.height};
+            lifeform.position[0] = lifeform.position[0].abs();
+            lifeform.position[2] = lifeform.position[2].abs();
 
         }
     }