Questions tagged [optimization]

The process of modifying software to make some part of it work more efficiently or use fewer resources. Generally, this means it executes more rapidly, or will require fewer resources.

Filter by
Sorted by
Tagged with
56
votes
3answers
15k views

Optimizing an XNA 2D game

Does it make sense to implement the logic to skip rendering objects outside the viewport or should I not care about it and let the Framework do it?
63
votes
11answers
96k views

What is the fastest way to work out 2D bounding box intersection?

Assume that each Box object has the properties x, y, width, height and have their origin at their center, and that neither the objects nor the bounding boxes rotate.
3
votes
3answers
4k views

Optimized rendering of a cube mesh world

I want to render a cube-mesh (a.k.a. Minecraft-style) world. If I render each existing cube it will eat up FPS pretty quickly. How can I optimize it? I understand that the point is to not render ...
79
votes
17answers
56k views

C++ low-level optimization tips [closed]

Assuming you already have the best-choice algorithm, what low-level solutions can you offer for squeezing the last few drops of sweet sweet frame rate out of C++ code? It goes without saying that ...
14
votes
4answers
4k views

How to load a spherical planet and its regions?

I'm designing a game partially composed of planets exploration. I want to use pseudo-random generation for them, regenerating from a defined seed when I have to load them rather than store every ...
3
votes
3answers
491 views

Ways to make my game world bigger without slowing users CPU

I've been developing my first game for a little while now, but I've found that I want to make the game world MUCH bigger. It's currently about 300*300 tiles, but has creatures and bad guys running ...
76
votes
6answers
28k views

How can I optimise a Minecraft-esque voxel world?

I found Minecraft's marvelous large worlds extremely slow to navigate, even with a quad core and meaty graphics card. I assume Minecraft's slowness comes from: Java, as spatial partitioning and ...
167
votes
9answers
32k views

Why is it so bad to optimize too early?

After looking into optimization a bit, I have discovered (literally everywhere) that it seems to be a universally recognized sin to optimize a game too early. I really don't understand this, would it ...
16
votes
2answers
10k views

What are the common rendering optimization techniques for the geometry pass in a deferred shading renderer? [closed]

I have been developing a game engine using OpenGL 3 and C++ (and glfw for window management). I have advanced so far, got most of the things done except sound entities and optimizations. The engine ...
13
votes
11answers
2k views

In general how often and when should I optimize my code?

In 'normal' business programming optimization step is often left until really needed. Meaning you should not optmize until it is really needed. Remember what Donald Knuth said "We should forget ...
0
votes
3answers
900 views

How to optimize collisions

I'm building a 2D MORPG using JavaScript, Node JS and socket.io To prevent cheating, I have to run all collisions for all players on my server. I'm currently doing fairly simple square collisions ...
7
votes
6answers
5k views

How do I efficiently sort objects by draw order when rendering a 2D game?

I need to render a "tile" game with objects that overlap, because they are taller than the tile they stand on, like the games in these screenshots: I don't know how to render them in the correct ...
6
votes
4answers
7k views

Smoothing found path on grid

I implemented several approaches such as A* and Potential fields for my tower defense game. But I want smooth paths, first I tried to find path on very small grid ( 5x5 pixels per tile) but it is ...
7
votes
2answers
9k views

How do I enable higher FPS in XNA 4.0?

