MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / check_terrain_node

Function check_terrain_node

physics/findintersection.cpp:3797–4106  ·  view source on GitHub ↗

void DoLinearApprox(vector *collision_point, vector *collision_normal, float *hit_dist, float *hit_interval, vector *movement_dir, vector *p0, object *obj, int nv, vector **vertex_ptr_list, vector *face_normal) { vector end_pos; bool hit; *hit_interval /= 2.0f; end_pos = *p0 + ((*hit_interval + *hit_dist)* *movement_dir); float frametime = fvi_query_ptr->f

Source from the content-addressed store, hash-verified

3795// checks for collisions within a given terrain node (fvi_sub minus the recursiveness).
3796// If f_check_local_nodes is set, it will look in surrounding nodes.
3797inline void check_terrain_node(int cur_node, bool f_check_local_nodes, bool f_check_ground) {
3798 vector hit_point;
3799 float cur_dist;
3800 int check_x, check_y;
3801 int tercheck_x, tercheck_y;
3802 int new_node;
3803 int xcounter, ycounter;
3804 int xstart, xend;
3805 int ystart, yend;
3806 int terxstart, terxend;
3807 int terystart, teryend;
3808 int i;
3809 int objnum;
3810 bool f_check_next_ground;
3811 object *this_obj;
3812
3813 if (fvi_query_ptr->thisobjnum >= 0)
3814 this_obj = &Objects[fvi_query_ptr->thisobjnum];
3815 else
3816 this_obj = nullptr;
3817
3818 // Object checks
3819 if ((fvi_terrain_obj_visit_list[cur_node >> 3] & (0x01 << (cur_node % 8))) == 0) {
3820 ASSERT(cur_node >= 0 && cur_node < TERRAIN_WIDTH * TERRAIN_DEPTH);
3821 ASSERT(fvi_num_cells_obj_visited < MAX_CELLS_VISITED);
3822 fvi_terrain_obj_visit_list[cur_node >> 3] |= 0x01 << (cur_node % 8);
3823 fvi_cells_obj_visited[fvi_num_cells_obj_visited] = cur_node;
3824 fvi_num_cells_obj_visited++;
3825
3826 if (fvi_query_ptr->flags & FQ_CHECK_OBJS) {
3827 for (objnum = Terrain_seg[cur_node].objects; objnum != -1; objnum = Objects[objnum].next) {
3828 ASSERT(objnum != -1);
3829 if (!(Objects[objnum].flags & OF_BIG_OBJECT))
3830 check_hit_obj(objnum);
3831 }
3832 } else {
3833
3834 if (!(fvi_query_ptr->flags & FQ_IGNORE_EXTERNAL_ROOMS))
3835 for (objnum = Terrain_seg[cur_node].objects; objnum != -1; objnum = Objects[objnum].next) {
3836 ASSERT(objnum != -1);
3837 if ((Objects[objnum].type == OBJ_ROOM) && !(Objects[objnum].flags & OF_BIG_OBJECT))
3838 check_hit_obj(objnum);
3839 }
3840 }
3841 }
3842
3843 // Terrain node checks
3844 if (f_check_ground) {
3845 int lod_x = (cur_node % TERRAIN_WIDTH) >> 2;
3846 int lod_z = (cur_node / TERRAIN_WIDTH) >> 2;
3847
3848 ASSERT(cur_node >= 0 && cur_node < TERRAIN_WIDTH * TERRAIN_DEPTH);
3849 ASSERT((fvi_terrain_visit_list[cur_node >> 3] & (0x01 << (cur_node % 8))) == 0);
3850 ASSERT(fvi_num_cells_visited < MAX_CELLS_VISITED);
3851
3852 // Mark the current node as visited
3853 fvi_terrain_visit_list[cur_node >> 3] |= 0x01 << (cur_node % 8);
3854 fvi_cells_visited[fvi_num_cells_visited] = cur_node;

Callers 1

do_fvi_terrainFunction · 0.85

Calls 5

check_hit_objFunction · 0.85
check_line_to_faceFunction · 0.85
BBoxPlaneIntersectionFunction · 0.85
vm_NormalizeVectorFunction · 0.85
compute_movement_AABBFunction · 0.85

Tested by

no test coverage detected