Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Paniolo
Oct 9, 2007

Heads will roll.

haveblue posted:

This is a horrible, horrible naming convention (unless you just pulled it out of your rear end for this example).

No that's actually what Source is like. What can you do, some people like the smell of skunks. Though the lack of a toolchain from this century is a bigger problem with Source than the naming conventions (of which it has at least half a dozen in use, since there's code in there dating back to the original Quake.)

Adbot
ADBOT LOVES YOU

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Since we're on the subject of source, I think I should just point out that this is taken from their Alien Swarm SDK, and in my opinion, cements the idea that no one should be using Source at this moment in time.



I believe it continues on like this until about SCRIPT_BINDING_ARGS_20 (or was it thirty?).

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

nibe posted:

I find myself endlessly fretting over what objects should have access to what other objects. I've got the notion in my head that less = better, but I'm not sure whether or why that is true beyond simplicity's sake. For example, I have a Unit class that represents humanoid objects that can move around. Right now the class only has information about that unit (name, position, HP, etc.) with no access to other game subsystems. But suppose I want a Unit to follow a moving target. In the Unit's update method I have to find a path to the target, which is a call to a function in the AI class.
Although it's really hard to tell without seeing your code structure, one thing that springs to mind is that you could pull the unit's 'position' information into a separate class, say Position. This should be an interface ideally, where the exposed methods are nothing but getters and setters for the raw coordinates.

After this, make a PositionController class which will have a reference to a Position object, and nothing else. Inside an implementation of PositionController, you'll be updating positions and nothing more.

As for where the currently active PositionControllers live, I don't know, you might want to create a list of them to be managed externally from your units. Or maybe you never want two to 'compete' with eachother, in which case each Unit would always have exactly one PositionController at all times.

Staggy
Mar 20, 2008

Said little bitch, you can't fuck with me if you wanted to
These expensive
These is red bottoms
These is bloody shoes


Bakkon posted:

Ah, I see. Sorry there, I misinterpreted your original problem. I thought you wanted point of impact so you could do rotational calculations for physics, because that's what I was using it for. You're just looking for the minimal overlap so you can remove interpenetration, correct? SAT alone can find the projection vector to do that. (Referencing the stuff seen here: http://www.metanetsoftware.com/technique/tutorialA.html) The direction is the axis of minimum overlap and the distance is the difference of the two projections.

Ah, thank you so much. I've actually got that working now, and I've got detecting which edge of a box (top/bottom/left/right) was involved in the collision almost working - I should definitely get that done by tomorrow.
Half the problem I have in cases like this is not knowing the right term to google.

SAHChandler posted:

Since we're on the subject of source, I think I should just point out that this is taken from their Alien Swarm SDK, and in my opinion, cements the idea that no one should be using Source at this moment in time.



I believe it continues on like this until about SCRIPT_BINDING_ARGS_20 (or was it thirty?).

Call it morbid curiosity, but couldn't you do:
code:
#define SCRIPT_BINDING_ARGS_0
#define SCRIPT_BINDING_ARGS_1 pArguments[0]
#define SCRIPT_BINDING_ARGS_2 SCRIPT_BINDING_ARG_1, pArguments[1]
#define SCRIPT_BINDING_ARGS_3 SCRIPT_BINDING_ARG_2, pArguments[2]
It's still horrible, but wouldn't that make things at least slightly easier to type/read?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Paniolo posted:

No that's actually what Source is like. What can you do, some people like the smell of skunks. Though the lack of a toolchain from this century is a bigger problem with Source than the naming conventions (of which it has at least half a dozen in use, since there's code in there dating back to the original Quake.)
What people forget in this is that COD4/MW2 are essentially Quake 3 derivatives. However, they've been reworked to the point that they're barely recognizable, there are numerous signs that the map compilers for instance might be near-total rewrites of the originals.

Using BSP for scene management isn't really the worst decision in the world below certain level sizes and Source supports an occluder-based visibility system anyway starting with Episode 2. Using it for geometry isn't a huge deal because it still supports arbitrary meshes for collision and geometry.

