Is there some way to do immediate collision check?

I want to add physycs object somewhere, but only if it does not cause it to collide with something already present.

So far i know i can do ray test, sweep test or just add and try to resolve it when it happens.

ray test is not enough

sweep test

  1. seems wastefull (I care about one position, not all along line)
  2. can miss object if it starts inside and moves away from center. I could use 2 sweep test, just over intended position in both directions, but that seems even more wastefull.

Is there better way to do it?

PS: I’m trying to use just collision detection, I don’t want actual physics so unless I change my mind, resolving when it happens is not something I’d like to do (I want to be sure, that there is no tick where objects (that I mind colliding) are colliding (I want to resolve collision by moving back to “safe” position and object will block both old and new position during tick, so old position will be unocuppied)

Why not distribute it over two frames?
Frame one check with a ghostobject, frame two add if sucessfull check.

It could take unqnowingly longer and betwen tries world changes, so it is not equivalent to multiple instant tries.
And doing one operation at once seems to be much simpler than distributing it over time. With multi frame approach I would need to formulate some rules differently (eg. when something, add skeletons around caster (try N times using some pattern) vs when something, start adding skeletons around caster (try N times using some pattern)).

With instant query I still could use multi frame approach so it can be design/performance decision.

You could add a ghostshape step a 0ms timestep for the physic (read the javadoc/docu how to do without the interpolation so it actually does a physic step)