Randomness in bullet?

Post Reply
jpmunic
Posts: 2
Joined: Sun Jul 19, 2015 4:12 am

Randomness in bullet?

Post by jpmunic »

I have a simulation that drops fruits from a tree and checks if the fruits hit a branch or the ground first (or one of the rods on a simulated fruit picker machine). If I run the simulation multiple times, I get different results. For example, maybe the first two times I run it I'll get 11% of the fruits colliding with a branch, then all the times after that I get 9%. I can't find any uninitialized variables that might account for the inconstancy, and there's no random number generation. Is there any inherent randomness in bullet physics?

I'm detecting collisions like this:

Code: Select all

bool callbackFunc(btManifoldPoint& cp,const btCollisionObjectWrapper* obj1,int id1,int index1,const btCollisionObjectWrapper* obj2,int id2,int index2)
{
        int num1,num2; //num 1 is id 1, num 2 is id 2
        num1=((bulletObject*)obj1->getCollisionObject()->getUserPointer())->id;
        num2=((bulletObject*)obj2->getCollisionObject()->getUserPointer())->id;
        //collision check for rod
        if ((num1==3 || num2==3) && ((bulletObject*)obj2->getCollisionObject()->getUserPointer())->hitbranch==false)
        {
                ((bulletObject*)obj1->getCollisionObject()->getUserPointer())->hitrod=true;
                ((bulletObject*)obj2->getCollisionObject()->getUserPointer())->hitrod=true;
        }
        //collision check for branch
        if ((num1==2 || num2==2) && ((bulletObject*)obj2->getCollisionObject()->getUserPointer())->hitrod==false)
        {
                ((bulletObject*)obj1->getCollisionObject()->getUserPointer())->hitbranch=true;
                ((bulletObject*)obj2->getCollisionObject()->getUserPointer())->hitbranch=true;
        }
        return false;
}
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Randomness in bullet?

Post by Basroil »

Is this an offline simulation or is it connected to the GUI? If it's connected to the GUI, there might be some variability from that?
jpmunic
Posts: 2
Joined: Sun Jul 19, 2015 4:12 am

Re: Randomness in bullet?

Post by jpmunic »

It's offline. There's no GUI, it's all just code and simple rendering.
Post Reply