/*
 * Copyright (c) 2008-2009 Bill Whitacre http://rampancy.g0dsoft.com
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
*/

#ifndef RAT_PHYSICS_BODY_MANAGER_ARRAY_TABLE
#define RAT_PHYSICS_BODY_MANAGER_ARRAY_TABLE

#include "common.h"
#include "body_manager.h"

typedef struct rat_body_manager_array_table
{
	rat_body_manager_type type;
	rat_body_manager_class *clas;

	struct rat_world *world_ref;

	unsigned int numbods;
	unsigned int numbodsrmv;
	unsigned int numbodsrmvdel;
	unsigned int numstatic;
	unsigned int numdynamic;
	unsigned int numarbs,maxarbs;

	rat_body **bodies;
	rat_body **bodiestoremove;
	rat_body **bodiestodel;
	rat_arbiter **arbiters;

	rat_body **static_bodies;
	rat_body **dynamic_bodies;
} rat_body_manager_array_table;

#ifdef __cplusplus
extern "C" {
#endif

rat_body_manager *rat_body_manager_array_table_create(struct rat_world *world_ref);
void rat_body_manager_array_table_destroy(rat_body_manager *table);
void rat_body_manager_array_table_add_body(rat_body_manager *table,rat_body *body);
void rat_body_manager_array_table_remove_body(rat_body_manager *table,rat_body *body);
void rat_body_manager_array_table_remove_and_destroy_body(rat_body_manager *table,rat_body *body);
void rat_body_manager_array_table_clear_bodies(rat_body_manager *table);
void rat_body_manager_array_table_free_bodies(rat_body_manager *table);

void rat_body_manager_array_table_build_spatial_index(rat_body_manager *table);
void rat_body_manager_array_table_collide_bodies(rat_body_manager *table);

unsigned int rat_body_manager_array_table_count_all_bodies(rat_body_manager *table);
unsigned int rat_body_manager_array_table_count_static_bodies(rat_body_manager *table);
unsigned int rat_body_manager_array_table_count_dynamic_bodies(rat_body_manager *table);
unsigned int rat_body_manager_array_table_count_arbiters(rat_body_manager *table);

rat_iterator *rat_body_manager_array_table_all_bodies_iterator(rat_body_manager *table);
rat_iterator *rat_body_manager_array_table_static_bodies_iterator(rat_body_manager *table);
rat_iterator *rat_body_manager_array_table_dynamic_bodies_iterator(rat_body_manager *table);
rat_iterator *rat_body_manager_array_table_arbiters_iterator(rat_body_manager *table);

#ifdef __cplusplus
};
#endif

#endif
