2017-11-25 11:11:57 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2005-2016 Christoph Oelckers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef __GL_MODELS_H_
|
|
|
|
#define __GL_MODELS_H_
|
|
|
|
|
|
|
|
#include "tarray.h"
|
2019-08-20 19:02:40 +00:00
|
|
|
#include "matrix.h"
|
2020-04-26 22:03:23 +00:00
|
|
|
#include "m_bbox.h"
|
|
|
|
#include "r_defs.h"
|
2018-06-05 22:30:59 +00:00
|
|
|
#include "g_levellocals.h"
|
2020-04-26 22:03:23 +00:00
|
|
|
#include "r_data/voxels.h"
|
2020-04-26 11:19:57 +00:00
|
|
|
#include "i_modelvertexbuffer.h"
|
2020-04-26 23:16:17 +00:00
|
|
|
#include "model.h"
|
2017-11-25 11:11:57 +00:00
|
|
|
|
2020-04-26 22:03:23 +00:00
|
|
|
class FModelRenderer;
|
|
|
|
|
2017-11-25 11:11:57 +00:00
|
|
|
struct FSpriteModelFrame;
|
|
|
|
class IModelVertexBuffer;
|
2019-01-29 01:18:19 +00:00
|
|
|
struct FLevelLocals;
|
2017-11-25 11:11:57 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// [BB] Model rendering flags.
|
|
|
|
//
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
// [BB] Color translations for the model skin are ignored. This is
|
|
|
|
// useful if the skin texture is not using the game palette.
|
|
|
|
MDL_IGNORETRANSLATION = 1,
|
|
|
|
MDL_PITCHFROMMOMENTUM = 2,
|
|
|
|
MDL_ROTATING = 4,
|
|
|
|
MDL_INTERPOLATEDOUBLEDFRAMES = 8,
|
|
|
|
MDL_NOINTERPOLATION = 16,
|
|
|
|
MDL_USEACTORPITCH = 32,
|
|
|
|
MDL_USEACTORROLL = 64,
|
|
|
|
MDL_BADROTATION = 128,
|
|
|
|
MDL_DONTCULLBACKFACES = 256,
|
2018-02-28 19:35:01 +00:00
|
|
|
MDL_USEROTATIONCENTER = 512,
|
2017-11-25 11:11:57 +00:00
|
|
|
};
|
|
|
|
|
2018-05-21 15:52:03 +00:00
|
|
|
FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped);
|
|
|
|
bool IsHUDModelForPlayerAvailable(player_t * player);
|
2017-11-25 11:11:57 +00:00
|
|
|
|
2018-06-05 20:43:11 +00:00
|
|
|
// Check if circle potentially intersects with node AABB
|
|
|
|
inline bool CheckBBoxCircle(float *bbox, float x, float y, float radiusSquared)
|
|
|
|
{
|
|
|
|
float centerX = (bbox[BOXRIGHT] + bbox[BOXLEFT]) * 0.5f;
|
|
|
|
float centerY = (bbox[BOXBOTTOM] + bbox[BOXTOP]) * 0.5f;
|
|
|
|
float extentX = (bbox[BOXRIGHT] - bbox[BOXLEFT]) * 0.5f;
|
|
|
|
float extentY = (bbox[BOXBOTTOM] - bbox[BOXTOP]) * 0.5f;
|
|
|
|
float aabbRadiusSquared = extentX * extentX + extentY * extentY;
|
|
|
|
x -= centerX;
|
|
|
|
y -= centerY;
|
|
|
|
float dist = x * x + y * y;
|
|
|
|
return dist <= radiusSquared + aabbRadiusSquared;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper function for BSPWalkCircle
|
|
|
|
template<typename Callback>
|
|
|
|
void BSPNodeWalkCircle(void *node, float x, float y, float radiusSquared, const Callback &callback)
|
|
|
|
{
|
|
|
|
while (!((size_t)node & 1))
|
|
|
|
{
|
|
|
|
node_t *bsp = (node_t *)node;
|
|
|
|
|
|
|
|
if (CheckBBoxCircle(bsp->bbox[0], x, y, radiusSquared))
|
|
|
|
BSPNodeWalkCircle(bsp->children[0], x, y, radiusSquared, callback);
|
|
|
|
|
|
|
|
if (!CheckBBoxCircle(bsp->bbox[1], x, y, radiusSquared))
|
|
|
|
return;
|
|
|
|
|
|
|
|
node = bsp->children[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
subsector_t *sub = (subsector_t *)((uint8_t *)node - 1);
|
|
|
|
callback(sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search BSP for subsectors within the given radius and call callback(subsector) for each found
|
|
|
|
template<typename Callback>
|
2019-01-29 01:18:19 +00:00
|
|
|
void BSPWalkCircle(FLevelLocals *Level, float x, float y, float radiusSquared, const Callback &callback)
|
2018-06-05 20:43:11 +00:00
|
|
|
{
|
2019-01-29 01:18:19 +00:00
|
|
|
if (Level->nodes.Size() == 0)
|
|
|
|
callback(&Level->subsectors[0]);
|
2018-06-05 20:43:11 +00:00
|
|
|
else
|
2019-01-29 01:18:19 +00:00
|
|
|
BSPNodeWalkCircle(Level->HeadNode(), x, y, radiusSquared, callback);
|
2018-06-05 20:43:11 +00:00
|
|
|
}
|
|
|
|
|
2020-04-26 22:25:53 +00:00
|
|
|
void RenderModel(FModelRenderer* renderer, float x, float y, float z, FSpriteModelFrame* smf, AActor* actor, double ticFrac);
|
|
|
|
void RenderHUDModel(FModelRenderer* renderer, DPSprite* psp, float ofsX, float ofsY);
|
|
|
|
|
2017-11-25 11:11:57 +00:00
|
|
|
#endif
|