BGE: Fix for T42285 & T38935 crashes. They are Rayhit related.
We make sure that good values are passed to GetPolygon() and we check that the visual mesh doesn't have a wrong displacement when it passes over a object which has a mesh triangle as compound bound. Reviewers: dfelinto, sergof, agoose77, moguri Reviewed By: moguri Subscribers: agoose77 Differential Revision: https://developer.blender.org/D979
This commit is contained in:
parent
2b847d1e65
commit
1af042d9ed
Notes:
blender-bot
2023-02-14 11:05:04 +01:00
Referenced by issue #42285, Crash of Blender in Gameengine/Physicsengine concerning ApplyForce Referenced by issue #38935, BGE crash (Fase Orientation == Shadow above Collision Bounds == Convex Hull)
|
@ -1269,28 +1269,32 @@ void RAS_OpenGLRasterizer::RemoveLight(RAS_ILightObject* lightobject)
|
|||
|
||||
bool RAS_OpenGLRasterizer::RayHit(struct KX_ClientObjectInfo *client, KX_RayCast *result, void * const data)
|
||||
{
|
||||
double* const oglmatrix = (double* const) data;
|
||||
if (result->m_hitMesh) {
|
||||
double* const oglmatrix = (double* const) data;
|
||||
|
||||
RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
|
||||
if (!poly->IsVisible())
|
||||
RAS_Polygon* poly = result->m_hitMesh->GetPolygon(result->m_hitPolygon);
|
||||
if (!poly->IsVisible())
|
||||
return false;
|
||||
|
||||
MT_Vector3 resultnormal(result->m_hitNormal);
|
||||
MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
|
||||
MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
|
||||
left = (dir.cross(resultnormal)).safe_normalized();
|
||||
// for the up vector, we take the 'resultnormal' returned by the physics
|
||||
|
||||
double maat[16] = {left[0], left[1], left[2], 0,
|
||||
dir[0], dir[1], dir[2], 0,
|
||||
resultnormal[0], resultnormal[1], resultnormal[2], 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
glTranslated(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
|
||||
//glMultMatrixd(oglmatrix);
|
||||
glMultMatrixd(maat);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
MT_Point3 resultpoint(result->m_hitPoint);
|
||||
MT_Vector3 resultnormal(result->m_hitNormal);
|
||||
MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
|
||||
MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
|
||||
left = (dir.cross(resultnormal)).safe_normalized();
|
||||
// for the up vector, we take the 'resultnormal' returned by the physics
|
||||
|
||||
double maat[16] = {left[0], left[1], left[2], 0,
|
||||
dir[0], dir[1], dir[2], 0,
|
||||
resultnormal[0], resultnormal[1], resultnormal[2], 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
|
||||
//glMultMatrixd(oglmatrix);
|
||||
glMultMatrixd(maat);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
|
||||
|
|
Loading…
Reference in New Issue