🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #1427

Re: Need hard core help doing some 3d optimizations

#1427
From: Ian Kemmish
Date: Sat, 13 Apr 1991 15:41
47 lines
2484 bytes
2fmlcalls@kuhub.cc.ukans.edu writes:

>> I just ran Turbo Profiler on some code of mine, and it looks like roughly
>> 90% of my CPU time is being shoved into one function.  Any help on the
>> optimizations would be really appreciated.

>snip

>> float xa, ya, za;

>snip

>> AngPerspFactor is a float, as are the assorted factors.  I have already
>> used a COS and SIN lookup table in another part of the module to expedite
>> things, but this is really slowing things down considerably.
>> 
>> Any help is appreciated.
>> 
>> Brian

>I don't fully follow C, but I know float.  Go with scaled integers or longs and
>use integer division.  As well, use scaled integers for your sin/co look=up
>tables (i.e. sin(45 degrees) = 707 rather than 0.707).  When you are through
>multiplying, do a div 1000 (or C equivalent of integer division).

>General optimizations - use fewer points.  If you get creative you may find you
>can represent your planes/tanks/whatnots with less points (and thus fewer lines
>to draw as well).

>john calhoun

But don't get rid of floats completely.  If you can, parameterise the
decision to use floats or scaled ints in a config file.  On mips
systems, and with luck the civilised habit will spread, doing
arithmetic in floats os considerably faster than doing it in
integers (assuming its not something simple like a long run
of adds and subtracts with just a couple of token multiplies and
divides thrown in), which in turn is faster than arithmetic using
shorts.  Scaled integers and shorts are slower, again.  I recently
saw a preliminary copy of the JPEG sample implementation, and
it suffered from this ``integer-centrism''....

-- 
Ian D. Kemmish                    Tel. +44 767 601 361
18 Durham Close                   uad1077@dircon.UUCP
Biggleswade                       ukc!dircon!uad1077
Beds SG18 8HZ United Kingdom    uad1077@dircon.co.uk
Technical Details
Message-ID: <1991Apr13.154112.11345@dircon.co.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!slxsys!dircon!uad1077
References: <27979@uflorida.cis.ufl.EDU> <1991Apr11.202429.29648@kuhub.cc.ukans.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!slxsys!dircon!uad1077
From: uad1077@dircon.co.uk (Ian Kemmish)
Newsgroups: rec.games.programmer,comp.os.msdos.programmer,comp.graphics
Subject: Re: Need hard core help doing some 3d optimizations
Message-ID: <1991Apr13.154112.11345@dircon.co.uk>
Date: 13 Apr 91 15:41:12 GMT
References: <27979@uflorida.cis.ufl.EDU> <1991Apr11.202429.29648@kuhub.cc.ukans.edu>
Organization: The Direct Connection, UK
Lines: 47