<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Maratis forum - OO stuff and frame drop]]></title>
		<link>http://forum.maratis3d.com/viewtopic.php?id=923</link>
		<description><![CDATA[The most recent posts in OO stuff and frame drop.]]></description>
		<lastBuildDate>Thu, 06 Feb 2014 16:51:50 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6348#p6348</link>
			<description><![CDATA[<p>Hi, i went the safe way and directly used both techniques <img src="http://forum.maratis3d.com/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Vegas)]]></author>
			<pubDate>Thu, 06 Feb 2014 16:51:50 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6348#p6348</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6345#p6345</link>
			<description><![CDATA[<p>Hi Vegas,<br />yes, thank you for adding the technique to the wiki.</p><p>For your game, was the pre-allocation of clone enough<br />or did you also use the simpler collision detection describe above ?</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Thu, 06 Feb 2014 14:46:43 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6345#p6345</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6336#p6336</link>
			<description><![CDATA[<div class="quotebox"><cite>sunnystormy wrote:</cite><blockquote><p>Good luck with your game, Vegas! <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p></blockquote></div><p>hehe thanks <img src="http://forum.maratis3d.com/img/smilies/wink.png" width="15" height="15" alt="wink" /></p><p>I had some trouble setting-up everything but now it&#039;s all good, i can spawn projectiles <br />just like in the gameplay video on the first post without any frame drop <img src="http://forum.maratis3d.com/img/smilies/cool.png" width="15" height="15" alt="cool" /></p><p>Also, anael i&#039;m gonna add your explanations about clones on the wiki if you don&#039;t mind, <br />that&#039;s some important infos imo</p><p>Cheers !</p>]]></description>
			<author><![CDATA[dummy@example.com (Vegas)]]></author>
			<pubDate>Thu, 06 Feb 2014 03:26:18 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6336#p6336</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6302#p6302</link>
			<description><![CDATA[<p>Cool. Thanks for explaining. Good luck with your game, Vegas! <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (sunnystormy)]]></author>
			<pubDate>Fri, 31 Jan 2014 15:40:15 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6302#p6302</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6299#p6299</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>To add to the point of pre-allocating memory; are there ways for users to get more control over the heap? Or to be able to create our own?</p></blockquote></div><p>It&#039;s a natural bottleneck, specially for fast game like this shooting game where hundred of objects are created in a single frame. It&#039;s not just the memory allocation, but the fact that a new object need to be added to the scene description, some object data need to be initialized (matrices, references, parenting).</p><p>Also, it&#039;s possible that the slow down in this example is more related to the physics than a pure memory allocation bottleneck, in an indirect way, like above, because the collision object need to be added to the physics scene, the scene octree probably need to be updated because of that, etc.</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Thu, 30 Jan 2014 17:17:34 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6299#p6299</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6298#p6298</link>
			<description><![CDATA[<p>To add to the point of pre-allocating memory; are there ways for users to get more control over the heap? Or to be able to create our own?</p>]]></description>
			<author><![CDATA[dummy@example.com (sunnystormy)]]></author>
			<pubDate>Thu, 30 Jan 2014 16:37:52 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6298#p6298</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6297#p6297</link>
			<description><![CDATA[<p>In fact, i would never have guessed how it works, Thank you sir <img src="http://forum.maratis3d.com/img/smilies/wink.png" width="15" height="15" alt="wink" /> <br />now let&#039;s rock <img src="http://forum.maratis3d.com/img/smilies/cool.png" width="15" height="15" alt="cool" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Vegas)]]></author>
			<pubDate>Thu, 30 Jan 2014 15:55:20 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6297#p6297</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6296#p6296</link>
			<description><![CDATA[<p>The radius is just a value you have to choose.<br />Sphere to Sphere collision works like that :<br /><span class="postimg"><img src="https://community.aldebaran-robotics.com/doc/1-14/_images/motion_collision_sphere_2.png" alt="https://community.aldebaran-robotics.com/doc/1-14/_images/motion_collision_sphere_2.png" /></span><br />when D is inferior than r1+r2 it means the two sphere are colliding.</p><p>Let&#039;s say the object Enemy1 has a radius of 10 units and that the object Bullet1 a radius of 2 :</p><div class="codebox"><pre><code>Enemy1 = getObject(&quot;Enemy1&quot;)
Bullet1 = getObject(&quot;Bullet1&quot;)

Enemy1_radius = 10
Bullet1_radius = 2

function onSceneUpdate()

    Enemy1_pos = getTransformedPosition(Enemy1)
    Bullet1_pos = getTransformedPosition(Bullet1)

    distance = length(Enemy1_pos - Bullet1_pos)

    if distance &lt; (Enemy1_radius + Bullet1_radius) then -- collision !
        -- do something
    end 

end</code></pre></div><p>(the radius don&#039;t need to be the exact same size of the mesh, in shoot game it&#039;s usually smaller to reduce difficulty, choose the best value for the gameplay)</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Thu, 30 Jan 2014 15:30:55 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6296#p6296</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6294#p6294</link>
			<description><![CDATA[<p>Thanks you &amp; thank you, everything&#039;s more clearer now <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>And hum, I feel a bit dumb to ask again, as you and ant0n practically wrote 90% of my project&#039;s scripts but, there&#039;s alot of situation where i wanted to use this distance method instead of physics collisions, how can i get the two objects radius like in you small snippet ?</p><p>(projectileRadius + objectRadius)</p><p>could you make a little example when you have time ?</p>]]></description>
			<author><![CDATA[dummy@example.com (Vegas)]]></author>
			<pubDate>Thu, 30 Jan 2014 14:13:23 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6294#p6294</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6293#p6293</link>
			<description><![CDATA[<p>Hi Vegas,<br />your video looks quite interesting, waiting to see more !</p><p>About the frame drop, there is some concept that need to be understood :</p><p>1 : dynamic object creation is not fast, for multiple reasons :<br />&nbsp; - memory allocation : each cloning allocate new memory, fast games usually pre-allocate memory.<br />&nbsp; - when using physics, the new object need to be also allocated to the physics world<br />&nbsp; - when using sound, the source need to be also allocated to the sound context</p><p>2 : collision need to be optimized for your need</p><p>There is two things I suggest :</p><p>1 : pre-allocate the projectiles :<br />&nbsp; - clone a list of each object at the beginning of the scene, think about how much of each projectile<br />&nbsp; &nbsp; would be used at max at the same time (let&#039;s say 32 of each)<br />&nbsp; - when you shot a projectile, use one of the object from the list and turn with this 32 objects</p><p>2 : if it&#039;s still slow, try to not use physics where it&#039;s not necessary :<br />&nbsp; <br />for example, use a simpler collision test for the projectiles :<br />(if the distance between object and projectile is less than a certain distance, there is a collision)</p><div class="codebox"><pre><code>distance = length(projectilePos - objectPos)

if distance &lt; (projectileRadius + objectRadius) then
  --do something
end</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Thu, 30 Jan 2014 08:29:08 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6293#p6293</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6292#p6292</link>
			<description><![CDATA[<p>I want to help You, but unfortunately I can not understand.. Google translate is not perfect. <img src="http://forum.maratis3d.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (ant0n)]]></author>
			<pubDate>Thu, 30 Jan 2014 05:23:31 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6292#p6292</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6290#p6290</link>
			<description><![CDATA[<p>All my objects are already clones (here&#039;s a <a href="https://dl.dropboxusercontent.com/u/19970067/v00001.mp4">video</a> of the current project)</p><p>It&#039;s just that spawning them faster, like in the video in my first post will make the frame rate goes crazy.<br />also,&nbsp; testing collision between clones is making the game freeze after a while.</p>]]></description>
			<author><![CDATA[dummy@example.com (Vegas)]]></author>
			<pubDate>Thu, 30 Jan 2014 02:20:23 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6290#p6290</guid>
		</item>
		<item>
			<title><![CDATA[Re: OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6288#p6288</link>
			<description><![CDATA[<p>If you want the spawning to behave more like a particle system, you probably want to use the getClone function for bullets, and also give each clone a lifetime that it can be active. </p><p>Take you can take cues from the settings of the particle system in Blender. I just made a post called &quot;Code snippets.&quot; The first post is a snippet that allows you to clone an object on another object&#039;s position. My objects are 3d with no velocity, but if your objects are just flat planes then it should move even faster.</p>]]></description>
			<author><![CDATA[dummy@example.com (Tutorial Doctor)]]></author>
			<pubDate>Thu, 30 Jan 2014 01:09:26 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6288#p6288</guid>
		</item>
		<item>
			<title><![CDATA[OO stuff and frame drop]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6285#p6285</link>
			<description><![CDATA[<p>Hello! i&#039;m having multiple problems with on my shooter project, <br />have a look at this <a href="http://youtu.be/hd63DJDqVMU?t=3m17s">Video</a>, it&#039;s a gameplay vid of an arcade game that illustrate some of the problems i&#039;m having.</p><p>And i apologise for my english / clarity of what i&#039;m trying to explain. i have very hard times doing this.</p><p>I&#039;m using the same script than <a href="http://forum.maratis3d.com/viewtopic.php?pid=6042#p6042">Here</a> (+&nbsp; the isActive(object) for optimisation that is not present here) for all objects :</p><p>- 1 Player projectile<br />- 1 Ennemies <br />- 1 Ennemy projectile</p><p>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br />Problem 1 : Brutal frame drop when player is shooting fast<br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br /><span class="postimg"><img src="https://dl.dropboxusercontent.com/u/19970067/Questions/Fev_playershots.jpg" alt="PunBB bbcode test" /></span></p><p>see the player shots ? i believe all single projectiles are OO items spawned every frames, right ?</p><p>If i&#039;m trying to do this in maratis, the frame rate drop dramatically</p><p>my method :</p><p>one hitbox (just a invisible cube), and one graphic item (the projectile)</p><p>I&#039;m joining the collision cube with the projectile graphic with :</p><p>setParent<br />OR <br />follow behavior</p><p>Both method works and the result is the same for both methods (same frame drop, no differences)</p><p>Note that : </p><p>spawning 1 bullet every frame works ok<br />spawning more than 1 bullet every frame result in hyper frame drop</p><p>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br />Problem 2 : Frame drop when two ennemies of the same type are shooting together<br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</p><p><span class="postimg"><img src="https://dl.dropboxusercontent.com/u/19970067/Questions/FervTank2.jpg" alt="PunBB bbcode test" /></span></p><p>See the &quot;tank&quot; who&#039;s shooting green projectiles ?</p><p>if i&#039;m spawning 1 ennemy like that, it will run ok, if i spawn 2 at the same time,<br />when it starts shooting even if its a very low amount of projectiles (about 10 for each)<br />frame drop occurs. I believe it&#039;s a similiar problem than in problem 1.</p><p>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br />Problem 3 : Progressive frame drop when using &quot;for i=1, #projectileList do&quot; in the ennemy script to check whenever there is a collision between the player projectile and the ennemy<br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</p><p>This one starts to freeze after some time. i would say after 20~ ennemies are spawned.</p><p>I had make sure everything in the ennemy script and bullet script<br />(objects, values, and extra stuff) got deactivated when a collision occurs.</p><p>When removing &quot;for i=1, #projectileList do&quot; from the ennemy script, frame drop is gone, but then i cant make collision between player bullet and ennemy <img src="http://forum.maratis3d.com/img/smilies/hmm.png" width="15" height="15" alt="hmm" /></p><br /><p>So right spawning multiple projectiles very fast makes the game freeze and testing collision between OO projectiles/ennemies make the game freeze <img src="http://forum.maratis3d.com/img/smilies/hmm.png" width="15" height="15" alt="hmm" /></p><p>I don&#039;t know what to do, any ideas ?</p>]]></description>
			<author><![CDATA[dummy@example.com (Vegas)]]></author>
			<pubDate>Thu, 30 Jan 2014 00:17:55 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6285#p6285</guid>
		</item>
	</channel>
</rss>
