File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,27 @@ pub struct Fixed {
49
49
}
50
50
51
51
impl Time < Fixed > {
52
+ /// Return new fixed time clock with given timestep as `Duration`
53
+ pub fn from_duration ( timestep : Duration ) -> Self {
54
+ let mut ret = Self :: default ( ) ;
55
+ ret. set_timestep ( timestep) ;
56
+ ret
57
+ }
58
+
59
+ /// Return new fixed time clock with given timestep seconds as `f64`
60
+ pub fn from_seconds ( seconds : f64 ) -> Self {
61
+ let mut ret = Self :: default ( ) ;
62
+ ret. set_timestep_seconds ( seconds) ;
63
+ ret
64
+ }
65
+
66
+ /// Return new fixed time clock with given timestep frequency as `f64`
67
+ pub fn from_hz ( hz : f64 ) -> Self {
68
+ let mut ret = Self :: default ( ) ;
69
+ ret. set_timestep_hz ( hz) ;
70
+ ret
71
+ }
72
+
52
73
/// Returns the amount of virtual time that must pass before the fixed
53
74
/// timestep schedule is run again.
54
75
pub fn timestep ( & self ) -> Duration {
Original file line number Diff line number Diff line change @@ -69,6 +69,13 @@ pub struct Virtual {
69
69
impl Time < Virtual > {
70
70
const DEFAULT_MAX_DELTA : Duration = Duration :: from_millis ( 333 ) ; // XXX: better value
71
71
72
+ /// Create new virtual clock with given maximum delta step `Duration`
73
+ pub fn from_max_delta ( max_delta : Duration ) -> Self {
74
+ let mut ret = Self :: default ( ) ;
75
+ ret. set_max_delta ( max_delta) ;
76
+ ret
77
+ }
78
+
72
79
/// Returns the maximum amount of time that can be added to this clock by a
73
80
/// single update, as [`std::time::Duration`].
74
81
///
You can’t perform that action at this time.
0 commit comments