I am trying to test collision with convex polyhedra using the SWIFT library. Here are my two shapes:

cube.poly

Code:
POLY

8

6

-1 -1 -1
1 -1 -1
1 1 -1
-1 1 -1
-1 -1 1
1 -1 1
1 1 1
-1 1 1

4 0 4 7 3
4 1 2 6 5
4 2 3 7 6
4 0 1 5 4
4 4 5 6 7
4 3 2 1 0
pyramid.tri

Code:
TRI

5

6

1 -1 1
1 -1 -1
-1 -1 -1
-1 -1 1
0 1 0

0 1 4
4 1 2
4 2 3
4 3 0
0 3 2
0 2 1
Some code:

Code:
static const char* object1_filename = "cube.poly";
static const char* object2_filename = "pyramid.tri";

static int id1 = 0;
static int id2 = 1;

static SWIFT_Scene* swift_scene;



static void swift_scene_init() {

    swift_scene = new SWIFT_Scene( true, false );


    swift_scene->Add_Object( object1_filename, id1, false,
                        DEFAULT_ORIENTATION, DEFAULT_TRANSLATION, 0.1,
                        DEFAULT_BOX_SETTING, DEFAULT_BOX_ENLARGE_REL, 0.5 )




    swift_scene->Add_Object( object2_filename, id2, false,
                        DEFAULT_ORIENTATION, DEFAULT_TRANSLATION, 0.1,
                        DEFAULT_BOX_SETTING, DEFAULT_BOX_ENLARGE_REL, 0.5 )


    //Set the initial transformations for objects
    R[0] = 1.0; R[1] = 0.0; R[2] = 0.0;
    R[3] = 0.0; R[4] = 1.0; R[5] = 0.0;
    R[6] = 0.0; R[7] = 0.0; R[8] = 1.0;

    T[0] = 0.0; T[1] = 0.0; T[2] = 0.0;
    my_swift_scene.scene->Set_All_Object_Transformations( R, T);
    swift_scene->Activate();
}


static void query() {

    int num_pairs=-1;
    int* oids;
    SWIFT_Real* dists;

    //Set the transformations for objects
    R[0] = 1.0; R[1] = 0.0; R[2] = 0.0;
    R[3] = 0.0; R[4] = 1.0; R[5] = 0.0;
    R[6] = 0.0; R[7] = 0.0; R[8] = 1.0;

    T[0] = 0.0; T[1] = 0.0; T[2] = 0.0;
    my_swift_scene.scene->Set_All_Object_Transformations( R, T);


    bool collision = swift_scene->Query_Exact_Distance(false, SWIFT_INFINITY, num_pairs, &oids, &dists);
    cout<<"\ncollision:"<<collision;

    for( int i = 0; i < num_pairs; i++ ) {
        cout << "    Object " << oids[i<<1] << " vs. Object "
            << oids[(i<<1)+1] << " = " << dists[i] << endl;
    }
 }
I have also been testing with just Query_Intersection:

Code:
bool collision = swift_scene->Query_Intersection(false, num_pairs, &oids);
cout<<"\ncollision:"<<collision;
The SWIFT queries return false for collision! The objects are right on top of each other! The Exact Distance returns a distance of 0.

Now if I translate the pyramid.tri vertices over 1 on the x axis so that it is:

Code:
TRI

5

6

2 -1 1
2 -1 -1
0 -1 -1
0 -1 1
1 1 0

0 1 4
4 1 2
4 2 3
4 3 0
0 3 2
0 2 1
It returns intersection. So what is the difference between the objects being stacked practically on top of each other and this new formation of them when one is slightly translated?

Another strange thing is that if I continue to increase the translation on the x axis...SWIFT will return false for intersection when it should and the correct distance up until I pass a translation of 5 (distance of 3). When I go to a translation of 6 (distance of 4), the

Code:
    bool c = my_swift_scene.scene->Query_Exact_Distance(false, SWIFT_INFINITY, num_pairs, &oids, &dists);
line does not put any values into num_pairs or dists. Why is that? Am I passing some kind of threshold?

My main concern is why that first case will not return intersection between the objects. But the distance problem puzzles me as well. I am extremely new to SWIFT so maybe I am missing some small, yet important details. Any help is appreciated.