예제 #1
0
// call BLI_bvhtree_update_node() first for every node/point/triangle
void BLI_bvhtree_update_tree(BVHTree *tree)
{
	//Update bottom=>top
	//TRICKY: the way we build the tree all the childs have an index greater than the parent
	//This allows us todo a bottom up update by starting on the biger numbered branch

	BVHNode** root  = tree->nodes + tree->totleaf;
	BVHNode** index = tree->nodes + tree->totleaf + tree->totbranch-1;

	for (; index >= root; index--)
		node_join(tree, *index);
}
예제 #2
0
파일: node.c 프로젝트: hydra/freewpc
/* Initialize the node graph for this machine.
	This creates the nodes that match the topology of the game, using
	some of the machine-specific parameters to guide things.
	Last, the ball trough is populated with all of the pinballs. */
void node_init (void)
{
    unsigned int i;

    /* Create nodes for all playfield switches.  Not all of these will
    be used necessarily.  The default is for all switches to drain to the
    open playfield.  The switch will remain active for 100ms before it moves. */
    for (i=0; i < NUM_SWITCHES; i++)
    {
        struct ball_node *node = switch_nodes + i;
        node->name = names_of_switches[i];
        node->type = &switch_type_node;
        node->index = i;
        node->unlocked = 1;
        node->size = 1;
        node_join (node, &open_node, 100);
    }

    /* Create nodes for the ball devices.  Trough leads to shooter;
    everything else leads to the open playfield as for the switches. */
    for (i=0; i < MAX_DEVICES; i++)
    {
        device_nodes[i].type = &device_type_node;
        device_nodes[i].index = i;
        device_nodes[i].size = device_properties_table[i].sw_count;
        device_nodes[i].name = device_properties_table[i].name;
        device_nodes[i].unlocked = 0;
#if defined(DEVNO_TROUGH) && defined(MACHINE_SHOOTER_SWITCH)
        if (i == DEVNO_TROUGH)
            node_join (&device_nodes[i], &shooter_node, 50);
        else
#endif
            node_join (&device_nodes[i], &open_node, 0);
    }

    /* The outhole and the shooter switches, initialized above, can
    actually hold more pinballs than 1; they just queue up undetected.
    They are also unlocked, meaning that they stay there until something
    forces them to move on. */
#ifdef MACHINE_OUTHOLE_SWITCH
    outhole_node.size = MAX_BALLS_PER_NODE;
    outhole_node.unlocked = 0;
    node_join (&outhole_node, &trough_node, 100);
#endif
#ifdef MACHINE_SHOOTER_SWITCH
    shooter_node.size = MAX_BALLS_PER_NODE;
    shooter_node.unlocked = 0;
    node_join (&shooter_node, &open_node, 0);
#endif

    /* Initialize the open playfield node, which feeds into the trough
    (or outhole if present). */
    open_node.name = "Playfield";
    open_node.type = &open_type_node;
    open_node.size = MAX_BALLS_PER_NODE;
    open_node.unlocked = 0;
#ifdef drain_node
    node_join (&open_node, &drain_node, 0);
#endif

    /* Fixup the graph in a machine-specific way */
#ifdef CONFIG_MACHINE_SIM
    mach_node_init ();
#endif

#ifdef DEVNO_TROUGH
    /* Create the pinballs and dump them into the trough.
    	Actually, we dump them onto the playfield and force them to drain.
    	This lets us install more balls than the trough can hold, as if
    	you just dropped them onto the playfield. */
    for (i=0; i < sim_installed_balls; i++)
    {
        the_ball[i].node = NULL;
        strcpy (the_ball[i].name, "Ball X");
        the_ball[i].name[5] = i + '0';
        the_ball[i].index = i;
        the_ball[i].flags = 0;

        node_insert (&open_node, &the_ball[i]);
        node_kick (&open_node);
    }
#endif
}