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. 

Local Varibles not been correct.

Hi all,

I am writing a voxel engine and I require a function to perform a calculation to work out the centre of a cube. To that end I have this function in my UUBlock Class written in C++.

 void UUBlock::Blockdata(AChunk* chunk, INT32 X, INT32 Y, INT32 Z, TArray<FMeshDataTriangle>& Triangles)
     this->BlockCenter.X = (float)((float)X*chunk->BlockSize) + chunk->BlockSizeHalf;
     this->BlockCenter.Y = (float)((float)Y*chunk->BlockSize) + chunk->BlockSizeHalf;
     this->BlockCenter.Z = (float)((float)Z*chunk->BlockSize) + chunk->BlockSizeHalf;

when I call this method with a know BlockSize and BlockSizeHalf and know my X, Y, Z parameters.

my BlockCenter.X / BlockCenter.Y & BlockCenter.Z or always 0

which is rubbish when I have X = 5, BlockSize = 100 & BlockSizeHalf = 50

in this case BlockCenter.X should be 550.

Can someone please Advise as I am having these issues in serveral places in my code I don't understand why simple Maths isn't working.

Thanks for any advise or pointers.

Product Version: Not Selected
more ▼

asked Apr 03 '15 at 11:55 AM in C++ Programming

avatar image

6 1 2

avatar image Apr 03 '15 at 01:13 PM

You are setting BlockCenter.X twice and never BlockCenter.Z

When you break on line 6 in your function are every variable values right according to what you are expecting ? (check chunk member values, it seems that everything is 0 in your chunk)

avatar image ToxicBlotch Apr 03 '15 at 01:47 PM

The Variables that are passed in are what I am expecting. It's the results that should be getting stored in the BlockCenter FVector that aren't correct.

And i am literal at my wits end trying to understand why.

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

0 answers: sort voted first
Be the first one to answer this question
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