james7132 / DanmakU

An open source Danmaku development kit for Unity3D.
https://danmaku.jamessliu.com/
MIT License
238 stars 50 forks source link

Add per-Danmaku scaling #36

Open Jonath opened 6 years ago

Jonath commented 6 years ago

Potentially 2 types :

The advantage of solution 2 is that you could simulate the rotation of a bullet around an axis with a behaviour. (for instance scaling down X or Y to zero to make it look like it's rotating around the X or Y axis).

james7132 commented 6 years ago

This has several components that need to be implemented:

The latter seems to be difficult to handle with non-uniform scaling.

Jonath commented 6 years ago

I agree scaling a collider could be expensive, and also inaccurate for option 2. AABB and OOB should actually scale pretty nicely (although AABB could become very big). Circle won't scale well at all in case 2 (r = min(X,Y) will be inaccurate, and ellipse collision is terrible).

Maybe this should rather be defined by an empiric jobified behaviour depending on the pattern ? Thus, something to leave to the user to implement.

james7132 commented 6 years ago

Under the hood, we use a two pass collision algorithm: an initial AABB check against colliders, and then call Physics2D.CircleCastNonAlloc to do fine grain collision detection.

While computing AABBs for scaled offset circles is trivial, it does significantly complicate the code for this section of the algorithm.

The second part is the worrying one: Physics2D.CircleCast* calls do not support arbitrary non-uniform scaling.

For the time being, it should be possible to add at least uniform scaling without any major roadblocks.