So those aren't really the worst problems. The worst are that it's completely cobbled together from middleware, the gamecode API is still bogged down in legacy cruft, and the tool chain still relies extremely heavily on loving around with text files. Absolutely everything about it screams "this was bolted on to existing technology," and in this case the existing technology dates back as far as 1996.

Also those script defines aren't really that shocking, Doom 3 has even more obnoxious defines in its API. It's just what you get from C++ not having tuples or a good stack-based allocation mechanism.

OneEightHundred fucked around with this message at 06:15 on Dec 7, 2010

Inverness
Feb 4, 2009

Fully configurable personal assistant.

haveblue posted:

As I understand it Unreal works at the level of individual variables. Object instances are identical on the server and all clients (with the server authoritative) and certain members are tagged as replicated, which causes them to be asynchronously kept up to date with the values of their remote equivalents. You can request different priorities, interpolation types, etc for each of them. The core network layer marshals all the pending updates into bundles, invisibly.
This is correct. I really like how Unreal enables you to create conditions for replicating certain variables rather than just doing a blanket approach. After doing some looking, I was able to find some C++ code from UT2k4's Onslaught package (which isn't leaked) that demonstrates how they implement this in their code. Source: http://koders.com/cpp/fid212DA5370827D1C04D75E7B668BCD4FF3BACC209.aspx

Just from looking at that I was able to figure out how it was working and create almost identical functionality for my own game, and it took much less time than I thought. Even better, I was able to easily integrate it with RakNet's Replica Manager plugin. At first I wondered if I was maybe overdoing it a bit, but making it has been an interesting experience, and the code is open source if anyone wants to take a look or use it themselves.

Vino
Aug 11, 2010

haveblue posted:

This is a horrible, horrible naming convention (unless you just pulled it out of your rear end for this example).

That's actually not hardly the worst part about Source and to be truthful I don't mind it at all. It's clear and easy and I never got a server/client class confused. The difference between C and C_ is the first thing you learn (and I think I learned it by just looking at code) so there's no real problem there. I'd much prefer that shorthand to CClientWeapon and CServerWeapon, all that typing would make me dizzy.


Also your description of Unreal's net code sounds basically like the way Source does it, except that the code that Inverness just linked looks pretty obtuse compared to how Source does it:

code:
BEGIN_NETWORK_TABLE( CCFBaseMeleeWeapon, DT_CFBaseMeleeWeapon )
#ifdef CLIENT_DLL
	RecvPropInt( RECVINFO( m_iAttack ) ),
	RecvPropBool( RECVINFO( m_bStrongAttack ) ),
	RecvPropTime( RECVINFO( m_flLastAttackTime ) ),
	RecvPropTime( RECVINFO( m_flChargeStartTime ) ),
	RecvPropTime( RECVINFO( m_flSwingTime ) ),
	RecvPropBool( RECVINFO( m_bCharging ) ),
	RecvPropBool( RECVINFO( m_bAfflictive ) ),
	RecvPropInt( RECVINFO( m_eAttackElement ) ),
#else
	SendPropInt( SENDINFO( m_iAttack ), 4 ),
	SendPropBool( SENDINFO( m_bStrongAttack ) ),
	SendPropTime( SENDINFO( m_flLastAttackTime ) ),
	SendPropTime( SENDINFO( m_flChargeStartTime ) ),
	SendPropTime( SENDINFO( m_flSwingTime ) ),
	SendPropBool( SENDINFO( m_bCharging ) ),
	SendPropBool( SENDINFO( m_bAfflictive ) ),
	SendPropInt( SENDINFO( m_eAttackElement ), TOTAL_ELEMENTS ),
#endif
END_NETWORK_TABLE()
Pretty fuckin easy. In fact I don't know why those weren't ever grouped into a single #define:

