Skip to content

Commit 6eb82b2

Browse files
committed
Added SimTime.getUnlockedTime() for those rare occasions
when code needs to know the "real" time and not the current frame time.
1 parent 4a12f08 commit 6eb82b2

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
apply plugin: 'java'
1515
apply plugin: 'maven'
1616

17-
version='1.2.0'
17+
version='1.2.0-SNAPSHOT'
1818
group='com.simsilica'
1919

2020
ext.jmeVersion = "3.2.1-stable"

release-notes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Version 1.2.0 (latest)
2+
Version 1.2.0 (unreleased)
33
--------------
44
* Fixed a SimTime initialization problem where the first tpf would be
55
huge.
@@ -30,6 +30,8 @@ Version 1.2.0 (latest)
3030
that game time begins counting from the first frame.
3131
* Fixed an NPE in CompositeAppState.addChild() when called after the outer state is
3232
attached but before it was initialized. See PR #5.
33+
* Added SimTime.getUnlockedTime() which will return a SimTime-translated time
34+
between frames, ie: not frame locked.
3335
* Set sourceCompatibility to 1.7 and turned on detailed 'unchecked' warnings
3436
* Suppressed 'unchecked' warnings in some methods of EntityContainer, EventBus,
3537
and DecaySystem where it is known that the operations are safe or safe-ish,

src/main/java/com/simsilica/sim/SimTime.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ public void update( long time ) {
6464
this.time = time;
6565
}
6666

67+
/**
68+
* Returns the SimTime version of the specified timestamp that
69+
* is compatible with what would normally be provided to update().
70+
* SimTime.getTime() will provide 'frame locked' timestamps that will
71+
* not update during a frame which is what the systems will want 99.99%
72+
* of the time. Rarely it is desirable to get a "real" timestamp that
73+
* is not locked to frames, usually as part of providing matching accurate
74+
* timesource information to something else that is trying to synch.
75+
*/
76+
public long getUnlockedTime( long time ) {
77+
return time - baseTime;
78+
}
79+
6780
public long toSimTime( double seconds ) {
6881
return (long)(seconds * invTimeScale);
6982
}

0 commit comments

Comments
 (0)