Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
cell.h
Go to the documentation of this file.
1/*
2** Jo Sega Saturn Engine
3** Copyright (c) 2012-2026, Johannes Fetz (johannesfetz@gmail.com)
4** All rights reserved.
5**
6** Redistribution and use in source and binary forms, with or without
7** modification, are permitted provided that the following conditions are met:
8** * Redistributions of source code must retain the above copyright
9** notice, this list of conditions and the following disclaimer.
10** * Redistributions in binary form must reproduce the above copyright
11** notice, this list of conditions and the following disclaimer in the
12** documentation and/or other materials provided with the distribution.
13** * Neither the name of the Johannes Fetz nor the
14** names of its contributors may be used to endorse or promote products
15** derived from this software without specific prior written permission.
16**
17** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
41
42#ifndef __JO_CELL_H__
43# define __JO_CELL_H__
44
45#if defined(JO_COMPILE_WITH_LEVEL_SUPPORT) && defined(JO_COMPILE_WITH_3D_SUPPORT)
46
48# define JO_CELL_MAX (48)
50# define JO_CELL_MAX_PORTALS (96)
52# define JO_CELL_MAX_DRAWN (12)
53
55typedef struct
56{
57 jo_3d_mesh *mesh; // Model of the cell (world coordinates), JO_NULL: none
58 jo_3d_mesh *reflection; // Simpler model drawn in its mirrors (a polished floor), JO_NULL: its model
59 jo_pos3D_fixed center; // Bounding sphere of the model
60 int radius;
61 int x0; // Box where the player can walk (world units)
62 int z0;
63 int x1;
64 int z1;
65 int floor0; // Floor (Saturn Y): see JO_LEVEL_CELL_SLOPE_xxx
66 int floor1;
67 unsigned short slope;
68 unsigned short first_portal;
69 unsigned short portal_count;
70 short yaw; // The box is turned around its center (degrees)
71 jo_fixed cos; // Of the yaw (0 and 1: not turned)
72 jo_fixed sin;
73} jo_cell;
74
76typedef struct
77{
78 jo_pos3D_fixed points[4]; // Corners (world space)
79 unsigned short cell; // Cell seen through it
80 unsigned short kind; // JO_LEVEL_PORTAL_xxx
81} jo_cell_portal;
82
87int jo_cells_load(jo_level * const level);
88
90void jo_cells_free(void);
91
93int jo_cells_count(void);
94
98bool jo_cells_have_exits(void);
99
103const jo_cell *jo_cells_get(const int index);
104
111int jo_cells_outside_view(jo_3d_rect * const rect);
112
119int jo_cell_floor(const jo_cell * const cell, const int x, const int z);
120
128int jo_cells_find(const jo_fixed x, const jo_fixed y, const jo_fixed z, const int step);
129
138bool jo_cells_floor(const jo_fixed x, const jo_fixed y, const jo_fixed z, const int step, int * const floor);
139
148bool jo_cells_is_walkable(const jo_fixed x, const jo_fixed y, const jo_fixed z, const int radius, const int step);
149
155int jo_cells_draw(const jo_pos3D_fixed * const camera);
156
162int jo_cells_prepare(const jo_pos3D_fixed * const camera);
163
170void jo_cells_draw_prepared(const bool slave);
171
178void jo_cells_draw_prepared_part(const bool slave, const int part, const int handicap);
179
187void jo_cells_draw_prepared_share(const bool slave, const int part, const int share);
188
200bool jo_cells_draw_mirror(void (*draw_more)(void));
201
206bool jo_cells_mirror_is_floor(void);
207
213void jo_cells_set_window_distance(const int distance);
214
222bool jo_cells_view_rect_at(const jo_pos3D_fixed * const position, jo_3d_rect * const rect);
223
231bool jo_cells_seen_through(const int index, jo_3d_rect * const rect);
232
238bool jo_cells_seen_through_window(const int index);
239
244bool jo_cells_is_drawn(const int index);
245
254int jo_cells_close_portals(const jo_fixed x, const jo_fixed z, const int radius, const bool closed);
255
263int jo_cells_depth_bias_at(const jo_fixed x, const jo_fixed y, const jo_fixed z);
264
273int jo_cells_object_cell(const jo_fixed x, const jo_fixed y, const jo_fixed z);
274
279int jo_cells_depth_bias_of(const int cell);
280
284unsigned short jo_cells_generation(void);
285
294bool jo_cells_ray_hit(const jo_pos3D_fixed * const origin, const jo_pos3D_fixed * const dir, const jo_fixed max_t,
295 jo_fixed * const t, jo_pos3D_fixed * const normal);
296
302int jo_cells_add_point_light_meshes(const bool shadows);
303
304#endif /* !JO_COMPILE_WITH_LEVEL_SUPPORT && JO_COMPILE_WITH_3D_SUPPORT */
305
306#endif /* !__JO_CELL_H__ */
307
308/*
309** END OF FILE
310*/
Mesh structure.
Definition 3d.h:216
A rectangle of the screen (pixels, the edges are in it).
Definition 3d.h:1383
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:48
3D position using fixed numbers
Definition types.h:92