code:
#ifdef CLIENT_DLL
#define NETWORKPROP(name) \
RecvPropBool( RECVINFO( name ) ),
#else
#define NETWORKPROP(name) \
SendPropBool( SENDINFO( name ) ),
#endif
That'd have made it even easier. At this point, Source parses those tables and ensures that all of those properties from that class (a melee weapon) are kept up to date on the client. You can use special functions to modify the number of bits used, the network priority, specify a callback on the client when it's updated, or whatever else you want and everything is kept in neat little tables. That Unreal code didn't look nearly as legible. What the hell is NEQ and GetOptimizedReqList() ?

I think I've said before that of all the things wrong with Source, I actually like their net code, I don't think that's one of them.

Staggy
Mar 20, 2008

Said little bitch, you can't fuck with me if you wanted to
These expensive
These is red bottoms
These is bloody shoes



:psyboom: How is this a collision? It boggles the mind.
Source.
It works fine until both boxes are rotated roughly that amount; I just can't understand it.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Vino posted:

That Unreal code didn't look nearly as legible. What the hell is NEQ and GetOptimizedReqList() ?
NEQ means not-equal, its a function used to compare the current value and the value recently sent over the network.

GetOptimizedRepList() ("get optimized replication list") is the function that is called in order to figure out which variables need to be replicated based on a set of conditions and whether or not their values have changed. The 'Recent' argument is a pointer to a copy of the object which is casted so that the current value can be compared with the recently sent value. 'Ptr' is a pointer to an array used to store indices. If a variable needs to be replicated, then its unique index is added to the array and the pointer position is advanced by one. DOREP is the macro that does all that.

If you're familiar with the replication statements in UnrealScript, GetOptimizedRepList() is the C++ version of that. It's called optimized because it is much faster than the UnrealScript equivalent.

Overall I think it is a really nice way to do things. It's very flexible.

The code you posted from Source doesn't look like it has the same purpose as that.

Inverness fucked around with this message at 17:27 on Dec 7, 2010

Beef
Jul 26, 2004

Staggy posted:


:psyboom: How is this a collision? It boggles the mind.
Source.
It works fine until both boxes are rotated roughly that amount; I just can't understand it.

First thing I noticed is that you can avoid all those sqrt operations. You can just keep comparing the power 2 distances. At the moment that early culling is more expensive than a straight axis-aligned BB check.

Without looking too much at your code, are you only comparing the axis-aligned BB? This is one of the cases where they overlap while the original vertices don't.

Staggy
Mar 20, 2008

Said little bitch, you can't fuck with me if you wanted to
These expensive
These is red bottoms
These is bloody shoes


Beef posted:

First thing I noticed is that you can avoid all those sqrt operations. You can just keep comparing the power 2 distances. At the moment that early culling is more expensive than a straight axis-aligned BB check.

Without looking too much at your code, are you only comparing the axis-aligned BB? This is one of the cases where they overlap while the original vertices don't.

Well, I figured it out got lucky.

I was comparing the rotated BBs. In fact, my code for generating the projection axis for each box was:
code:
Point( cos( A1 ) , sin( A1 ) );
Point( -sin( A1 ) , cos( A1 ) );
A1 was the angle of rotation for the box. However your comment made it clear that this was probably a problem with the angle. I poked around a bit, and on a whim I decided to try using -A1 instead.
It works perfectly now. Thank you.

HiriseSoftware
Dec 3, 2004

Two tips for the wise:
1. Buy an AK-97 assault rifle.
2. If there's someone hanging around your neighborhood you don't know, shoot him.

Beef posted:

First thing I noticed is that you can avoid all those sqrt operations. You can just keep comparing the power 2 distances. At the moment that early culling is more expensive than a straight axis-aligned BB check.

Without looking too much at your code, are you only comparing the axis-aligned BB? This is one of the cases where they overlap while the original vertices don't.

If you're ever really in the need to perform square-root and inverse-square-root operations, look no further than John Carmack's fast inverse square root:

code:
// Fast Inverse Square Root - From Quake III source code
// [url]http://en.wikipedia.org/wiki/Fast_inverse_square_root[/url]

