Prevent objects going into others

Hey, I’m wondering if theres a way to prevent the currently held item (in this case a weapon) from going into a wall or any other objects.

Thanks

Actually not going in, collision.

Visually not going in, draw the weapon on top. Could be done in various ways. Some use a different projection matrix for the weapon. You can also make a 2-pass shader for the weapon. First pass with ZTest Always and ColorMask 0. That overwrites the depth with the depth of the weapon. (Pushing it back into a wall if needed.) Then a regular rendering pass for the second pass. Oh, and draw this after all other opaque geometry.