Timeline for What is a manageable way to handle physics collisions for many types in C#?
Current License: CC BY-SA 4.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 30, 2022 at 8:08 | vote | accept | WDUK | ||
| Jul 28, 2021 at 9:09 | answer | added | JonasH | timeline score: 0 | |
| Jul 22, 2021 at 21:30 | answer | added | Christophe | timeline score: 2 | |
| Jul 22, 2021 at 18:56 | comment | added | Jon Raynor | You could use a factory or abstract factory to create concrete IntersectingPoint calculators. The gets rid of your switch, but you are going to end up with different implementations. You could even make it generic. Also, there are several ways to eliminate switches in code...stackoverflow.com/questions/126409/… | |
| Jul 22, 2021 at 8:56 | comment | added | Philip Kendall | Assuming that GetIntersectingPoints is commutative, you can deal with "the other way around" issue by swapping obj1 and obj2 if necessary so that type(obj1) <= type(obj2) (you may need to define an ordering for your types. It doesn't matter what it is so long as it's consistent). This won't fix your combinatorial explosion problem though. | |
| Jul 22, 2021 at 8:38 | answer | added | pjc50 | timeline score: 3 | |
| Jul 22, 2021 at 8:29 | comment | added | CookedCthulhu | It matters because there's no one-fits-all design pattern. If you don't care about performance or where points intersect, create an interface or abstract class that rasterizes every primitive and compare them on the pixel level. Done. If your requirement is soft realtime, it may be time to think about ditching object orientation alltogether and only work with polygons. If your requirement is exact intersections, look up those math formulas specific to your primitives. | |
| Jul 22, 2021 at 8:17 | comment | added | Caleth | Related SO: multiple dispatch | |
| S Jul 22, 2021 at 7:57 | history | suggested | Kjartan | CC BY-SA 4.0 | Formatting to avoid sidescrolling |
| Jul 22, 2021 at 7:56 | comment | added | WDUK | I don't see why it matters if it's 2D, 3D or what i require out of a method. I am talking about if theres is a better design pattern for handling all the type combinations other than making gigantic switch statement for every combination like i currently have - it seems unmanageable. The current switch is like a middle man to direct the compiler to the relevant methods but its getting long and very repetitive. | |
| Jul 22, 2021 at 7:46 | comment | added | CookedCthulhu | I'm not sure there's enough information to properly answer the question: 2D or 3D (looks like 2D)? What are the performance requirements? Do you care about the exact intersection coordinates, the amount of intersection points or only that two objects intersect? What prevents you from turning everything into polygons? | |
| Jul 22, 2021 at 6:31 | review | Suggested edits | |||
| S Jul 22, 2021 at 7:57 | |||||
| Jul 22, 2021 at 2:57 | history | asked | WDUK | CC BY-SA 4.0 |