Collision callback always returns true!!

joehot200
Posts: 15
Joined: Wed Apr 23, 2014 9:47 am

Re: Collision callback always returns true!!

Post by joehot200 »

Basroil wrote:
joehot200 wrote: However, my hit variable in the code converted to java is always returning true!

Is anyone able to tell me what I am doing wrong and how I can fix it? Thanks.

As a sidenote, the JBullet code is on a server, and not a client.
Well, from that code if there are contact points you are almost guaranteed to have a "hit", and in many cases multiple hits. Contact points can be when surfaces collide, but also when one object is inside another. If the object passes through another object, then things start to get complicated depending on what version you're using. Perhaps you mistakenly put two objects inside one another?

On another note, the checking of classes to each other is kind of iffy, since I'm not sure jBullet returns a class pointer (which can be checked by !=) or a copy of the class (which would make objects 1 and 2 be different even if they describe the same object).
joehot200 wrote: I see no use in wasting time with a new programming language when what I really want to learn is how to make a game and the logic of making one.
1)You can never waste time learning C/C++, it's the reason why java is around in the first place, and the syntax is very similar (with keyword differences). Only major difference is in how stack management and pointers are used, at least for the tests you want to use.
2) The logic of making a game engine is 50% game engine design, 50% solving coding problems in engine design, so logic = learning the language. The logistics of making a game and making a game engine are completely different though, and why you generally see teams of people working on one with input from the other. You don't need to program to learn logistics of game design, but in that case you need to excel at something else, be it story, art, or management.
joehot200 wrote:I strongly dislike your comment about learning math. I dont know the question mainly because I am 14 and have not covered that yet. Criticizing me for lack of knowledge is like criticizing an old person because they are not so familiar with computer technology.
Your software education should begin with math and have math continue throughout. A programmer who doesn't understand math is nothing more than a monkey at a keyboard, banging away hoping he has the right order of letters to make something work. If you don't know something, go to a library and check out a book on it. When I was in middle school I was already doing linear algebraic problems to solve for solutions, even using Bayesian algorithms (unintentionally) while writing simple calculator games (and solvers so I didn't have to do algebra homework). There's plenty of resources now that weren't around in my time, so your age has nothing to do with your ability to learn.

joehot200 wrote:As it happens, it was mainly that george oswell thing which I could not find, because the question was asking about how many books he wrote and the answer was a year.... (unless he wrote almost 2000 books).
Another part of a software engineer's job is to be well rounded and understand the world, not just how to make fuzzy shapes clash together. You really should be familiar with the book, after all, many software companies draw inspiration from it for commercials and tag lines (including apple).
joehot200 wrote:I am looking for a software debugger, but I did not know if this forum was the correct one for it. I have been flamed on other forums for asking that question, even though it is supposedly in the list of questions that I can ask.
I assume you're using Eclipse or NetBeans, both have debugging and profiling built in or available as an extension. It's almost a joke to search for that though, and likely why people attacked. Perhaps you should be asking "what debugger do you recommend?"
joehot200 wrote:But using Bullet does not directly solve my problem, so I am still looking for an answer.
So you've tried C++ code with bullet then? Just before you stated that you would not even try it.
joehot200 wrote:Anyway, I was fed up of bullet, I went for my own collision detection system:
That's not collision detection, that 's overlap detection, and not a very good one at that because you keep casting back to integers at each step... Which means your x distances will be zero between about -60 degrees and +60 degrees! What you should do instead is subtract the ball and player positions and test against a threshold that is equal to the player radius in the direction of the ball and the radius of the ball (using absolute values of course), then if necessary convert to integers for display. Integer only collisions won't work in bullet with expected results, since it was made with floating point math in mind.
joehot200 wrote:I have a lot of useful code in java that I dont want to lose by switching to C++. Currently, I am using LWJGL and JBullet which if I ever switch to C++ can make me go to OpenGL and Bullet.
Why are you using a game client package for the server? A server program should have no graphics or input of it's own, it should simply be a way of connecting clients in a meaningful way (that's not to say a server instance can't also have a client program running for things like live video feeds). You do NOT need ogl to use bullet, and indeed it runs far faster without it. What you might need is a UDP or TCP/IP framework to communicate with your clients, but those are available at github, sourceforge, etc.
I wrote many of that quite a long time ago, and I do not still have all of those opinions. Mainly about me going to C++, which I do not have an issue with any more.

Software debugger was a stupid question. I have since learned to use the Eclipse debugger.

Not casting to integers with the collision detection would leave a ton of errors. In the end, then it would effectively be cast to Integers anyway because the map heights @ locations are made of integers.

I do not use LWJGL with my server any more. I used to try rendering some graphics there for some stupid reason. Other than that, then yes the server is simply passing info to the clients.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Collision callback always returns true!!

Post by Basroil »

joehot200 wrote: I wrote many of that quite a long time ago, and I do not still have all of those opinions. Mainly about me going to C++, which I do not have an issue with any more.
It's good to see things have changed in 2 months.
joehot200 wrote:Not casting to integers with the collision detection would leave a ton of errors. In the end, then it would effectively be cast to Integers anyway because the map heights @ locations are made of integers.
Bullet works with floats (both 32bit and 64bit ones), and collisions work just fine. If integers were "solving errors" you have far more serious issues in your program. As for integer map heights, why? I doubt you use all 32bits unless you have the resolution of a millimeter and have distances bigger than the distance between florida and new york! However, my issue wasn't with your use of integers for distance, rather for angles. Radian angles are represented in floating point having a number between 0 and 2 Pi (about 6.3), which means your angle solver gives you 6 directions rather than the 4 or 8 needed for minimal integer movement (cardinals or cardinal+diagonal), which means if you go right and left you can't go up or down properly!. Angles should always be represented as floating point if you use radian, and is highly recommended for degrees (though you can sometimes get away with it just fine in degrees)
Post Reply