Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3722572
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:57:13+00:00 2026-05-19T05:57:13+00:00

I have a rendering application that renders lots and lots of cubes in a

  • 0

I have a rendering application that renders lots and lots of cubes in a 3-dimensional grid. This is inherently inefficient as each cube represents 4 vertices, and often the cubes are adjacent, creating one surface that could be represented by a single rectangle.

To populate the area I use a 3-dimensional array, where a value of 0 denotes empty space and a non-0 value denotes a block.

e.g. (where X denotes where a cube would be placed)

OOOXXXOOOO
OOXXXXXXXO
OOXXXXXXXO
OOXXXXOOOO

would currently be represented as 21 cubes, or 252 triangles, whereas it could easily be represented as (where each letter denotes a part of a rectangle)

OOOAAAOOOO
OOBAAACCCO
OOBAAACCCO
OOBAAAOOOO

which is a mere 3 rectangles, or 26 triangles.

The typical size of these grids is 128x128x128, so it’s clear I would benefit from a massive performance boost if I could efficiently reduce the shapes to the fewest rectangles possible in a reasonable amount of time, but I’m stuck for ideas for an algorithm.

Using Dynamic programming – Largest square block would be one option, but it wouldn’t result in an optimal answer, although if the solution is too complex to perform efficiently then this would have to be the way to go.

Eventually I will have multiple types of cubes (e.g. green, brown, blue, referenced using different non-0 numbers in the array) so if possible a version that would work with multiple categories would be very helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:57:14+00:00Added an answer on May 19, 2026 at 5:57 am

    Maybe something “octree” like:

    Build a 64x64x64 grid over your 128x128x128 grid so each cell of the first grid “contains” height cells of the second.

    For each cell, of the 64x64x64 grid, proceed like that:

    • If the height contained cells have the same value, put that value in the 64x64x64 grid.
    • Else draw each cell individually and put -1 in the 64x64x64 grid.

    Now build a 32x32x32 grid over the 64x64x64 one and repeat.

    Then 16x16x16, 8x8x8, 4x4x4, 2x2x2, 1x1x1 and you’re done 🙂

    Of course, it would be best if the octree was computed once and for all, not for each rendering operation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing the application that uses DirectX for graphics rendering. I have to
We have a client side application (Java/Swing) that we need an HTML rendering control
I have a UserControl that is part of my application, I am rendering it
I have a application that uses the Aero glass effect, so each pixel has
I have a WPF application that runs as a service and renders 2D graphical
I have a Mac OS X server application that renders NSViews and returns them
In an MVC3 application I have a view rendering two Ajax partial views: a
The documentation implies that you can either have 3D rendering or framebuffer mode, and
I have a UIView that I am rendering a UIBezierPath in based on touchesBegan
I have an ASP.NET application that uses themes. Let's pretend I have a theme

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.