Revision: 41532
http://brlcad.svn.sourceforge.net/brlcad/?rev=41532&view=rev
Author: erikgreenwald
Date: 2010-12-07 14:00:50 +0000 (Tue, 07 Dec 2010)
Log Message:
-----------
remove old cache stuff
Modified Paths:
--------------
brlcad/branches/bottie/src/librt/primitives/bot/tie_kdtree.c
Modified: brlcad/branches/bottie/src/librt/primitives/bot/tie_kdtree.c
===================================================================
--- brlcad/branches/bottie/src/librt/primitives/bot/tie_kdtree.c
2010-12-07 13:09:44 UTC (rev 41531)
+++ brlcad/branches/bottie/src/librt/primitives/bot/tie_kdtree.c
2010-12-07 14:00:50 UTC (rev 41532)
@@ -124,70 +124,6 @@
}
}
-static void tie_kdtree_cache_free_node(tie_t *tie, tie_kdtree_t *node, void
**cache, uint32_t *size, uint32_t *mem)
-{
- tie_kdtree_t *node_aligned = (tie_kdtree_t *)((intptr_t)node & ~0x7L);
- uint32_t tri_num, i, tri_ind;
- uint8_t type, split;
-
-/*
- * If the available size for this cache is under 1MB, then grow it 4MB larger.
- * This reduces the number of bu_realloc's required. Makes things much much
faster
- * on systems like FreeBSD that do a full copy for each bu_realloc.
- */
- if (*mem - *size < 1<<20)
- {
- (*mem) += 1<<23;
- *cache = bu_realloc(*cache, *mem, __FUNCTION__);
- }
-
- if (((intptr_t)(node_aligned->data)) & 0x4)
- {
-/* Create a KD-Tree Node in the cache */
- type = 0;
- TCOPY(uint8_t, &type, 0, *cache, *size);
- (*size) += 1;
-
- TCOPY(tfloat, &(node_aligned->axis), 0, *cache, *size);
- (*size) += sizeof(tfloat);
-
- split = ((intptr_t)(node_aligned->data)) & 0x3;
- TCOPY(uint8_t, &split, 0, *cache, *size);
- (*size) += 1;
-
-/* Node Data is KDTREE Children, Recurse */
- tie_kdtree_cache_free_node(tie, &((tie_kdtree_t
*)(((intptr_t)(node_aligned->data)) & ~0x7L))[0], cache, size, mem);
- tie_kdtree_cache_free_node(tie, &((tie_kdtree_t
*)(((intptr_t)(node_aligned->data)) & ~0x7L))[1], cache, size, mem);
- bu_free((void *)((intptr_t)(node_aligned->data) & ~0x7L), __FUNCTION__);
- }
- else
- {
- type = 1;
- TCOPY(uint8_t, &type, 0, *cache, *size);
- (*size) += 1;
-
- tri_num = ((tie_geom_t *)((intptr_t)(node_aligned->data) &
~0x7L))->tri_num;
-
- TCOPY(uint32_t, &tri_num, 0, *cache, *size);
- (*size) += sizeof(uint32_t);
-
- for (i = 0; i < tri_num; i++)
- {
-/*
- * Pointer subtraction gives us the index of the triangle since the block of
memory
- * that the triangle exists in is contiguous memory.
- */
- tri_ind = ((tie_geom_t *)((intptr_t)(node_aligned->data) &
~0x7L))->tri_list[i] - &tie->tri_list[0];
- TCOPY(uint32_t, &tri_ind, 0, *cache, *size);
- (*size) += sizeof(uint32_t);
- }
-
-/* This node points to a geometry node, free it */
- bu_free(((tie_geom_t *)((intptr_t)(node_aligned->data) &
~0x7L))->tri_list, __FUNCTION__);
- bu_free((void *)((intptr_t)(node_aligned->data) & ~0x7L), __FUNCTION__);
- }
-}
-
static void tie_kdtree_prep_head(tie_t *tie, tie_tri_t *tri_list, unsigned int
tri_num)
{
tie_geom_t *g;
@@ -782,126 +718,6 @@
bu_free(tie->kdtree, "kdtree");
}
-uint32_t TIE_VAL(tie_kdtree_cache_free)(tie_t *tie, void **cache)
-{
- uint32_t size, mem;
-
-/*
- * Free KDTREE Node
- * Prevent tie from crashing when a tie_free() is called right after a
tie_init()
- */
- if (!tie->kdtree)
- return 0;
-
- *cache = NULL;
- size = 0;
- mem = 0;
-
-/* Build the cache */
- tie_kdtree_cache_free_node(tie, tie->kdtree, cache, &size, &mem);
-
-/* Resize the array back to it's real value */
- /* TODO: examine if this is correct. A 0 re-alloc is probably a very bad
- * thing. */
- if( size == 0 ) {
- bu_free (*cache, "freeing unused cache");
- *cache = NULL;
- } else
- *cache = bu_realloc(*cache, size, "cache");
-
- bu_free(tie->kdtree, "kdtree");
- tie->kdtree = NULL;
-
- return size;
-}
-
-void TIE_VAL(tie_kdtree_cache_load)(tie_t *tie, void *cache, uint32_t size)
-{
- tie_kdtree_t *node = 0, *temp_node = 0, *stack[64];
- tie_geom_t *geom = 0;
- TIE_3 min, max;
- uint32_t i, index = 0, tri_ind = 0, stack_ind = 0;
- uint8_t type = 0, split;
-
-
- if (!cache)
- return;
-
- while (index < size) {
- TCOPY(uint8_t, cache, index, &type, 0);
- index += 1;
-
- if (type) {
-/* Geometry Node - Allocate a tie_geom_t and assign to node->data. */
- node->data = bu_malloc(sizeof(tie_geom_t), "cache node data");
- geom = (tie_geom_t *)node->data;
-
- TCOPY(uint32_t, cache, index, &(geom->tri_num), 0);
- index += sizeof(uint32_t);
-
- if(geom->tri_num <= 0)
- geom->tri_list = NULL;
- else
- geom->tri_list = (tie_tri_t **)bu_malloc(geom->tri_num *
sizeof(tie_tri_t *), "cache geom tri_list");
-
- for (i = 0; i < geom->tri_num; i++) {
- TCOPY(uint32_t, cache, index, &tri_ind, 0);
- index += sizeof(uint32_t);
-
-/* Translate the numerical index to a pointer index into tie->tri_list. */
- geom->tri_list[i] = &tie->tri_list[0] + tri_ind;
- }
-
- if (stack_ind) {
- stack_ind--;
- node = stack[stack_ind];
- }
- } else {
-/* KD-Tree Node */
- if (!tie->kdtree) {
- tie->kdtree = (tie_kdtree_t *)bu_malloc(sizeof(tie_kdtree_t),
"cache kdtree");
- node = tie->kdtree;
- }
-
-/* Assign splitting axis value */
- TCOPY(tfloat, cache, index, &node->axis, 0);
- index += sizeof(tfloat);
-
-/* Get splitting plane */
- TCOPY(uint8_t, cache, index, &split, 0);
- index += 1;
-
-/* Allocate memory for 2 child nodes */
- node->data = bu_malloc(2 * sizeof(tie_kdtree_t), "kdtree node
data");
-
-/* Push B on the stack and Process A */
- stack[stack_ind] = &((tie_kdtree_t *)node->data)[1];
- stack_ind++;
-
-/* Set the new current node */
- temp_node = node;
- node = &((tie_kdtree_t *)node->data)[0];
-
-/*
- * Mask the splitting plane and mark it as a kdtree node
- * using the lower bits of the ptr.
- */
- temp_node->data = (void *)((intptr_t)(temp_node->data) + split + 4);
- }
- }
-
-/* form bounding box of scene */
- MATH_BBOX(tie->min, tie->max, tie->tri_list[0].data[0],
tie->tri_list[0].data[1], tie->tri_list[0].data[2]);
- for (i = 0; i < tie->tri_num; i++) {
-/* Get Bounding Box of Triangle */
- MATH_BBOX(min, max, tie->tri_list[i].data[0], tie->tri_list[i].data[1],
tie->tri_list[i].data[2]);
-
-/* Check to see if defines a new Max or Min point */
- MATH_VEC_MIN(tie->min, min);
- MATH_VEC_MAX(tie->max, max);
- }
-}
-
void TIE_VAL(tie_kdtree_prep)(tie_t *tie)
{
TIE_3 delta;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits