static __inline__ Uint32 dynamic_aabb_is_in_node(BBOX_TREE *bbox_tree, Uint32 node, Uint32 ID, Uint32 type_mask) { Uint32 i, result; Uint32 id; result = 0; for (i = 0; i < bbox_tree->nodes[node].dynamic_objects.index; i++) { if ((type_mask == TYPE_MASK_3D_BLEND_SELF_LIT_OBJECT) || (type_mask == TYPE_MASK_3D_BLEND_NO_SELF_LIT_OBJECT) || (type_mask == TYPE_MASK_3D_NO_BLEND_SELF_LIT_OBJECT) || (type_mask == TYPE_MASK_3D_NO_BLEND_NO_SELF_LIT_OBJECT)) id = get_3dobject_index(bbox_tree->nodes[node].dynamic_objects.items[i].ID); else id = bbox_tree->nodes[node].dynamic_objects.items[i].ID; if ((id == ID) && (get_type_mask_from_type(bbox_tree->nodes[node].dynamic_objects.items[i].type) == type_mask)) { delete_dynamic_item_from_node(bbox_tree, node, i, ID, type_mask); result = 1; } } return result; }
static __inline__ void delete_item_from_intersect_list(BBOX_TREE* bbox_tree, Uint32 ID, Uint32 type_mask) { Uint32 i, j, k, size; int start, stop; Uint32 id; for (i = 0; i < MAX_INTERSECTION_TYPES; i++) { for (j = 0; j < TYPES_COUNT; j++) { if (type_mask != get_type_mask_from_type(j)) continue; start = bbox_tree->intersect[i].start[j]; stop = bbox_tree->intersect[i].stop[j]; for (k = start; k < stop; k++) { if ((type_mask == TYPE_MASK_3D_BLEND_SELF_LIT_OBJECT) || (type_mask == TYPE_MASK_3D_BLEND_NO_SELF_LIT_OBJECT) || (type_mask == TYPE_MASK_3D_NO_BLEND_SELF_LIT_OBJECT) || (type_mask == TYPE_MASK_3D_NO_BLEND_NO_SELF_LIT_OBJECT)) id = get_3dobject_index(bbox_tree->intersect[i].items[k].ID); else id = bbox_tree->intersect[i].items[k].ID; if (id == ID) { size = stop - k -1; if (size > 0) memmove(&bbox_tree->intersect[i].items[k], &bbox_tree->intersect[i].items[k+1], size*sizeof(BBOX_ITEM)); bbox_tree->intersect[i].stop[j]--; stop--; k--; } } } } }
void draw_3d_objects(unsigned int object_type) { unsigned int start, stop; unsigned int i, l; int is_selflit, is_transparent, is_ground; #ifdef SIMPLE_LOD int x, y, dist; #endif #ifdef CLUSTER_INSIDES_OLD short cluster = get_actor_cluster (); #endif #ifdef SIMPLE_LOD x= -camera_x; y= -camera_y; #endif cur_e3d= NULL; #ifdef DEBUG cur_e3d_count= 0; #endif //DEBUG get_intersect_start_stop(main_bbox_tree, object_type, &start, &stop); // nothing to draw? if(start >= stop){ return; } // reduce CPU usage while minimized if(!(SDL_GetAppState()&SDL_APPACTIVE)){ // not actually drawing, fake it // now loop through each object for (i=start; i<stop; i++) { int j; j = get_intersect_item_ID(main_bbox_tree, i); l = get_3dobject_index(j); if (objects_list[l] == NULL) continue; //track the usage cache_use(objects_list[l]->e3d_data->cache_ptr); } // and all done return; } // find the modes we need is_selflit= is_self_lit_3d_object(object_type); is_transparent= is_alpha_3d_object(object_type); is_ground= is_ground_3d_object(object_type); // set the modes we need if (is_selflit && (!is_day || dungeon)) { glDisable(GL_LIGHTING); } #ifdef FSAA if (fsaa > 1) { glEnable(GL_MULTISAMPLE); } #endif /* FSAA */ if(is_transparent) { #ifdef NEW_ALPHA if(use_3d_alpha_blend){ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); } #endif //NEW_ALPHA //enable alpha filtering, so we have some alpha key glEnable(GL_ALPHA_TEST); if(is_ground)glAlphaFunc(GL_GREATER,0.23f); #ifdef OLD_MISC_OBJ_DIR else glAlphaFunc(GL_GREATER,0.06f); #else else glAlphaFunc(GL_GREATER,0.3f); #endif glDisable(GL_CULL_FACE); }