float Q_rsqrt( float number )
{
	long i;
	float x2, y;
	const float threehalfs = 1.5F;
 
	x2 = number * 0.5F;
	y  = number;
	i  = * ( long * ) &y;                       // evil floating point bit level hacking
	i  = 0x5f3759df - ( i >> 1 );               // what the gently caress?
	y  = * ( float * ) &i;
	y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//	y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed
 
	return y;
}

// Fast Square Root - From [url]http://www.codemaestro.com/reviews/9[/url]

float SquareRootFloat(float number) {
    long i;
    float x, y;
    const float f = 1.5F;

    x = number * 0.5F;
    y  = number;
    i  = * ( long * ) &y;
    i  = 0x5f3759df - ( i >> 1 );
    y  = * ( float * ) &i;
    y  = y * ( f - ( x * y * y ) );
    y  = y * ( f - ( x * y * y ) );
    return number * y;
}
Apparently not invented by Carmack from what I read, but he probably made it famous. Know them, use them, love them!

Beef
Jul 26, 2004

HiriseSoftware posted:

If you're ever really in the need to perform square-root and inverse-square-root operations, look no further than John Carmack's fast inverse square root:


Cool hack in the day, but please don't do it this way these days :)
Floating point operations these days aren't as slow as they they were back in the day, so you could do it more straight-forward instead of trying to hack it into the integer data-path.

edit: Most processor do it in hardware now anyway.

HiriseSoftware
Dec 3, 2004

Two tips for the wise:
1. Buy an AK-97 assault rifle.
2. If there's someone hanging around your neighborhood you don't know, shoot him.

Beef posted:

Cool hack in the day, but please don't do it this way these days :)
Floating point operations these days aren't as slow as they they were back in the day, so you could do it more straight-forward instead of trying to hack it into the integer data-path.

edit: Most processor do it in hardware now anyway.

As an iPhone game programmer, I like to squeeze as much performance out of the devices as I can get! I would assume what you're saying is true generally though... I've just had this fast square root code in my projects for a while and thought I'd share.

Here is something about these fast functions and the iPhone:

http://iphonedevelopment.blogspot.com/2009/03/speed-with-catch.html

haveblue
Aug 15, 2005



Toilet Rascal
That article was written in early 2009 and the Cortex A8 (3GS/4/iPad) supports hardware square root, so I don't think it applies any more.

HiriseSoftware
Dec 3, 2004

Two tips for the wise:
1. Buy an AK-97 assault rifle.
2. If there's someone hanging around your neighborhood you don't know, shoot him.

haveblue posted:

That article was written in early 2009 and the Cortex A8 (3GS/4/iPad) supports hardware square root, so I don't think it applies any more.

Hmm ok I'll add some #defines in my code to use either the fast version or the sqrtf version depending on the architecture.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

HiriseSoftware posted:

Hmm ok I'll add some #defines in my code to use either the fast version or the sqrtf version depending on the architecture.

Just as a heads up, be careful with introducing conditional compilation to a program or library, it can be easy to fall off the cliff if you do it overmuch

Vino
Aug 11, 2010
I'd like to find the right markup language for my level files. It'll have information like the name of the level, whatever props are scattered around the level and in what locations, and references to external resources like images and whatever else is needed to load the level, so the game can load the markup to display the metadata to the user but avoid actually loading the assets until later.

I would rather not use XML which I view as too cumbersome for my needs. Something like YAML would be nice but YAML strikes me has having a strict and sometimes confusing syntax that I think artists might not enjoy much. I want an artist to be able to mess with it. Something like Valve's KeyValue system would work great. Is there any other option or should I just roll my own?

haveblue
Aug 15, 2005



Toilet Rascal
JSON?

Vino
Aug 11, 2010
Okay yeah I totally slept on JSON because it looked like it relied on Javascript but now I see it doesn't. It may work for me, thanks.

haveblue
Aug 15, 2005



