# Compound Shape for CollisionSolid

I am aware that Bullet supports compound shape. Does CollisionSolid also support it?
I could set TransformState to a CollisionNode, but cannot set TransformState to a CollisionSolid. A CollisionNode cannot host several CollisionSolids with different tranformations.

Ah, but it can support multiple CollisionSolids (just call â€śaddSolidâ€ť more than once, passing in the desired solids), and such solids can be set up to effectively have transformations.

For example, letâ€™s say that you wanted to have a CollisionNode that contained two spheres, one atop the other. That might look something like this, I believe:

``````node = CollisionNode("kitten")

# Create a sphere at location (0, 0, 0), of radius 2
solid1 = CollisionSphere(0, 0, 0, 2)

# Create a sphere at location (0, 0, 2), of radius 1
# --i.e. smaller, and located vertically higher than the other
solid2 = CollisionSphere(0, 0, 2, 1)
``````

Thanks. I am trying to combine multiple CollisionBox.
The following code might be a solution, but if I want to change the collisionmasks later, I have to get down to each of the node() and update them separately. That is annoying.

`````` collision_primitive = CollisionBox(center=LPoint3(0, 0, 0),
x=x_side,
y=math.tan(angles[1] / 2) * x_side,
z=cyl.height / 2.0)
pdcndp = NodePath("auto")
for angle in angles:
homomat = cyl.homomat @ rm.homomat_from_posrot(rot=rm.rotmat_from_axangle(np.array([0, 0, 1]), angle))
pdcnd = CollisionNode("auto")
pdcnd.setTransform(TransformState.makeMat(da.npmat4_to_pdmat4(homomat)))
pdcndp.attachNewNode(pdcnd).show()
``````

Iâ€™mâ€¦ not sure that it would work with a single collision-solid being shared by multiple collision-nodesâ€“I was thinking of something the other way around! (But maybe it willâ€“I donâ€™t know that Iâ€™ve tried it!)

Humâ€“but if you do require more than just the positioning of your solidsâ€“if you require rotation, tooâ€“and if itâ€™s boxesâ€“i.e. not spheres or capsulesâ€“that you want to rotate, then indeed, the â€śmultiple solids in a single nodeâ€ť solution might not workâ€¦

Otherwise, let me ask: what are you trying to achieve here? Perhaps another solution might be foundâ€¦

And if notâ€¦ then perhaps Bullet will work better for you!

Yes, Bullet works. Essentially, I am trying to build a CollisionCylinder using multiple boxesâ€¦ It is an invalid CollisionSolid.

When you say â€ścylinderâ€ť, do you mean a circular tube with flat ends?

If so, would a CollisionCapsule perhaps be close enough? That would, I suspect, make things a lot simplerâ€¦

If you have the time to wait, you could perhaps request a cylinder-solid via the issue-tracker.

1 Like

I think you donâ€™t need to modify the existing `CollisionNode`, you can always create a new one.

That is a possibilityâ€“depending of course on how often one wants to do it.

(If itâ€™s infrequent, and the process of building up this model is quick, then indeed: why not just throw away the old one and build a new one?)

I have to disagree with you, changing the transformation always costs more.

Not necessarily: it would depend I daresay on the process involved in making new nodes for the given purpose.

The problem is CollisionBox always aligns with axes. It cannot be rotated. I guess the problem is irrelavent to how many new CollisionNodes are created.