I created a FpsCounter DrawableGameComponent (linked to code, it's longish). It works great: It displays 60.0 fps normally. If I ...
3
votes
1answer
351 views

Collision Detection Efficiency

I've just written my first successful collision detection code, and it works great for a small scene of actors (player + 4-5 obstacles). However, I realize that since it checks every possible ...
3
votes
3answers
862 views

Possible A* Optimizations [closed]

I have implemented A* in my game. However, I am not happy with the performance and need some help deciding what to do next. I have already done the following optimizations: Not having a closed list ...
23
votes
6answers
1k views

Spell casting - How to optimize damage per second

Imagine we have a wizard that knows a few spells. Each spell has 3 attributes: Damage, cool down time, and a cast time. Pretty standard RPG stuff. Cooldown time: the amount of time (t) it takes ...
23
votes
7answers
4k views

Optimizing gravity calculations

I've got a bunch of objects of varying size and velocity which gravitate towards each other. On every update, I have to go over every object and add up the forces due to gravity of every other object. ...
23
votes
6answers
5k views

How to optimize the distance function?

While developing a reasonably simple RTS-like game, I noticed my distance calculations were causing an impact in performance. At all times, there are distance checks to know if a unit is in range to ...
19
votes
4answers
20k views

Which opcodes are faster at the CPU level? [closed]

In every programming language there are sets of opcodes that are recommended over others. I've tried to list them here, in order of speed. Bitwise Integer Addition / Subtraction Integer ...
14
votes
2answers
4k views

“Optimal” game loop for 2D side-scroller

Is it possible to describe an "optimal" (in terms of performance) layout for a 2D side-scroller's game loop? In this context the "game loop" takes user input, updates the states of game objects and ...
6
votes
4answers
13k views

Effecient tilemap rendering

I have done mostly tile based games, but never really bothered with optimization. I always just rendered all the tiles that convered the viewport. I am currently working on platformer for a mobile ...
14
votes
5answers
3k views

How can I optimize a collision engine where order is significant and collision is conditional based on object group?

If this is your first time on this question, I suggest reading the pre-update part below first, then this part. Here's a synthesis of the problem, though: Basically, I have a collision detection ...
14
votes
3answers
7k views

Are collision detection always O(n^2)?

Are physics engine able to decrease that complexity, for example by grouping objects who are near each other and check for collisions inside this group instead of against all objects ? (for example, ...
8
votes
1answer
603 views

How can City-sim simulate hundreds of characters?

My games usually start lagging quite easily when there are a couple hundred of boxes representing possible characters. While games like SimCity or even Anno have hundreds of characters. I realized ...
11
votes
3answers
8k views

Rendering performance for Flash games

I was reading on SO about native flash rendering vs building a custom BitmapData frame buffer and some of the answers were a bit conflicting, so I was wondering: ...
5
votes
2answers
2k views

How do I optimize 2D visibility cone calculations?

I'm creating a simple 2D game and got a little bit stuck with a visibility cone algorithm, influenced by walls and other obstacles on the map. The only issue I'm currently having, is that it's very ...
10
votes
4answers
6k views

How do I efficiently check if a point is inside a rotated rectangle?

Part for the sake of optimization, part for learning purposes, I will dare to ask: How can I most efficiently check whether a 2D point P is inside a 2D rotated ...
9
votes
1answer
1k views

In a 2D physics engine, how do I avoid useless collision resolutions when objects come to a rest?

In a physics engine I'm developing (for learning) using love-2d, I implemented collision resolutions in this way: ...
6
votes
4answers
5k views

Object pools for efficient resource management

How can I avoid using default new() to create each object? My previous demo had very unpleasant framerate hiccups during dynamic memory allocations (usually, when arrays are resized), and creating ...
2
votes
3answers
2k views

Coarse Collision Detection in highly dynamic environment

I'm currently working a 3D space game with A LOT of dynamic objects that are all moving (there is pretty much no static environment). I have the collision detection and resolution working just fine, ...
9
votes
1answer
1k views

Is the STL efficient enough for mobile devices?

When it comes to mobile game development on iOS and Android NDK, some developers write their own C++ containers, while others claim that STL is more than adequate for mobile game development (For ...
6
votes
1answer
10k views

Quads Vs Triangles

I'm curious to know which is better for games: quads or triangles? Wouldn't quads be better for rendering performances and smoothing out tessellation?
3
votes
0answers
440 views

Rendering hundreds of animated characters in Unity3D

I am currently doing some research in anticipation to the development of a game where there is going to be hundreds of secondary entities which will interact with the player and among themselves (...
6
votes
1answer
1k views

How to generate portal zones?

I'm developing a portal-based scene manager. Basically all it does is to check the portals against the camera frustum, and render their associated portal zones accordingly. Is there any way my editor ...
5
votes
1answer
1k views

Component-wise GLSL vector branching

I'm aware that it usually is a BAD idea to operate separately on GLSL vec's components separately. For example: ...
4
votes
3answers
2k views

why is it faster to draw lots of small arrays than one big array?

This application on-line here has interesting performance characteristics: Sorting the rectangles to be drawn so it keeps having to change colour is faster than sorting the rectangles by their colour ...
4
votes
3answers
6k views

Using SQL for a Realtime Multiplayer Game Server's Working Data (Fast Enough?)

The game I'm working on currently has a Client in Flash AS3, and a Server in C# (multithreaded). Currently I use mySQL to handle logins (Raw access: no middleman for accessing the database) which ...
3
votes
2answers
3k views

Handmade Terrain vs. Terrain Engine in Unity?

I'm planning a game right now, to be made in Unity, and I'm trying to decide how I'll approach the basic level construction. Essentially, my game takes place on an island in an infinite ocean, very ...
3
votes
3answers
839 views

Cube world rendering optimizations

I'm making a Minecraft like game and I would like to apply some optimizations. Firstly I didn't and I rendered the world using a vbo in which I stored a cube model and I drow all blocks of the worlds ...
2
votes
5answers
1k views

OpenGL Performance Questions

This subject, as with any optimisation problem, gets hit on a lot, but I just couldn't find what I (think) I want. A lot of tutorials, and even SO questions have similar tips; generally covering: ...
2
votes
1answer
24k views

Unity3D draw call optimization : static batching VS manually draw mesh with MaterialPropertyBlock

I've read Unity3D draw call batching documentation. I understood it, and I want to use it (or something similar) in order to optimize my application. My situation ...
2
votes
2answers
425 views

FPS drop when detecting collision (sfml, c++)

So, I have this small class with a collision detection function in it, it's called every frame. When I run the game I get around 8000 FPS, but when the collision function gets called it drops to 2000....
1
vote
2answers
2k views

Fastest way to neutralize scale in the transform matrix?

Let's assume we have 4x4 3D transformation matrix, that is the result of scale, rotation, and translation transforms. How to set its scale to (1,1,1) in the fastest way? Assume also that the matrix is ...
8
votes
1answer
431 views

Chunking/caching large levels in a singleplayer game

Does it make sense to try to offload a large nonlinear level into file-based chunks, and load those on demand? We've implemented level chunking to improve rendering performance, but still all level ...
7
votes
1answer
589 views

Display Lists in OpenGL

I heard that there was a faster method of displaying vertices, rather than recreating the GL_TRIANGLES, each time the scene is drawn. I thought I read somewhere that this method was obselete. Why ...
2
votes
1answer
3k views

How to generate AABB, OBB & Sphere from polygon soup

How can I generate AABB, OOBB and Sphere from a polygon soup, where the bounding volumes are defined as follows: AABB should be specified by min(x,y,z) max(x,y,z) OOBB should be specified by min(x,y,...
1
vote
1answer
59 views

How to optimize two-pass operations on an array with Unity Coroutines

I am working on simulating vacuum decompression in a 2D top down environment. I have 2 2-dimensional arrays: one that stores the pressure at a location, and one that stores the vector of fluid flow. ...
1
vote
2answers
1k views

Multithreading/Optimisation for Random Generation in Gamemaker

I have a FurGeneration() script in my game; when run, it randomly generates individual oFur objects in specified areas in the ...
1
vote
0answers
287 views

OpenWorld SceneGraph management and optimization [closed]

I have a SceneGraph class which for now is just a simple list implementation, and the only optimization I've planned so far is a check is something like this: ...