Skip to content

Commit 2354edc

Browse files
committed
Return vertex objects to pool after making a compound
1 parent 17fe1a1 commit 2354edc

4 files changed

Lines changed: 20 additions & 13 deletions

File tree

docs/GlowScriptDocs/libraryuse.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,28 @@
107107
&nbsp;&nbsp;&nbsp;&nbsp;print(f.text)<br />
108108
}<br />
109109
read_local_file(get) // establish callback </p>
110-
<p class="Normal">The function <span class="attribute">get_library()</span> times out if the library cannot be loaded and posts an alert to the user, asking whether the user wants to attempt the operation again. Here is a way to use this function without the keyword <span class="attribute">wait</span>:</p>
110+
<p class="Normal">The function <span class="attribute">get_library()</span> times out if the library cannot be loaded and posts an alert to the user, asking whether the user wants to attempt the operation again. Here is one way to use this function: </p>
111111
<p class="program">var loaded = false<br />
112-
var start = new Date().getSeconds()<br />
113-
var load = function() { loaded = true }<br />
112+
var load = function() { loaded = true }<br />
114113
<br />
115114
get_library(file, load)<br />
116115
<br />
117116
var wait_for_load = function() {<br />
118117
&nbsp;&nbsp;if (loaded) {<br />
119118
&nbsp;&nbsp;&nbsp;&nbsp;print('Got library')<br />
119+
&nbsp;&nbsp;&nbsp;&nbsp;// use the library <br />
120120
&nbsp;&nbsp;} else {<br />
121-
&nbsp;&nbsp;&nbsp;&nbsp;var t = new Date().getSeconds()<br />
122-
&nbsp;&nbsp;&nbsp;&nbsp;if (t - start &gt; 2) {<br />
123-
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(&quot;Takes more than 2 sec&quot;)<br />
124-
&nbsp;&nbsp;} else {<br />
125-
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rate(30,wait_for_load)<br />
121+
&nbsp;&nbsp;&nbsp;&nbsp;rate(30,wait_for_load)<br />
126122
&nbsp;&nbsp;}<br />
127123
}<br />
128124
<br />
129-
wait_for_load()</p>
125+
wait_for_load()<br />
126+
while (!loaded) {<br />
127+
&nbsp;&nbsp;rate(30,wait)<br />
128+
}<br />
129+
print('Library is loaded')
130+
<br />
131+
</p>
130132
<p class="Normal">The same structure can be used with <span class="attribute">scene.waitfor('textures',load)</span>, with the difference that there is no timeout; if any of the textures requested for objects cannot be found, the load() function will never be called. This structure can also be used with <span class="attribute">scene.pause('Click to see something',load)</span>.</p>
131133
<p class="Normal">&nbsp;</p>
132134
<!-- InstanceEndEditable --></td>

lib/glow/primitives.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,11 +1030,15 @@
10301030
update_extent( this, mesh.merge(o.v0, o.v0, 0) )
10311031
update_extent( this, mesh.merge(o.v1, o.v1, 0) )
10321032
update_extent( this, mesh.merge(o.v2, o.v2, 0) )
1033+
this.canvas.__vertices.available.push(o.v0.__id) // release no longer needed vertex objects
1034+
this.canvas.__vertices.available.push(o.v1.__id)
1035+
this.canvas.__vertices.available.push(o.v2.__id)
10331036
if (o instanceof quad) {
10341037
// Bias the index to point to already existing data:
10351038
update_extent( this, mesh.merge(o.v0, o.v0, -3) )
10361039
update_extent( this, mesh.merge(o.v2, o.v2, -1) )
10371040
update_extent( this, mesh.merge(o.v3, o.v3, 0) )
1041+
this.canvas.__vertices.available.push(o.v3.__id)
10381042
}
10391043
} else {
10401044
update_extent( this, mesh.merge(o.getTransformedMesh(), o, 0) )

package/glow.1.1.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

untrusted/run.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ function ideRun() {
181181
}
182182

183183
function reportScriptError(program, err) { // This machinery only works on Chrome
184-
// err.stack: https://code.google.com/p/v8-wiki/wiki/JavaScriptStackTraceApi
185-
// TraceKit - Cross browser stack traces: https://github.com/occ/TraceKit
184+
// TraceKit - Cross browser stack traces: https://github.com/csnover/TraceKit
185+
//console.log('Error', err)
186+
//console.log('Stack', err.stack)
186187
var referror = (err.__proto__.name === 'ReferenceError')
187188
//var unpack = /[ ]*at[ ]([^ ]*)[^>]*>:(\d*):(\d*)/
188189
var unpack = /[ ]*at[ ]([^ ]*)[^>]*>:(\d*):(\d*)/

0 commit comments

Comments
 (0)