From ae914d0b813dd7e9da9f2c12be2ebc57c708cf68 Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Sun, 12 Jun 2011 20:20:36 -0400 Subject: [PATCH] Fix some animation bugs --- cuburn/_pyflam3_hacks.py | 5 ++++- cuburn/render.py | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cuburn/_pyflam3_hacks.py b/cuburn/_pyflam3_hacks.py index d98a474..0489ada 100644 --- a/cuburn/_pyflam3_hacks.py +++ b/cuburn/_pyflam3_hacks.py @@ -11,7 +11,7 @@ this may become unnecessary. """ from ctypes import * -from fr0stlib.pyflam3 import constants +from fr0stlib.pyflam3 import constants, _flam3 from fr0stlib.pyflam3._flam3 import * from cuburn import render @@ -170,3 +170,6 @@ BaseXForm._fields_ = [('var', c_double * flam3_nvariations) # It seems I'm missing something in the current version. , ('mysterious_padding', c_double * 2) ] +libflam3.flam3_align.argtypes = [POINTER(BaseGenome), POINTER(BaseGenome), c_int] +flam3_align = libflam3.flam3_align + diff --git a/cuburn/render.py b/cuburn/render.py index ee0c9c1..8d05038 100644 --- a/cuburn/render.py +++ b/cuburn/render.py @@ -1,6 +1,7 @@ import sys import math import re +import time from itertools import cycle, repeat, chain, izip from ctypes import * from cStringIO import StringIO @@ -85,8 +86,9 @@ class Animation(object): interpolated sequence between one or two genomes. """ def __init__(self, ctypes_genome_array): - self._g_arr = ctypes_genome_array - self.genomes = map(Genome, ctypes_genome_array) + self._g_arr = type(ctypes_genome_array)() + libflam3.flam3_align(self._g_arr, ctypes_genome_array, len(ctypes_genome_array)) + self.genomes = map(Genome, self._g_arr) self.features = Features(self.genomes) self._iter = self._de = self.src = self.cubin = self.mod = None @@ -165,7 +167,7 @@ class Animation(object): # Zip up each genome with an alternating renderer, plus enough empty # genomes at the end to flush all pending tasks - times = times or [cp.time for cp in self.genomes] + times = times if times is not None else [cp.time for cp in self.genomes] exttimes = chain(times, repeat(None, NRENDERERS)) for rdr, time in izip(cycle(rdrs), exttimes): if rdr.wait(): @@ -374,7 +376,7 @@ class _AnimRenderer(object): @staticmethod def _mk_dts(cen_time, cen_cp, ncps): w = cen_cp.temporal_filter_width - return [w * (t / (ncps - 1.0) - 0.5) for t in range(ncps)] + return [cen_time + w * (t / (ncps - 1.0) - 0.5) for t in range(ncps)] class Features(object): """ @@ -413,8 +415,8 @@ class Features(object): self.xforms = [XFormFeatures([cp.xforms[i] for cp in genomes], i) for i in range(self.nxforms)] if any(lambda cp: cp.final_xform_enable): - if not reduce(lambda a, b: a == b, - [cp.final_xform_index for cp in genomes]): + if not all([cp.final_xform_index == genomes[0].final_xform_index + for cp in genomes]): raise ValueError("Differing final xform indexes") self.final_xform_index = genomes[0].final_xform_index else: