[project1dev] Re: Project1 - SVN Update 837

  • From: Alan Wolfe <alan.wolfe@xxxxxxxxx>
  • To: project1dev@xxxxxxxxxxxxx
  • Date: Sun, 11 Jul 2010 15:42:42 -0700

thanks for sending that!

Looking at your profiler, i see the same thing i see on my own machine.

rendering is by far the biggest CPU hog right now (and gpu)

i need to rework how our rendering works because i dont think it should be
taking anywhere this long with the little amount of geometry and simple
shaders we have.

its on the todo list, i gotta see if i can find a book on doing it better or
something :P

On Sun, Jul 11, 2010 at 2:03 PM, Kent Petersen <kentkmp@xxxxxxxxx> wrote:

> Nice man. Interesting stuff. Makes a lot of sense to do it the 2nd way. The
> fps didn't change much for me. I now run between 17 and 27 fps with the town
> being built. I didn't wait or full completion of town construction. I
> attached my profiler.
>
>
> On Sun, Jul 11, 2010 at 10:39 AM, Apache User <
> dhapache@xxxxxxxxxxxxxxxxxxx> wrote:
>
>> User:atrix256
>>
>> Message: Optimization - saves about 2-3 ms when town was fully built (:
>>
>> [Technical info below - figured you would be interested Kent!]
>>
>> This is something i learned not that long about but basically there's 2
>> main ways you can handle state changes (ie going from living to dead for
>> example)
>>
>> 1) You can have a tick function where every frame you look at the HP of
>> something, and if it's < 0 you make it die.
>> OR
>> 2) You can make a function that you call whenever you do damage to it, and
>> only have it check if the object is dead then.
>>
>> The first method is called POLLING and means that every frame you poll
>> (ask) if the object should be dead.
>>
>> That wastes cpu because most of the time, the object isn't dead but you
>> are asking every frame.
>>
>> The second method is alot more efficient because it only asks when HP
>> changes.
>>
>> Anyhow, I noticed mob ticks were taking about 4ms per frame when the town
>> was completely built, due to all the houses checking if they were dead or
>> not.
>>
>> So what i did was instead of making mobs change the life property on a
>> building model, i made them send the building model a message of
>> "Hut_Do_Damage" with a value of 2 (how much damage it did).
>>
>> Then, in the mob, i made the damage and death check happen in response to
>> the message only (not in the tick).
>>
>> Also, since that was the only thing the tick function was doing, i removed
>> it from Hut1x1 and Hut2x2 so they didn't have a tick function.  Then i made
>> the game make it so if a mob doesn't have a tick function, not to even
>> bother caling tick every frame, which further optimized the code not having
>> to interface with lua each frame for each building.
>>
>> So yeah, in the end all this stuff saved about 2-3 miliseconds going on my
>> machine from an average of 24ms when the town was fully built down to an
>> average of 21ms when the town was fully built.
>>
>> On my machine that took me from 41fps avg up to 47fps.
>>
>> <Files Changed>
>> U   ActRaiser/ARRelease.exe
>> U   ActRaiser/Scripts/Enemies/OverWorld/Troll.lua
>> U   ActRaiser/Scripts/GameOverworld/Hut1x1.lua
>> U   ActRaiser/Scripts/GameOverworld/Hut2x2.lua
>> U   Code/ARRelease.exe
>> U   Code/AR_Mobile.cpp
>> U   Code/AR_Mobile.h
>>
>>
>> ==============================
>> Project 1 Dev mailing list
>> to unsubscribe, please send an email request to demofox@xxxxxxxxxxx
>> Project 1 website: http://project1.demofox.org
>> Project 1 SVN repository: http://pyotek.com/project1
>>
>
>

Other related posts: