<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[GMan's Mods & Stuff — Removing Scene Nodes from an Array.]]></title>
	<link rel="self" href="https://gprogs.com/extern.php?action=feed&amp;tid=128&amp;type=atom" />
	<updated>2006-11-27T22:31:12Z</updated>
	<generator>PunBB</generator>
	<id>https://gprogs.com/viewtopic.php?id=128</id>
		<entry>
			<title type="html"><![CDATA[Re: Removing Scene Nodes from an Array.]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=535#p535" />
			<content type="html"><![CDATA[<p>Thank you, that was the problem. Now it&#039;s working fine.<br />Thank you for the compliment. Wait till you see what I&#039;m working on.<br />Keep up the great work on the mods. Bye</p>]]></content>
			<author>
				<name><![CDATA[HondaDirtBiker]]></name>
				<uri>https://gprogs.com/profile.php?id=5</uri>
			</author>
			<updated>2006-11-27T22:31:12Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=535#p535</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Removing Scene Nodes from an Array.]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=534#p534" />
			<content type="html"><![CDATA[<p>greetings <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" />&nbsp; the only thing that raises a flag in my mind is the erase() call inside the loop.&nbsp; this will resize the array during the loop and cause skipping of nodes.&nbsp; for example, if i was on node 1 and then erased it, node 2 is now node 1 but my next index is 2.&nbsp; old node 2 is now completely skipped.&nbsp; i would try building a TList or array to queue up the erase calls and then call them after the main for loop.&nbsp; the second loop would essentially call the erase() in descending order.&nbsp; an alternative is store the size and loop backwards in your for loop using the stored size instead of the Size() call.&nbsp; </p><p>also, are you rebuilding the array coming back into this code or is the AsteroidNode array persistant?&nbsp; if for some reason Irrlicht decides to remove one of the other scenenodes in the array that could cause this error also.</p><p>on a side note, i have long thought about a simple try/catch that would improve the IsValid() functionality.&nbsp; i may see if there is something i can do about that in the next version.&nbsp; the reason i have not yet done it is most of the time the crashes are telling you something.&nbsp; not sure if i want to eliminate that or not.</p><p>EDIT: i checked out the SpacePirate screenies.&nbsp; looking good <img src="https://gprogs.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[gman]]></name>
				<uri>https://gprogs.com/profile.php?id=2</uri>
			</author>
			<updated>2006-11-27T12:48:15Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=534#p534</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Removing Scene Nodes from an Array.]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=533#p533" />
			<content type="html"><![CDATA[<p>I need to create scenenodes in an array, find information about each element, then delete certain scenenodes within the array.<br />I wrote this code to delete certain nodes but after I delete some nodes then run the function again I receive an error saying &quot;unhandled memory exception, cannot getposition()&quot;<br /></p><div class="codebox"><pre><code>&#039;Delete Asteroid
Local PlayerPos:Vector3df = PlayerNode.getPosition() &#039;Position of Player

If (AsteroidNode.Size() &gt; 0)
    Local Ast:Int &#039;Current Array Element
    
    For Ast = 0 To AsteroidNode.Size() - 1
        Local AstNode:ISceneNode = AsteroidNode.elementAt(Ast) &#039;Current Asteroid Node
        
        If (AstNode.isValid() = True)
            If (AstNode.getPosition().getDistanceFrom(PlayerPos) &gt; Radius And AstNode.getName() &gt;&lt; &quot;Cave&quot;)
                AstNode.Remove()
                AsteroidNode.erase(Ast)
            End If
        End If
    Next
End If</code></pre></div><p>I could be removing the scenenodes incorrectly but, If I don&#039;t remove the scenenode before the element, the scenenode is not removed.</p>]]></content>
			<author>
				<name><![CDATA[HondaDirtBiker]]></name>
				<uri>https://gprogs.com/profile.php?id=5</uri>
			</author>
			<updated>2006-11-24T20:23:17Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=533#p533</id>
		</entry>
</feed>
