|
From: Roger H. <rog...@mi...> - 2007-02-14 12:50:45
|
On 13 Feb, 2007, at 23:49, James Walker wrote: > In the renderers, I'm using a custom element to cache an optimized > version of a TriMesh. The element contains an edit index along > with the > TriMesh reference, so that a stale cache can be detected. That works > fine in principle, though there's a bug at the moment. > > But now suppose I have another similar custom element, say to cache a > triangle strip. When I update the triangle strip, it bumps the edit > index, so the other cache becomes stale. Which causes the other cache > to get updated, bumping the edit index, which makes the triangle cache > stale... > > How can I get out of this infinite loop? The simplest way, I suppose, > would be to add a Q3Shared_SetEditIndex function, and use it when > setting these cache elements. Is there a more elegant way I haven't > thought of? > -- I don't exactly understand what you are trying to do. You have an object A which has two caches B and C, both of which hold the edit index of A. Why would updating B or C update the edit index of A? Or is C a cache of B? If so, C holds the edit indexes of A and B. If A gets changed, its edit index gets modified. When you need C it checks both edit indexes, if A's has changed it forces B to recache then recaches itself. If you need B first then it recaches itself and when you need C it finds both indexes are stale, so gives B a chance to recache (which it decided not to do as its edit index for A is still fresh), and then C recaches itself. Roger. |