Moderators: Sascha Willems, walaber
Julio Jerez wrote:I do no see that guard rail in that demo. I see many ramps and obstacles but nothing like in the video
there is a door at the end of the room, but I don know how to get there, the ramp tip toe down want I try get to the door. and it does not jumps high enough.
dgInt32 dgBroadPhase::ConvexCast(const dgBroadPhaseNode** stackPool, dgFloat32* const distance, dgInt32 stack, const dgVector& velocA, const dgVector& velocB, dgFastRayTest& ray,
dgCollisionInstance* const shape, const dgMatrix& matrix, const dgVector& target, dgFloat32* const param, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const
{
dgVector boxP0;
dgVector boxP1;
dgTriplex points[DG_CONVEX_CAST_POOLSIZE];
dgTriplex normals[DG_CONVEX_CAST_POOLSIZE];
dgFloat32 penetration[DG_CONVEX_CAST_POOLSIZE];
dgInt64 attributeA[DG_CONVEX_CAST_POOLSIZE];
dgInt64 attributeB[DG_CONVEX_CAST_POOLSIZE];
dgInt32 totalCount = 0;
dgAssert(matrix.TestOrthogonal());
shape->CalcAABB(matrix, boxP0, boxP1);
static int xxx;
xxx ++;
maxContacts = dgMin (maxContacts, DG_CONVEX_CAST_POOLSIZE);
dgAssert (!maxContacts || (maxContacts && info));
dgFloat32 maxParam = *param;
dgFloat32 timeToImpact = *param;
while (stack) {
stack--;
dgFloat32 dist = distance[stack];
if (dist > maxParam) {
break;
} else {
const dgBroadPhaseNode* const me = stackPool[stack];
dgBody* const body = me->GetBody();
if (body) {
if (!PREFILTER_RAYCAST(prefilter, body, body->m_collision, userData)) {
dgInt32 count = m_world->CollideContinue(shape, matrix, velocA, velocB, body->m_collision, body->m_matrix, velocB, velocB, timeToImpact, points, normals, penetration, attributeA, attributeB, maxContacts, threadIndex);
if (timeToImpact < maxParam) {
if ((timeToImpact - maxParam) < dgFloat32(-1.0e-3f)) {
totalCount = 0;
}
maxParam = timeToImpact;
if (count >= (maxContacts - totalCount)) {
count = maxContacts - totalCount;
}
for (dgInt32 i = 0; i < count; i++) {
info[totalCount].m_point[0] = points[i].m_x;
info[totalCount].m_point[1] = points[i].m_y;
info[totalCount].m_point[2] = points[i].m_z;
info[totalCount].m_point[3] = dgFloat32(0.0f);
info[totalCount].m_normal[0] = normals[i].m_x;
info[totalCount].m_normal[1] = normals[i].m_y;
info[totalCount].m_normal[2] = normals[i].m_z;
info[totalCount].m_normal[3] = dgFloat32(0.0f);
info[totalCount].m_penetration = penetration[i];
info[totalCount].m_contaID = attributeB[i];
// trace the contact point top see if they are valid
dgTrace (("frame: %d, param: %f, posit(%f %f %f)\n", xxx, maxParam, points[i].m_x, points[i].m_y, points[i].m_z));
info[totalCount].m_hitBody = body;
totalCount++;
}
}
if (maxParam < 1.0e-8f) {
break;
}
}
} else if (me->IsAggregate()) {
dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)me;
const dgBroadPhaseNode* const node = aggregate->m_root;
if (node) {
dgVector minBox(node->m_minBox - boxP1);
dgVector maxBox(node->m_maxBox - boxP0);
dgFloat32 dist1 = ray.BoxIntersect(minBox, maxBox);
if (dist1 < maxParam) {
dgInt32 j = stack;
for (; j && (dist1 > distance[j - 1]); j--) {
stackPool[j] = stackPool[j - 1];
distance[j] = distance[j - 1];
}
stackPool[j] = node;
distance[j] = dist1;
stack++;
dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH);
}
}
} else {
dgBroadPhaseTreeNode* const node = (dgBroadPhaseTreeNode*)me;
const dgBroadPhaseNode* const left = node->m_left;
dgAssert(left);
dgVector minBox(left->m_minBox - boxP1);
dgVector maxBox(left->m_maxBox - boxP0);
dgFloat32 dist1 = ray.BoxIntersect(minBox, maxBox);
if (dist1 < maxParam) {
dgInt32 j = stack;
for (; j && (dist1 > distance[j - 1]); j--) {
stackPool[j] = stackPool[j - 1];
distance[j] = distance[j - 1];
}
stackPool[j] = left;
distance[j] = dist1;
stack++;
dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH);
}
const dgBroadPhaseNode* const right = node->m_right;
dgAssert(right);
minBox = right->m_minBox - boxP1;
maxBox = right->m_maxBox - boxP0;
dist1 = ray.BoxIntersect(minBox, maxBox);
if (dist1 < maxParam) {
dgInt32 j = stack;
for (; j && (dist1 > distance[j - 1]); j--) {
stackPool[j] = stackPool[j - 1];
distance[j] = distance[j - 1];
}
stackPool[j] = right;
distance[j] = dist1;
stack++;
dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH);
}
}
}
}
*param = maxParam;
return totalCount;
}
bool Shape::Reload(const int flags)
{
Stream* stream=NULL;
Vec3 position;
Vec3 rotation;
Vec3 scale;
Surface* surf=NULL;
int verts, v, i;
std::vector<float> vertices;
iVec3 tri;
if (path=="")
{
//Print("Error: Can't reload shape. No path specified.");
return false;
}
Reset();
int newtime = FileSystem::GetFileTime(path);
stream = FileSystem::ReadFile(path);
if (stream==NULL)
{
System::Print("Error: Failed to read file \""+path+"\".");
return false;
}
time=newtime;
if (stream->ReadString()!="PHY")
{
System::Print("Error: Shape file header not found.");
delete stream;
stream = NULL;
return false;
}
switch (stream->ReadInt())
{
case 2:
break;
default:
System::Print("Error: Unsupported shape file version.");
delete stream;
stream = NULL;
return false;
}
int subshapes = stream->ReadInt();
//At this time, only convexhulls and polymesh are supported
for (int k=0; k<subshapes; k++)
{
shapeid = stream->ReadInt();
if (shapeid==SHAPE_BOX)
{
position.x = stream->ReadFloat();
position.y = stream->ReadFloat();
position.z = stream->ReadFloat();
rotation.x = stream->ReadFloat();
rotation.y = stream->ReadFloat();
rotation.z = stream->ReadFloat();
scale.x = stream->ReadFloat();
scale.y = stream->ReadFloat();
scale.z = stream->ReadFloat();
((NewtonDynamicsPhysicsDriver*)driver)->CreateShapeBox((NewtonDynamicsShape*)this, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, scale.x, scale.y, scale.z);
}
if (shapeid == SHAPE_SPHERE)
{
position.x = stream->ReadFloat();
position.y = stream->ReadFloat();
position.z = stream->ReadFloat();
rotation.x = stream->ReadFloat();
rotation.y = stream->ReadFloat();
rotation.z = stream->ReadFloat();
scale.x = stream->ReadFloat();
scale.y = stream->ReadFloat();
scale.z = stream->ReadFloat();
((NewtonDynamicsPhysicsDriver*)driver)->CreateShapeSphere((NewtonDynamicsShape*)this, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, scale.x, scale.y, scale.z);
}
if (shapeid == SHAPE_CONE)
{
position.x = stream->ReadFloat();
position.y = stream->ReadFloat();
position.z = stream->ReadFloat();
rotation.x = stream->ReadFloat();
rotation.y = stream->ReadFloat();
rotation.z = stream->ReadFloat();
scale.x = stream->ReadFloat();
scale.y = stream->ReadFloat();
scale.z = stream->ReadFloat();
((NewtonDynamicsPhysicsDriver*)driver)->CreateShapeCone((NewtonDynamicsShape*)this, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, scale.x, scale.y, scale.z);
}
if (shapeid == SHAPE_CYLINDER)
{
position.x = stream->ReadFloat();
position.y = stream->ReadFloat();
position.z = stream->ReadFloat();
rotation.x = stream->ReadFloat();
rotation.y = stream->ReadFloat();
rotation.z = stream->ReadFloat();
scale.x = stream->ReadFloat();
scale.y = stream->ReadFloat();
scale.z = stream->ReadFloat();
((NewtonDynamicsPhysicsDriver*)driver)->CreateShapeCylinder((NewtonDynamicsShape*)this, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, scale.x, scale.y, scale.z);
}
if (shapeid==SHAPE_CONVEXHULL)
{
surf=Surface::Create();
verts=stream->ReadInt();
for (v=0; v<verts; v++)
{
position.x = stream->ReadFloat();
position.y = stream->ReadFloat();
position.z = stream->ReadFloat();
surf->AddVertex(position.x,position.y,position.z);
}
((PhysicsDriver*)driver)->CreateShapeConvexHull(surf,this);
surf->Release();
}
else if (shapeid==SHAPE_POLYMESH)
{
surf=Surface::Create();
int verts=stream->ReadInt();
int tris=stream->ReadInt();
#ifdef DEBUG
//Debug::Assert(verts < 10000);
//Debug::Assert(tris < 10000);
/*if (tris > 10000)
{
surf->Release();
return false;
}*/
#endif
int v,t;
float p, area;
Vec3 a, b, c;
float da, db, dc;
int vertex_count;
for (v=0; v<verts; v++)
{
position.x = stream->ReadFloat();
position.y = stream->ReadFloat();
position.z = stream->ReadFloat();
surf->AddVertex(position.x,position.y,position.z);
}
for (t=0; t<tris; t++)
{
tri.x = stream->ReadInt();
tri.y = stream->ReadInt();
tri.z = stream->ReadInt();
if (tri.x != tri.y && tri.x != tri.z && tri.y != tri.z)
{
#ifdef DEBUG
Debug::Assert(tri.x >= 0 && tri.x < verts);
Debug::Assert(tri.y >= 0 && tri.y < verts);
Debug::Assert(tri.z >= 0 && tri.z < verts);
#endif
a = surf->GetVertexPosition(tri.x);
b = surf->GetVertexPosition(tri.y);
c = surf->GetVertexPosition(tri.z);
vertex_count = surf->CountVertices();
da = a.DistanceToPoint(b);
db = b.DistanceToPoint(c);
dc = c.DistanceToPoint(a);
p = (da + db + dc) / 2.0;
area = sqrt(p * (p - da)*(p - db)*(p - dc));
if (area > 0.001) surf->AddTriangle(tri.x, tri.y, tri.z);
}
}
if (surf->CountTriangles())
{
((PhysicsDriver*)driver)->CreateShapePolyMesh(surf, this);
}
surf->Release();
}
}
Finalize();
stream->Release();
return true;
}
Julio Jerez wrote:not that does not work, The player can't even jump that high, can't you take one of these create and make a compound?
Users browsing this forum: No registered users and 12 guests