bullet3 icon indicating copy to clipboard operation
bullet3 copied to clipboard

Expose collision shape in Raycast callbacks

Open duckdoom5 opened this issue 3 years ago • 2 comments

I'm using a btCompoundShape to combine a bunch of shapes. When I hit a ray I need the specific shapes. Unfortunately, this is currently impossible because btCollisionObject:getShape() doesn't return the individual shape. This can only be retrieved from the btCollisionObjectWrapper or when the result is constructed.

The proposed changes expose the shape directly, allowing me to get the actual shape that was inside of the compound

duckdoom5 avatar Jan 18 '22 16:01 duckdoom5

:D

BluePrintRandom avatar Jan 18 '22 20:01 BluePrintRandom

Actually it seems I'm mistaken. I was looking through godot source and found this code:

// Triangle index is an odd name but contains the compound shape ID.
// A shape part of -1 indicates the index is a shape index and not a triangle index.
if (convexResult.m_localShapeInfo && convexResult.m_localShapeInfo->m_shapePart == -1) {
	m_shapeId = convexResult.m_localShapeInfo->m_triangleIndex;
} else {
	m_shapeId = 0;
}

With that shape ID you can retrieve the (actually colliding) child shape from the compound object.

Unfortunately I can't confirm currently, so I'll come back with an update later

duckdoom5 avatar Jan 22 '22 15:01 duckdoom5