Toilet Rascal
It's only called that because it was invented for AJAX serialization, it's a generic heirachic key-value format and you can find parsers for just about anything.

LOLLERZ
Dec 9, 2003
ASK ME ABOUT SPAMMING THE REPORT FORUM TO PROTECT ~MY WIFE'S~ OKCUPID PERSONALS ANALYSIS SA-MART THREAD. DO IT. ALL THE TIME. CONSTANTLY. IF SHE DOESN'T HAVE THE THREAD, SHE'LL WANT TO TALK TO ME!

Vino posted:

I'd like to find the right markup language for my level files. It'll have information like the name of the level, whatever props are scattered around the level and in what locations, and references to external resources like images and whatever else is needed to load the level, so the game can load the markup to display the metadata to the user but avoid actually loading the assets until later.

I would rather not use XML which I view as too cumbersome for my needs. Something like YAML would be nice but YAML strikes me has having a strict and sometimes confusing syntax that I think artists might not enjoy much. I want an artist to be able to mess with it. Something like Valve's KeyValue system would work great. Is there any other option or should I just roll my own?
Depending on your language, you could probably just use some serialization thing. If you write your tools in the same language as your game, you'll never have to care about file formats.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...
If you're looking at JSON, you might as well try YAML in my opinion.

Vino
Aug 11, 2010

LOLLERZ posted:

Depending on your language, you could probably just use some serialization thing. If you write your tools in the same language as your game, you'll never have to care about file formats.

Some serialization thing...? My game's in C++, and I'm not sure what you mean.

edit: Honestly I'm thinking of rolling my own. Since JSON is basically Javascript arrays it has a number of syntactical requirements that I was hoping to avoid. Artist forgets a comma and now it's an adventure to figure out why his stuff isn't showing up.

Vino fucked around with this message at 04:28 on Dec 10, 2010

cronio
Feb 15, 2002
Drifter

Vino posted:

Some serialization thing...? My game's in C++, and I'm not sure what you mean.

edit: Honestly I'm thinking of rolling my own. Since JSON is basically Javascript arrays it has a number of syntactical requirements that I was hoping to avoid. Artist forgets a comma and now it's an adventure to figure out why his stuff isn't showing up.

Instead of taking the time to roll your own format, why not write an editor? Your artists will always get something wrong if they're hand-editing config files.

h_double
Jul 27, 2001

cronio posted:

Instead of taking the time to roll your own format, why not write an editor? Your artists will always get something wrong if they're hand-editing config files.

Or else there are powerful general purpose editors like DAME, which allow you to script your own output format.

Vino
Aug 11, 2010

cronio posted:

Instead of taking the time to roll your own format, why not write an editor? Your artists will always get something wrong if they're hand-editing config files.

Your sarcasm is not lost on me. It took me all of an hour or two to cobble together a nice simple parser, no big deal. It'd probably have taken me as long to plug some library into my app.

edit: DAME sounds neat, link?

h_double
Jul 27, 2001

Vino posted:

Your sarcasm is not lost on me. It took me all of an hour or two to cobble together a nice simple parser, no big deal. It'd probably have taken me as long to plug some library into my app.

edit: DAME sounds neat, link?

http://dambots.com/dame-editor/


http://www.mapeditor.org/ is another one that looks good but I've not tried it myself.

Vino
Aug 11, 2010
Oh I thought he meant a text editor, maybe there was no sarcasm after all.

I'm avoiding writing an editor because that's much harder and I want to get my game done this year. Or I guess this year is almost over so maybe next year, point is I try to cut out unnecessary work. Also my game's not tile based so I can't really use another level editor.

Beef
Jul 26, 2004
In general, if you want to optimize: MEASURE, MEASURE and MEASURE
Common sense doesn't work anymore when squeezed through a language runtime, an OS runtime, a multi-stage optimizing compiler, virtual machine, tracing-JIT, complicated cache hierarchy, instruction-level parallelism, ...


On text format: How about s-expressions :p

