diff options
| author | Alexander <alex@cogarr.net> | 2019-10-27 17:25:16 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2019-10-27 17:25:16 -0400 |
| commit | 0d2de2ba9c616862d7881f089382db772d034f89 (patch) | |
| tree | 5fc58b63c593e2ac17f3353b50318c299f643390 /src/shared/lua_api/phys | |
| parent | c9db55cdc2f69c3dc7aefabe0cc828a64e377024 (diff) | |
| download | brokengine-0d2de2ba9c616862d7881f089382db772d034f89.tar.gz brokengine-0d2de2ba9c616862d7881f089382db772d034f89.tar.bz2 brokengine-0d2de2ba9c616862d7881f089382db772d034f89.zip | |
Various updates
Diffstat (limited to 'src/shared/lua_api/phys')
| -rw-r--r-- | src/shared/lua_api/phys/bphysbuffer.cpp | 10 | ||||
| -rw-r--r-- | src/shared/lua_api/phys/bphysmodel.cpp | 19 |
2 files changed, 18 insertions, 11 deletions
diff --git a/src/shared/lua_api/phys/bphysbuffer.cpp b/src/shared/lua_api/phys/bphysbuffer.cpp index 111b159..074f506 100644 --- a/src/shared/lua_api/phys/bphysbuffer.cpp +++ b/src/shared/lua_api/phys/bphysbuffer.cpp @@ -27,11 +27,11 @@ using namespace video; extern btDiscreteDynamicsWorld* World; extern core::list<btRigidBody*> Objects; -static LBPhysNode* checkisbphysmodel(lua_State* L, int index){ - void* ud = luaL_checkudata(L,index,"phys.physmodel"); - luaL_argcheck(L,ud != NULL, index, "'phys.physmodel' expected"); - return (LBPhysNode*) ud; -} +//static LBPhysNode* checkisbphysmodel(lua_State* L, int index){ + //void* ud = luaL_checkudata(L,index,"phys.physmodel"); + //luaL_argcheck(L,ud != NULL, index, "'phys.physmodel' expected"); + //return (LBPhysNode*) ud; +//} //iscenecamera.new(Vector position, Vector lookat, parrent) // {} {} 0 1 diff --git a/src/shared/lua_api/phys/bphysmodel.cpp b/src/shared/lua_api/phys/bphysmodel.cpp index 0cff0ed..2c9a02d 100644 --- a/src/shared/lua_api/phys/bphysmodel.cpp +++ b/src/shared/lua_api/phys/bphysmodel.cpp @@ -12,6 +12,8 @@ extern "C" { #include <lualib.h> } #include <btBulletDynamicsCommon.h> +#include <btBulletCollisionCommon.h> +#include <BulletCollision/Gimpact/btGImpactShape.h> #include "bphysmodel.hpp" #include <shared/lua_api/common.hpp> #include <shared/util/tinyobj.hpp> @@ -69,19 +71,22 @@ void makebphysmodel(lua_State *L){ //__mingw_printf("attrib.num_vertices: %u\n",attrib.num_vertices); //__mingw_printf("attrib.num_faces: %u\n",attrib.num_faces); btTriangleMesh* trimesh = new btTriangleMesh(); + btVector3 vertexes[attrib.num_vertices]; for(size_t i = 0; i < attrib.num_vertices; i++){ //0 - x, so num_vertices - 1 - //__mingw_printf("Looking at vertice %llu/%u\n",i,attrib.num_vertices); - //DO NOT MULTIPLY THIS BY SIEZEOF(FLOAT) float *vs = attrib.vertices + (3*i);//3 floats per vertex //printf("Got start\n"); - float v1 = vs[0]; + //For some reason irrlicht and bullet disagree with which direction +x is, + //negate the x in the physics engine so the graphical stuff lines up + //with the physics stuff + float v1 = -vs[0]; //printf("Got 1\n"); float v2 = vs[1]; //printf("Got 2\n"); float v3 = vs[2]; //printf("Got all 3 vertexees\n"); //printf("Adding vertex: (%f %f %f)\n",v1, v2, v3); - trimesh->findOrAddVertex(btVector3(v1,v2,v3),true); + //trimesh->findOrAddVertex(btVector3(v1,v2,v3),true); + vertexes[i] = btVector3(v1,v2,v3); } printf("Finished finding or adding vertexes\n"); for(size_t i = 0; i < attrib.num_faces - 1; i+= 3){ //0 - y to num_faces - 1 @@ -89,7 +94,8 @@ void makebphysmodel(lua_State *L){ i1 = attrib.faces[i]; i2 = attrib.faces[i+1]; i3 = attrib.faces[i+2]; - trimesh->addTriangleIndices(i1.v_idx,i2.v_idx,i3.v_idx); + trimesh->addTriangle(vertexes[i1.v_idx],vertexes[i2.v_idx],vertexes[i3.v_idx],true); + //trimesh->addTriangleIndices(i1.v_idx,i2.v_idx,i3.v_idx); } printf("Finished adding triangle indicies\n"); //size_t numverts = attrib.num_face_num_verts; @@ -120,7 +126,8 @@ void makebphysmodel(lua_State *L){ //face_offset += (size_t)attrib.face_num_verts[i]; //} printf("Done building trimesh\n"); - btCollisionShape *shape = new btBvhTriangleMeshShape(trimesh,true); + //btCollisionShape *shape = new btGImpactMeshShape(trimesh); + btCollisionShape *shape = new btConvexTriangleMeshShape(trimesh); btTransform tr; tr.setIdentity(); tr.setOrigin(btVector3(x,y,z)); |
