2
0
Эх сурвалжийг харах

Added support for Scene.UpdateRate 0 which can be used to pause.

Mark Sibly 7 жил өмнө
parent
commit
43b460a9b0

+ 9 - 0
modules/mojo3d/scene/scene.monkey2

@@ -184,6 +184,13 @@ Class Scene
 	
 	
 	Setter( updateRate:Float )
 	Setter( updateRate:Float )
 		
 		
+		If updateRate=_updateRate Return
+		
+		If updateRate And Not _updateRate
+			_time=Now()
+			_elapsed=0
+		Endif
+		
 		_updateRate=updateRate
 		_updateRate=updateRate
 	End
 	End
 	
 	
@@ -299,6 +306,8 @@ Class Scene
 	#end
 	#end
 	Method Update()
 	Method Update()
 		
 		
+		If Not _updateRate Return
+		
 		If Not _started
 		If Not _started
 			BeginUpdating()
 			BeginUpdating()
 			Start()
 			Start()

+ 6 - 4
modules/mojo3d/tests/shapes.monkey2

@@ -36,10 +36,6 @@ Class MyWindow Extends Window
 		Local model:=Model.CreateBox( box,16,16,16,material )
 		Local model:=Model.CreateBox( box,16,16,16,material )
 		model.Name="Ground"
 		model.Name="Ground"
 		
 		
-		model.Collided+=Lambda( body:RigidBody )
-'			Print "Ground hit: "+body.Entity.Name
-		End
-
 		Local collider:=model.AddComponent<BoxCollider>()
 		Local collider:=model.AddComponent<BoxCollider>()
 		collider.Box=box
 		collider.Box=box
 
 
@@ -47,6 +43,10 @@ Class MyWindow Extends Window
 		body.CollisionGroup=64
 		body.CollisionGroup=64
 		body.CollisionMask=127
 		body.CollisionMask=127
 		body.Mass=0
 		body.Mass=0
+		
+		model.RigidBody.Collided+=Lambda( body:RigidBody )
+'			Print "Ground hit: "+body.Entity.Name
+		End
 	End
 	End
 
 
 	Method CreateBodies()		
 	Method CreateBodies()		
@@ -175,6 +175,8 @@ Class MyWindow Extends Window
 		
 		
 		RequestRender()
 		RequestRender()
 		
 		
+		If Keyboard.KeyHit(Key.Space) _scene.UpdateRate=_scene.UpdateRate ? 0 Else 60
+		
 		_scene.Update()
 		_scene.Update()
 		
 		
 		If _marker
 		If _marker