h_double
Jul 27, 2001
If you wanted, say, a web form that spits out neatly-formatted XML/JSON data structures with input validation and sanity checks, you could build it in about ten minutes in a framework like Rails (it'd have the side benefit your data would already be in a Sqlite3 or MySql database so you could get at it that way, or massage the data further after the fact).

h_double fucked around with this message at 15:03 on Dec 10, 2010

cronio
Feb 15, 2002
Drifter

Vino posted:

Oh I thought he meant a text editor, maybe there was no sarcasm after all.

I'm avoiding writing an editor because that's much harder and I want to get my game done this year. Or I guess this year is almost over so maybe next year, point is I try to cut out unnecessary work. Also my game's not tile based so I can't really use another level editor.

Depending on how much data you want your artists to produce it may take more of your time debugging their data than writing the editor would have. Unless they're very technical, they will get it wrong, and often. If it's a simple enough format that you can write it in a text editor, it's simple enough that a real editor (even if it's simple) shouldn't take more than a few days to write -- and will guarantee no bad data. It will also let you change the format if you need to.

Vino
Aug 11, 2010
I understand that. My artists are fairly technical and the amount of data is not terribly great, so I'm making a calculated tradeoff. At some point I may make an editor but for now we're just prototyping.

Surface
May 5, 2007
<3 boomstick

Vino posted:

I understand that. My artists are fairly technical and the amount of data is not terribly great, so I'm making a calculated tradeoff. At some point I may make an editor but for now we're just prototyping.

Just throw something together, I made my tower defense level editor while protesting the 4loko ban with 4loko. The best part of it was it didn't matter how horrible the code was because it just needed to be a simple tool.

LOLLERZ
Dec 9, 2003
ASK ME ABOUT SPAMMING THE REPORT FORUM TO PROTECT ~MY WIFE'S~ OKCUPID PERSONALS ANALYSIS SA-MART THREAD. DO IT. ALL THE TIME. CONSTANTLY. IF SHE DOESN'T HAVE THE THREAD, SHE'LL WANT TO TALK TO ME!

Vino posted:

Some serialization thing...? My game's in C++, and I'm not sure what you mean.

edit: Honestly I'm thinking of rolling my own. Since JSON is basically Javascript arrays it has a number of syntactical requirements that I was hoping to avoid. Artist forgets a comma and now it's an adventure to figure out why his stuff isn't showing up.

pickle, serialize, toJSON, freeze, whatever

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
Is anyone doing any non-comedy-option HTML5 game development? I'd like to build a simple retro-styled platform-game for promotion purposes and while I could do it with in Flash (e.g. with FlashDevelop + PushButton or whatever), I don't want to exclude any devices that don't support Flash.

I've seen a few decent attempts at building something in HTML5 (the nicest one being Biolab Disaster) but I was wondering if any goons have done something similar.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Sagacity posted:

I don't want to exclude any devices that don't support Flash.
Isn't that pretty much just iPhones anyway? And the Biolab Disaster page says it doesn't work adequately on iPhones. So you might as well just use Flash.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

roomforthetuna posted:

Isn't that pretty much just iPhones anyway?
Well, yes, but that's a target audience I don't want to ignore :)

An alternative would be to build something using Unity, but then the online crowd probably won't want to play it, since just about nobody has the Unity web player installed (or do they?)

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Sagacity posted:

Well, yes, but that's a target audience I don't want to ignore :)
Which is why I went on to say that your plan to use HTML5 seemingly ignores iPhones anyway so is a silly idea.

(Hasn't someone made a Flash compiler that makes an iPhone app out of a Flash thing? Won't be in a webpage but will be supporting iPhone, if you can do it that way.)

Adbot
ADBOT LOVES YOU

iopred
Aug 14, 2005

Heli Attack!

roomforthetuna posted:

(Hasn't someone made a Flash compiler that makes an iPhone app out of a Flash thing? Won't be in a webpage but will be supporting iPhone, if you can do it that way.)

Yeah Adobe did. You can package a project to iPhone in CS5.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply