[QUOTE=Anonim;30606584]Maybe. It certainly adds a lot of precision, but it still has the same inaccuracies. Roughly, using an estimated calculation with WolframAlpha, I get 0.09999999999990905052982270717620849609375, which is a relative error of about 9.09e-11 %. So definitely an improvement.
There should've been hexadecatuple-precision floating points. That'd solve most precision issues. :saddowns:[/QUOTE]
I actually can't do that due to the way my game engine is designed. SFML uses floats, and I have to use floats.
Any idea how can I solve the problem? It's driving me crazy :(
Here's a video of the bug
[media]http://www.youtube.com/watch?v=bRynch1EtnE[/media]
[QUOTE=SupahVee;30606391]I do not understand where I have to make that check. In the AABB intersection check?[/QUOTE]
Whenever checking for equality or inequality you have to include the epsilon.
[editline]21st June 2011[/editline]
Well possibly not inequality (greater than, smaller than)
[editline]21st June 2011[/editline]
[url]http://stackoverflow.com/questions/3874627/floating-point-comparison-functions-for-c[/url]
Seems to have a comparison function
Well, you could just convert the fixed-point values to floating-point.
Or - as suggested a bunch of times - just allow a slight variation:
[csharp] const static float variation = Single.Epsilon * 10; //increase the multiplier if it still is jerky
if (mCornerMax1.X + variation <= mCornerMin2.X || mCornerMin1.X >= mCornerMax2.X + variation)
return false;
...[/csharp]
[QUOTE=SupahVee;30606658]I actually can't do that due to the way my game engine is designed. SFML uses floats, and I have to use floats.
Any idea how can I solve the problem? It's driving me crazy :(
Here's a video of the bug
[media]http://www.youtube.com/watch?v=bRynch1EtnE[/media][/QUOTE]
Yeah, I see the issue.
The only quick solution I can think of would be filling it with checks.
[i]Use those [img]http://latex.codecogs.com/gif.download?%5Chuge&space;%5Cdpi{300}&space;%5Cbg_white&space;%5Cvarepsilon[/img]s![/i]
Someone suggested not using pixels as world unit size. What do you think?
I tend to use integers whenever possible. If I could, I'd flood that shit with 64-bit integers (or use BigNum, or write my own n-bit integer structs with accompanying functions). It might be a bit slower and harder to set up, but generally solves any inconsistencies you get with floats.
Of course, ints overflow faster than floats, but that's a limitation one can adapt to.
Bignums are fancy.
[editline]21st June 2011[/editline]
[QUOTE=SupahVee;30606855]Someone suggested not using pixels as world unit size. What do you think?[/QUOTE]
You should probably abstract world units anyway.
[editline]21st June 2011[/editline]
Pixels are perfectly valid if you're only using integer units, though.
I tried multiplying everything to 0.1 when calculating SFML stuff, and dividing everything by 0.1 when calculating physics stuff.
It seems to work.
(why?)
Because when dividing by 0.1 you're multiplying by ten, giving more precision in the first digits? 1 can be expressed correctly in single-precision floats while 0.1 can't.
[editline]21st June 2011[/editline]
Or something.
The calculator probably just calculates how many decimals there should be and rounds the result appropriately?
[editline]21st June 2011[/editline]
Say you want to calculate 1.234*4.56
The first number has 3 decimals and the second only 2, so the result has 2+3=5 decimals, so it gives you the result 5.62704 instead of 5.627039999999999
[QUOTE=SupahVee;30607171]I tried multiplying everything to 0.1 when calculating SFML stuff, and dividing everything by 0.1 when calculating physics stuff.
It seems to work.
(why?)[/QUOTE]
I'm not sure if this is still your problem, but just because SFML uses floats in the background, doesn't mean you have to. What I do is use doubles for everything that requires any sort of decimal precision, and write my own classes to abstract from SFML's stuff. Then, in the background (hidden by those classes you wrote) you can do all the dirty work of casting from double to float for SFML's sake.
[editline]21st June 2011[/editline]
[QUOTE=SupahVee;30603252][url]http://forums.tigsource.com/index.php?topic=20157.0[/url]
second post is the technique I used[/QUOTE]
Most of his code seems sound enough, but:
[code]while !collision(x + sign(xmov), y) x+=sign(xmov);[/code]
That's horrible, especially if xmov could get potentially very large. It'd be much easier to have a collision function that returns X/Y coordinates or penetration values or whatever, any of which you could use to move the object next to the tile instead of inside it.
[QUOTE=Chris220;30607586]
Most of his code seems sound enough, but:
[code]while !collision(x + sign(xmov), y) x+=sign(xmov);[/code]
That's horrible, especially if xmov could get potentially very large. It'd be much easier to have a collision function that returns X/Y coordinates or penetration values or whatever, any of which you could use to move the object next to the tile instead of inside it.[/QUOTE]
Yeah I actually didn't do that and just calculated penetration vector.
However, now that I think about it, if I still kept pixel as world units and wanted to "cheat" on my physics engine, his method would have given me 0 problems (albeit slower).
[editline]21st June 2011[/editline]
[QUOTE=SupahVee;30607171]I tried multiplying everything to 0.1 when calculating SFML stuff, and dividing everything by 0.1 when calculating physics stuff.
It seems to work.
(why?)[/QUOTE]
Fuck it, nevermind. It still gives the same problems. Sigh.
Should I start learning LUA or just learn C++ first?
[QUOTE=cathal6606;30607990]Should I start learning LUA or just learn C++ first?[/QUOTE]
Do both. Lua is a handy scripting language and basic skills in something like that never hurt.
[QUOTE=cathal6606;30607990]Should I start learning LUA or just learn C++ first?[/QUOTE]
You could write a C++ program that embeds Lua and use it to perform various functions which you write in C++.
Like you have the C++ function "parseJSON" which would take one argument: A filename.
Then the function parses the JSON input file, and returns a table.
Fun little things to play around with for learning purposes :)
[QUOTE=T3hGamerDK;30608847]You could write a C++ program that embeds Lua and use it to perform various functions which you write in C++.
Like you have the C++ function "parseJSON" which would take one argument: A filename.
Then the function parses the JSON input file, and returns a table.
Fun little things to play around with for learning purposes :)[/QUOTE]
Hardly something you'd do if you're entirely new to programming, though.
Overcomplicating things for oneself while learning is the best way to get demotivated and quit altogether.
[QUOTE=Anonim;30609327]Hardly something you'd do if you're entirely new to programming, though.
Overcomplicating things for oneself while learning is the best way to get demotivated and quit altogether.[/QUOTE]
Embedding lua is mostly doing -llua<version> and creating a Lua state.
jA_cOp: Yes I know you can't do anything useful like that but for his example (exporting one function into Lua) it's not all that difficult. :v:
[QUOTE=SupahVee;30606658]Here's a video of the bug
[media]http://www.youtube.com/watch?v=bRynch1EtnE[/media][/QUOTE]
Watching this video is like playing my own game, we have the same bugs ;)
What are some good online resources for learning c# and XNA?
[QUOTE=AntonioR;30609905]Watching this video is like playing my own game, we have the same bugs ;)[/QUOTE]
Me too. It seems these problems are common in platformer games...
I still haven't solved it :(
Anyone has any other idea?
stackoverflow thread [url]http://stackoverflow.com/questions/6422293/floating-point-precision-and-physics-calculations/6422457#6422457[/url]
[QUOTE=Pelf;30610380]What are some good online resources for learning c# and XNA?[/QUOTE]
I've personally learned a lot from
[url]http://www.riemers.net/eng/Tutorials/xnacsharp.php[/url]
There's also loads of samples over at
[url]http://create.msdn.com/en-US/education/catalog/[/url]
This seems like a silly question, but it is possible to create a single triangle strip of half a cube (three adjacent faces)?
I have a triangle strip for a whole cube, but I only need three of the faces.
[QUOTE=noctune9;30616717]This seems like a silly question, but it is possible to create a single triangle strip of half a cube (three adjacent faces)?
I have a triangle strip for a whole cube, but I only need three of the faces.[/QUOTE]
It is, but I can't think of any way to show you how :v:
Edit:
Eh, maybe not then. Ignore meee!
[QUOTE=noctune9;30616717]This seems like a silly question, but it is possible to create a single triangle strip of half a cube (three adjacent faces)?
I have a triangle strip for a whole cube, but I only need three of the faces.[/QUOTE]
I don't think so, but it's possible with a triangle fan.
Can you see anything obviously wrong with this grammar:
[code]... means you may repeat last token
{} groups tokens
| is or
! is not
[] means optional
'x' is character literal
<LN> = ''
<NB> = ' ' | ' '
<ws> = <LN> | <NB>
<word> = !<ws> ...
<string> = {'"' <word> ... '"' | <word>} [<NB>]
<line> = {<string> [<ws>]} ... <LN>
<alchemy> = <project> ...
<project> = <word> ':' <LN> {<target> ...}
<target> = <word> ':' [[<nb>] <dependencies>] <LN> <commands> ...
<commands> = <line> ...
<dependencies> = [<string> [{<NB> <string>} ...]]
[/code]
(Sorry, I didn't bother learning BNF after 1am :v: Might do it later in BNF or some extension thereof)
is it possible to access and change content of a video file in C#?
Ok, Im using threading to carry out the same task lots of times
Anyway When using random numbers in the thread I get the same random number each time in each thread. Is there a easy way to ensure that all the threads get a different random number?
Im using this to get random numbers:
[code]random.Next(50, 214)[/code]
[QUOTE=noctune9;30616717]This seems like a silly question, but it is possible to create a single triangle strip of half a cube (three adjacent faces)?[/QUOTE]
It's possible if you use [url=http://www.opengl.org/wiki/Vertex_Specification#Primitive_Restart]primitive restart[/url] or [url=http://www.gamedev.net/page/resources/_/reference/programming/sweet-snippets/concatenating-triangle-strips-r1871]degenerate triangles[/url], but
[QUOTE=bean_xp;30617369]it's possible with a triangle fan[/QUOTE]
and is simpler and more elegant that way.
Do bools ever return true or false in C++? I always get some random ass number whenever I have it print.
Is there any function similiar to 'tostring' or something of that nature?
Sorry, you need to Log In to post a reply to this thread.