Skip to content

Commit 1ec8418

Browse files
committed
Removed some System.out.println() watchdog statements and replaced it with
the ability to control clamping in the TransitionBuffer. Some code that was doing bad things before might not do it silently... but some code that is doing good things actually wants this clamping.
1 parent 619bd6a commit 1ec8418

3 files changed

Lines changed: 32 additions & 12 deletions

File tree

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.0.1'
17+
version='1.0.2-SNAPSHOT'
1818
group='com.simsilica'
1919

2020
// Version meta-data

release-notes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 1.0.2 (unreleased)
2+
--------------
3+
* Modified TransitionBuffer to have a 'clamp' on getTransition()
4+
that when 'true' will use the old behavior of returning the
5+
earliest/latest transition for out-of-range times. For 'false',
6+
it will return null for out-of-range times.
7+
* Modified TransitionBuffer to remove the System.out.println() for
8+
out-of-range times.
19

210
Version 1.0.1
311
--------------

src/main/java/com/simsilica/mathd/trans/TransitionBuffer.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ private int previous( int index ) {
125125
}
126126

127127
public T getTransition( long time ) {
128+
return getTransition(time, true);
129+
}
130+
131+
public T getTransition( long time, boolean clamp ) {
128132

129133
// We run forward from head to tail so that
130134
// the loop moving underneath us matters less.
@@ -169,12 +173,16 @@ public T getTransition( long time ) {
169173
}
170174

171175
if( time < ft.getStartTime() ) {
172-
System.out.println("!!!!!<<<<< Time:" + time + " earlier than ft:" + ft);
173-
// The only way we could have gotten here is if we
174-
// asked for a time before anything we have... because
175-
// otherwise, time would have been contained in the
176-
// previous entry
177-
return (T)ft;
176+
//System.out.println("!!!!!<<<<< Time:" + time + " earlier than ft:" + ft);
177+
if( clamp ) {
178+
// The only way we could have gotten here is if we
179+
// asked for a time before anything we have... because
180+
// otherwise, time would have been contained in the
181+
// previous entry
182+
return (T)ft;
183+
} else {
184+
return null;
185+
}
178186
}
179187

180188
if( time <= ft.getEndTime() ) {
@@ -184,11 +192,15 @@ public T getTransition( long time ) {
184192
last = ft;
185193
}
186194

187-
System.out.println("!!!!!>>>>> Time:" + time + " later than last:" + last + " h:" + h + " t:" + t + " count:" + count);
188-
// The only way we could have gotten here is if we asked
189-
// for a time after this buffer contains... in which case
190-
// we'll just return the last value.
191-
return (T)last;
195+
//System.out.println("!!!!!>>>>> Time:" + time + " later than last:" + last + " h:" + h + " t:" + t + " count:" + count);
196+
if( clamp ) {
197+
// The only way we could have gotten here is if we asked
198+
// for a time after this buffer contains... in which case
199+
// we'll just return the last value.
200+
return (T)last;
201+
} else {
202+
return null;
203+
}
192204
}
193205

194206
@Override

0 commit comments

Comments
 (0)