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
58 votes
3 answers
16k 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?
smnbss's user avatar
  • 701
72 votes
12 answers
127k 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.
Iain's user avatar
  • 6,518
4 votes
3 answers
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 ...
Tamás Szelei's user avatar
172 votes
10 answers
35k 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 ...
mr-matt's user avatar
  • 2,759
82 votes
17 answers
59k 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 ...
16 votes
4 answers
5k 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 ...
Aracthor's user avatar
  • 1,009
3 votes
3 answers
550 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 ...
user avatar
74 votes
6 answers
35k 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 ...
SomeXnaChump's user avatar
19 votes
2 answers
15k 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 ...
deniz's user avatar
  • 505
7 votes
4 answers
10k 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 ...
Denis Ermolin's user avatar
23 votes
1 answer
6k views

Optimization of rendering of cube world

I have a world made of many cubes (like in Minecraft), they have only color (not texture). I am rendering them using OpenGL 3.3 core profile (GLFW3, GLAD, GLM). I am already have done some ...
galaxy001's user avatar
  • 369
13 votes
11 answers
4k 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 ...
David Basarab's user avatar
10 votes
1 answer
2k 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: ...
dnk drone.vs.drones's user avatar
9 votes
6 answers
9k 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 ...
Luke Vo's user avatar
  • 465
7 votes
2 answers
11k 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 ...
Matthew Scharley's user avatar
6 votes
4 answers
7k 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 ...
GameDevEnthusiast's user avatar
4 votes
1 answer
3k views

Do empty Update() methods get executed and slow down the game while playing?

From an optimization point of view, is it best practice to delete the predefined update() methods in all my C# scripts if there is no code inside them ? On hundreds/thousands of GameObject(s) with ...
Horatiu's user avatar
  • 43
3 votes
3 answers
1k 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 ...
Moo's user avatar
  • 352
3 votes
1 answer
394 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 ...
yoozer8's user avatar
  • 1,144
2 votes
3 answers
3k views

Displaying possible movement tiles

What's the fastest way to highlight all possible movement tiles for a player on a square grid? Players can only move up, down, left, right. Tiles can cost more than one movement, multiple levels are ...
Ash Blue's user avatar
  • 254
0 votes
3 answers
3k 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 ...
Pascal Claes's user avatar
24 votes
6 answers
7k 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 ...
Grimshaw's user avatar
  • 3,121
23 votes
7 answers
5k 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. ...
Carson Myers's user avatar
23 votes
6 answers
2k 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 ...
aaronfarr's user avatar
  • 468
20 votes
4 answers
28k 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 ...
Robin Rodricks's user avatar
20 votes
3 answers
11k 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, ...
jokoon's user avatar
  • 5,243
14 votes
2 answers
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 ...
MrDatabase's user avatar
  • 1,951
14 votes
4 answers
13k 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 ...
Louis15's user avatar
  • 569
13 votes
5 answers
4k 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 ...
Vittorio Romeo's user avatar
11 votes
3 answers
9k 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: ...
Alconja's user avatar
  • 848
11 votes
1 answer
17k 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?
SICGames2013's user avatar
9 votes
1 answer
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 ...
mx2's user avatar
  • 119
8 votes
1 answer
558 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 ...
user802232's user avatar
7 votes
1 answer
1k 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 ...
MisteriosM's user avatar
7 votes
1 answer
646 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 ...
seesharper's user avatar
6 votes
4 answers
17k 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 ...
omgnoseat's user avatar
  • 1,164
6 votes
1 answer
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 ...
Meow's user avatar
  • 123
6 votes
2 answers
3k 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 ...
Adrian17's user avatar
  • 161
5 votes
1 answer
2k 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: ...
Gustavo Maciel's user avatar
5 votes
3 answers
3k 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 ...
Will's user avatar
  • 6,977
4 votes
2 answers
10k 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 ...
user1002617's user avatar
4 votes
3 answers
7k 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 ...
Adrian Seeley's user avatar
4 votes
0 answers
677 views

Rendering hundreds of animated characters in Unity3D

I am currently doing some research in anticipation of the development of a game where there are going to be hundreds of secondary entities which will interact with the player and among themselves (...
Marc Jacob's user avatar
4 votes
2 answers
832 views

C++ Object management/deletion

I am working on a game with a lot of bullets, currently every second it loops through a vector of bullet objects and checks if its marked for erasure or not. ...
Sam Boman's user avatar
3 votes
3 answers
1k 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 ...
loryruta's user avatar
2 votes
2 answers
6k 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 ...
komorra's user avatar
  • 213
2 votes
1 answer
3k views

Should 3D transformations be represented by a 4x4 matrix or a 3x4 matrix?

Since 3D transformations are represented by 4x4 homogeneous matrices we know that their last row is always (0,0,0,1), and as such the behavior of this final row is implied so long as we know whether ...
Ryoku's user avatar
  • 187
2 votes
1 answer
868 views

To split or not to split large 3D objects?

I have a fairly simple question for which I'm seeking guidance: Should large 3D objects be splitted into smaller ones? By wide, I mean an object that would be as wide as a game level is, below is ...
Eric Cartman's user avatar
2 votes
5 answers
2k 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: ...
hiddensunset4's user avatar
2 votes
1 answer
25k 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 ...
Heisenbug's user avatar
  • 2,144