Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * Portions of this file are copyright Rebirth contributors and licensed as
3
 * described in COPYING.txt.
4
 * Portions of this file are copyright Parallax Software and licensed
5
 * according to the Parallax license below.
6
 * See COPYING.txt for license details.
7
 
8
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
9
SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
10
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
11
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
12
IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
13
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
14
FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
15
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
16
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
17
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
18
*/
19
 
20
/*
21
 *
22
 * Header for fvi.c
23
 *
24
 */
25
 
26
#pragma once
27
 
28
#include "vecmat.h"
29
 
30
#ifdef __cplusplus
31
#include "dxxsconf.h"
32
#include "fwd-object.h"
33
#include "pack.h"
34
#include "countarray.h"
35
 
36
//return values for find_vector_intersection() - what did we hit?
37
#define HIT_NONE                0               //we hit nothing
38
#define HIT_WALL                1               //we hit - guess - a wall
39
#define HIT_OBJECT      2               //we hit an object - which one?  no way to tell...
40
#define HIT_BAD_P0      3               //start point not is specified segment
41
 
42
#define MAX_FVI_SEGS 100
43
 
44
//this data structure gets filled in by find_vector_intersection()
45
struct fvi_info : prohibit_void_ptr<fvi_info>
46
{
47
        struct segment_array_t : public count_array_t<segnum_t, MAX_FVI_SEGS> {};
48
        int hit_type;                                   //what sort of intersection
49
        vms_vector hit_pnt;                     //where we hit
50
        segnum_t hit_seg;                                       //what segment hit_pnt is in
51
        int hit_side;                                   //if hit wall, which side
52
        segnum_t hit_side_seg;                          //what segment the hit side is in
53
        objnum_t hit_object;                            //if object hit, which object
54
        vms_vector hit_wallnorm;        //if hit wall, ptr to its surface normal
55
        segment_array_t seglist;
56
};
57
 
58
//flags for fvi query
59
#define FQ_CHECK_OBJS   1               //check against objects?
60
#define FQ_TRANSWALL            2               //go through transparent walls
61
#define FQ_TRANSPOINT   4               //go through trans wall if hit point is transparent
62
#define FQ_GET_SEGLIST  8               //build a list of segments
63
#define FQ_IGNORE_POWERUPS      16              //ignore powerups
64
 
65
#ifdef dsx
66
//this data contains the parms to fvi()
67
struct fvi_query : prohibit_void_ptr<fvi_query>
68
{
69
        const vms_vector *p0,*p1;
70
        segnum_t startseg;
71
        objnum_t thisobjnum;
72
        fix rad;
73
        std::pair<const vcobjidx_t *, const vcobjidx_t *> ignore_obj_list;
74
        int flags;
75
};
76
 
77
struct fvi_hitpoint
78
{
79
        fix u, v;
80
};
81
 
82
//Find out if a vector intersects with anything.
83
//Fills in hit_data, an fvi_info structure (see above).
84
//Parms:
85
//  p0 & startseg       describe the start of the vector
86
//  p1                                  the end of the vector
87
//  rad                                         the radius of the cylinder
88
//  thisobjnum          used to prevent an object with colliding with itself
89
//  ingore_obj_list     NULL, or ptr to a list of objnums to ignore, terminated with -1
90
//  check_obj_flag      determines whether collisions with objects are checked
91
//Returns the hit_data->hit_type
92
int find_vector_intersection(const fvi_query &fq, fvi_info &hit_data);
93
 
94
//finds the uv coords of the given point on the given seg & side
95
//fills in u & v. if l is non-NULL fills it in also
96
namespace dsx {
97
__attribute_warn_unused_result
98
fvi_hitpoint find_hitpoint_uv(const vms_vector &pnt, const cscusegment seg, uint_fast32_t sidenum, uint_fast32_t facenum);
99
}
100
 
101
struct sphere_intersects_wall_result
102
{
103
        const shared_segment *seg;
104
        uint_fast32_t side;
105
};
106
 
107
//Returns true if the object is through any walls
108
sphere_intersects_wall_result sphere_intersects_wall(fvcvertptr &vcvertptr, const vms_vector &pnt, vcsegptridx_t seg, fix rad);
109
#endif
110
 
111
#endif