New answers tagged optimization
1
O(N^2) refers to the fact that if you have N objects, figuring out what is colliding with what is, worst case, N^2 collision computations. Say you have 3 objects. To find "who is hitting who", you have to find:
o1 hitting o2? o1 hitting o3?
o2 hitting o1? o2 hitting o3?
o3 hitting o1? o3 hitting o2?
That's 6 checks for collisions, or N*(N-1) checks. ...
8
Spatial division is always O(N^2) in worst case and that is what complexity in informatics is about.
However there are algorithms that work in linear time O(N). All of them are based on some kind of sweep line.
Basically you need to have your objects sorted by one coordinate. Let's say X. If you perform the sort every time before collision detection, the ...
9
No. Collision detection is not always O(N^2).
For instance, say we have a 100x100 space with objects with size 10x10. We could divide this space in cells of 10x10 with a grid.
Each object can be in up to 4 grid cells (it could fit right in a block or be "between" cells). We could keep a list of objects in each cell.
We only need to check for collisions in ...
2
What you're talking about is called a "texture atlas". The simplest way to do it is to create a static, precomputed atlas, containing all the textures in your whole game world. Each tile would have UVs set up to point to wherever its texture is in the atlas. It's a quite common technique to allow combining draw calls together.
The idea you had of a ...
1
for the different matrix constructors: no it's easier to do a chained invocation matrix = Matrix4d.identity().rotateYaw(yaw).rotatePitch(pitch).translate(attachPoint);, and each of these rotate operations can be optimized (and the inverse calculated along side it)
the bottom (0 0 0 1) row can be optimized out easily by not even storing them (assume all ...
1
I don't think the performance problem is happening on the multiplication, but on the interpolation of your DestinationColor across the triangles, between vertex and fragment shaders. You have four floats to interpolate between tree vertices, for each fragment for each sprite.
For 700 sprites 64x64 pixels each, this is 11468800 additional operations per ...
Top 50 recent answers are included

