Code Help

is there anything less memory consuming than this: typedef struct color { uint8_t R; uint8_t G; uint8_t B; } typedef struct Voxel { PxMaterial mVmat; bool vxl_mask[4096]; color vxl_color[4096]; };

Note: im useing PhysX API

Reply to
braden nelson
Loading thread data ...

The vxl_mask tells what cubes are visible (the invisible ones aren't created)

Reply to
braden nelson

Why, yes. Comment it all out.

That's probably not what you're looking for.

On many machines, bool is as big as int. Making your mask out of uint8 should reduce the size of that part by at least a factor of two -- four on a 32-bit machine. Making it into a bitfield should reduce the size by another factor of eight, at the cost of more processing to extract the right bit.

--

Tim Wescott 
Wescott Design Services 
http://www.wescottdesign.com
Reply to
Tim Wescott

Fold vxl_mask *into* vxl_color. (unless "color" is a particular data type in itself that can exist in the absence of "mask"s).

"color"s will almost surely get packed (aligned) into 32b quantities (whether those are ints, longs, etc. on your platform). As such, there are 8 "wasted bits" in each "color".

To make this more explicit, you could think of a bitfield that represents: RRRRRRRRGGGGGGGGBBBBBBBB-------M

Reply to
Don Y

thanks for the help

-- The creator of World Juno

Reply to
braden nelson

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.