x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Performance cost of a C++ variable?

Hello!

I'm creating a voxel based game, and have planned to gain some performance by not spawning the blocks that don't have a block of air next to them, and therefore having tens, of not thousands of int's for each block, so it stores what block is in that slot, and spawns that block accordingly.

What would be the performance gains of this approach, and would they be demolished by the massive number of variables? (I would probably write a program to write the program, as it will be hundreds of thousands of lines of code, just declaring variables that I could easily auto-name..).

-DoctorPC

Product Version: Not Selected
Tags:
more ▼

asked Jul 29 '14 at 02:46 PM in C++ Programming

avatar image

DoctorPC
398 44 39 51

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You're planning to write a program that writes code that represents the voxel field? I wouldn't go down that route, it wont scale and it wont allow you the freedom to have arbitrary level data. Instead generate a file representing the data to load for your voxel levels. At runtime when you load the file, you can use a memory efficient structure to store the voxel data read from the file. I would recommend googling Sparse Voxel Octree. Alternatively, you could use a Spatial Hash, and just have uniform grid of sectors of some standard size, like 128^3 voxels. Then with either of those options you can eliminate needing to store in memory whole sectors of data with no blocks in them.

Cheers, Nick

more ▼

answered Jul 29 '14 at 03:01 PM

avatar image

Nick Darnell ♦♦ STAFF
6k 77 37 151

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question