public Grid_Placement_Info get_Info(Geometry_Container c) { var ret = new Grid_Placement_Info(); var aabb = c._AABB; ret.coords = Spatial.Grid_Func.Grid_Coords(aabb.Position, grid_info.Cellsize); var widths = Spatial.Grid_Func.Find_Width_In_Cells(grid_info.Cellsize, aabb.Position, aabb.widthx, aabb.widthy); ret.row_width = widths.row_width; ret.col_width = widths.col_width; ret.own_group = Base_Collision_Batches.Collision_Group_Slot[c.Collision_Type]; ret.groups_it_hits = Base_Collision_Batches.what_groups_each_group_collides_with[ret.own_group];// Multiple_Dispatch.Check_With_Whom[c.Collision_Type]; return(ret); }
public void Insert(int col, int row, Geometry_Container gc) { buckets[get_Bucket_Index(col, row)].Add(new Stored_Geometrical_Piece(gc, col, row)); }
public Stored_Geometrical_Piece(Geometry_Container g, int col, int row) { this.col = col; this.row = row; this.g = g; }
public void InsertCollidable(Collidable c) { if (c.Spawning_Or_Hit) return; for (int piece_i = 0; piece_i < c.Rigid.Geometries.Count; piece_i++) { Grid_Query_Counter.Counter++; var piece = c.Rigid.Geometries[piece_i]; var placement = piece.placement; if (placement.own_group >= 2) { placement.row_width = 1; placement.col_width = 1; } int border = placement.own_group < 2 ? 1 : 0; for (int group_i = 0; group_i < placement.groups_it_hits.Length; group_i++) for (int i = -border; i < placement.row_width + border; i++)//ta width xekinane me 1 for (int j = -border; j < placement.col_width + border; j++) { var list = grids[placement.groups_it_hits[group_i]].getBucket(placement.coords.col + j, placement.coords.row + i); for (int u = 0; u < list.Count; u++) { if (!((list[u].row == placement.coords.row + i) && (list[u].col == placement.coords.col + j))) continue; var other = list[u].g; current_pair_element_1 = piece; current_pair_element_2 = other; if ((other.Coll.Ignore_In_Collisions_Cause_It_Got_Killed) || (other.Coll.Spawning_Or_Hit) || other.Coll == piece.Coll) continue; if (other.Last_Query < Grid_Query_Counter.Counter) { other.Last_Query = Grid_Query_Counter.Counter; var dispatcher = Dispatcher.Dispatch_array[piece.Collision_Type, other.Collision_Type]; var coarse_test = dispatcher.Coarse_Test; if(coarse_test==null) { continue; } var check_coarse = dispatcher.rever_coarse?coarse_test(other, piece):coarse_test(piece, other); if(!check_coarse) { continue; } var test_call = dispatcher.Test; if (test_call != null) { var test_result = dispatcher.rever_test? test_call( other,piece): test_call(piece, other); if (test_result) { piece.Coll.Intersecting.Add(other.Coll); other.Coll.Intersecting.Add(piece.Coll); if (dispatcher.kill_first) piece.Ignore_In_Collisions_Cause_It_Got_Killed = true; if (dispatcher.kill_second) other.Ignore_In_Collisions_Cause_It_Got_Killed = true; if (dispatcher.kill_first) return; if (dispatcher.kill_second) continue; } } var intersect_call = dispatcher.I_Test; if (intersect_call != null) { var intersect_call_result = dispatcher.rever_intersect? intersect_call( other,piece): intersect_call(piece, other); if (intersect_call_result) { piece.Coll.Contacted.Add(other.Coll); other.Coll.Contacted.Add(piece.Coll); } } } } } //do not store enemies in the grid, only test them against existing geometry if (placement.own_group < 2) for (int i = -1; i < placement.row_width + 1; i++) for (int j = -1; j < placement.col_width + 1; j++) { grids[placement.own_group].Insert(placement.coords.col + i, placement.coords.row + j, piece); } } return; }
public Grid_Placement_Info get_Info(Geometry_Container c) { var ret = new Grid_Placement_Info(); var aabb = c._AABB; ret.coords = Spatial.Grid_Func.Grid_Coords(aabb.Position, grid_info.Cellsize); var widths = Spatial.Grid_Func.Find_Width_In_Cells(grid_info.Cellsize, aabb.Position, aabb.widthx, aabb.widthy); ret.row_width = widths.row_width; ret.col_width = widths.col_width; ret.own_group = Base_Collision_Batches.Collision_Group_Slot[c.Collision_Type]; ret.groups_it_hits = Base_Collision_Batches.what_groups_each_group_collides_with[ret.own_group];// Multiple_Dispatch.Check_With_Whom[c.Collision_Type]; return ret; }
public void Insert(int col, int row, Geometry_Container gc) { buckets[get_Bucket_Index(col, row)].Add(new Stored_Geometrical_Piece(gc, col, row)); }
public Stored_Geometrical_Piece(Geometry_Container g, int col, int row) { this.col = col; this.row = row; this.g = g; }