minecraft-renderObj icon indicating copy to clipboard operation
minecraft-renderObj copied to clipboard

Optimization idea

Open arpruss opened this issue 10 years ago • 4 comments

I was rendering a very large Deep Space 9 model, and it was hanging. I ended up optimizing your rendering script's Minecraft class as follows, and inserting a call to draw() after all the drawing was done. This puts all the block positions in a dictionary, which avoids the load on Minecraft from drawing multiple blocks in the same position.

def __init__(self, mc):
    self.mc = mc
    self.data = {}

def draw(self):
    for key in self.data:
         d = self.data[key]
         mc.setBlock(key[0],key[1],key[2],d[0],d[1])

# draw point
def drawPoint3d(self, x, y, z, blockType, blockData=None):
    #self.mc.setBlock(x,y,z,blockType,blockData)
    self.data[int(x),int(y),int(z)] = [blockType,blockData]
    #print "x = " + str(x) + ", y = " + str(y) + ", z = " + str(z)

arpruss avatar Apr 22 '15 00:04 arpruss

It looks like a sensible change to pre-process the blocks which need changing before changing them.

Any chance you could send me a pull request?

martinohanlon avatar Apr 22 '15 14:04 martinohanlon

Sorry: I don't know enough about git to know what exactly that means.

arpruss avatar Apr 22 '15 14:04 arpruss

Its pretty simple. If you fork my repository, make your changes to that repository you can then send me a request which says "pull this change - I think it should go into the main position". Or I could pull the change from your repository.

martinohanlon avatar Apr 22 '15 14:04 martinohanlon

OK, done that, both for this issue and for my other one. My repository is https://github.com/arpruss/minecraft-renderObj

arpruss avatar Apr 23 '15 01:04 arpruss