dxx-rebirth/common/include/interp.h

105 lines
3.2 KiB
C
Raw Normal View History

2014-06-01 17:55:23 +00:00
/*
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
2014-06-01 17:55:23 +00:00
* It is copyright by its individual contributors, as recorded in the
* project's Git history. See COPYING.txt at the top level for license
* terms and a link to the Git history.
*/
2006-03-20 17:12:09 +00:00
/*
*
* took out functions declarations from include/3d.h
* which are implemented in 3d/interp.c
*
*/
2015-01-29 04:27:36 +00:00
#pragma once
2006-03-20 17:12:09 +00:00
2012-07-01 02:54:33 +00:00
#include "maths.h"
2006-03-20 17:12:09 +00:00
#include "3d.h"
#ifdef __cplusplus
#include "dxxsconf.h"
#include "dsx-ns.h"
#include <array>
2015-12-13 18:00:49 +00:00
namespace dcx {
2015-02-14 22:48:28 +00:00
class submodel_angles;
constexpr std::integral_constant<std::size_t, 1000> MAX_POLYGON_VECS{};
2020-05-02 21:18:42 +00:00
struct polygon_model_points : std::array<g3s_point, MAX_POLYGON_VECS> {};
}
2015-02-05 03:03:50 +00:00
2016-01-09 16:38:15 +00:00
#ifdef dsx
2015-12-13 18:00:49 +00:00
namespace dsx {
#if defined(DXX_BUILD_DESCENT_I)
#define glow_array_size 1
#elif defined(DXX_BUILD_DESCENT_II)
#define glow_array_size 2
#endif
2020-05-02 21:18:42 +00:00
struct glow_values_t : public std::array<fix, glow_array_size> {};
#undef glow_array_size
2006-03-20 17:12:09 +00:00
//Object functions:
//calls the object interpreter to render an object. The object renderer
//is really a seperate pipeline. returns true if drew
2017-02-11 21:42:40 +00:00
void g3_draw_polygon_model(grs_bitmap *const *model_bitmaps, polygon_model_points &Interp_point_list, grs_canvas &, submodel_angles anim_angles, g3s_lrgb model_light, const glow_values_t *glow_values, const uint8_t *p);
2006-03-20 17:12:09 +00:00
//init code for bitmap models
int16_t g3_init_polygon_model(uint8_t *model_ptr, std::size_t model_size);
#if defined(DXX_BUILD_DESCENT_I)
void g3_validate_polygon_model(uint8_t *model_ptr, std::size_t model_size);
#endif
}
#endif
2006-03-20 17:12:09 +00:00
//un-initialize, i.e., convert color entries back to RGB15
static inline void g3_uninit_polygon_model(void *model_ptr)
{
(void)model_ptr;
}
2006-03-20 17:12:09 +00:00
2016-01-09 16:38:15 +00:00
#ifdef dsx
2015-12-13 18:00:49 +00:00
namespace dsx {
2006-03-20 17:12:09 +00:00
//alternate interpreter for morphing object
2017-03-11 19:56:27 +00:00
void g3_draw_morphing_model(grs_canvas &, const uint8_t *model_ptr, grs_bitmap *const *model_bitmaps, submodel_angles anim_angles, g3s_lrgb light, const vms_vector *new_points, polygon_model_points &Interp_point_list);
2006-03-20 17:12:09 +00:00
// check a polymodel for it's color and return it
2015-02-28 22:34:05 +00:00
int g3_poly_get_color(const uint8_t *model_ptr);
}
#endif
2015-12-13 18:00:49 +00:00
namespace dcx {
#if DXX_WORDS_BIGENDIAN
2006-03-20 17:12:09 +00:00
// routine to convert little to big endian in polygon model data
void swap_polygon_model_data(ubyte *data);
#else
static inline void swap_polygon_model_data(uint8_t *) {}
2006-03-20 17:12:09 +00:00
#endif
#if DXX_WORDS_NEED_ALIGNMENT
2006-03-20 17:12:09 +00:00
/*
* A chunk struct (as used for alignment) contains all relevant data
* concerning a piece of data that may need to be aligned.
* To align it, we need to copy it to an aligned position,
* and update all pointers to it.
* (Those pointers are actually offsets
* relative to start of model_data) to it.
*/
struct chunk
{
2015-02-22 01:29:43 +00:00
const uint8_t *old_base; // where the offset sets off from (relative to beginning of model_data)
uint8_t *new_base; // where the base is in the aligned structure
2006-03-20 17:12:09 +00:00
short offset; // how much to add to base to get the address of the offset
short correction; // how much the value of the offset must be shifted for alignment
};
2006-03-20 17:12:09 +00:00
#define MAX_CHUNKS 100 // increase if insufficent
/*
* finds what chunks the data points to, adds them to the chunk_list,
* and returns the length of the current chunk
*/
2015-02-22 01:29:43 +00:00
int get_chunks(const uint8_t *data, uint8_t *new_data, chunk *list, int *no);
2006-03-20 17:12:09 +00:00
#endif //def WORDS_NEED_ALIGNMENT
}
2006-03-20 17:12:09 +00:00
#endif