2016-09-14 18:01:13 +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/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
#ifndef __GLC_DYNLIGHT_H
|
|
|
|
#define __GLC_DYNLIGHT_H
|
|
|
|
|
|
|
|
#include "c_cvars.h"
|
|
|
|
#include "gl/utility/gl_geometric.h"
|
|
|
|
#include "gl/utility/gl_cycler.h"
|
2017-03-10 01:22:42 +00:00
|
|
|
#include "actor.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
EXTERN_CVAR(Bool, gl_lights)
|
|
|
|
EXTERN_CVAR(Bool, gl_attachedlights)
|
|
|
|
|
|
|
|
class ADynamicLight;
|
2016-09-23 23:47:44 +00:00
|
|
|
class FSerializer;
|
2016-12-23 14:25:39 +00:00
|
|
|
class FLightDefaults;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
LIGHT_RED = 0,
|
|
|
|
LIGHT_GREEN = 1,
|
|
|
|
LIGHT_BLUE = 2,
|
|
|
|
LIGHT_INTENSITY = 3,
|
|
|
|
LIGHT_SECONDARY_INTENSITY = 4,
|
|
|
|
LIGHT_SCALE = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
// This is as good as something new - and it can be set directly in the ActorInfo!
|
|
|
|
#define MF4_SUBTRACTIVE MF4_MISSILEEVENMORE
|
|
|
|
#define MF4_ADDITIVE MF4_MISSILEMORE
|
|
|
|
#define MF4_DONTLIGHTSELF MF4_SEESDAGGERS
|
2016-10-23 18:42:48 +00:00
|
|
|
#define MF4_ATTENUATE MF4_INCOMBAT
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
enum ELightType
|
|
|
|
{
|
|
|
|
PointLight,
|
|
|
|
PulseLight,
|
|
|
|
FlickerLight,
|
|
|
|
RandomFlickerLight,
|
|
|
|
SectorLight,
|
|
|
|
SpotLight,
|
|
|
|
ColorPulseLight,
|
|
|
|
ColorFlickerLight,
|
|
|
|
RandomColorFlickerLight
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct FLightNode
|
|
|
|
{
|
|
|
|
FLightNode ** prevTarget;
|
|
|
|
FLightNode * nextTarget;
|
|
|
|
FLightNode ** prevLight;
|
|
|
|
FLightNode * nextLight;
|
|
|
|
ADynamicLight * lightsource;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
side_t * targLine;
|
|
|
|
subsector_t * targSubsector;
|
|
|
|
void * targ;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Base class
|
|
|
|
//
|
|
|
|
// [CO] I merged everything together in this one class so that I don't have
|
|
|
|
// to create and re-create an excessive amount of objects
|
|
|
|
//
|
|
|
|
|
|
|
|
class ADynamicLight : public AActor
|
|
|
|
{
|
2016-12-23 14:25:39 +00:00
|
|
|
friend class FLightDefaults;
|
2013-06-23 07:49:34 +00:00
|
|
|
DECLARE_CLASS (ADynamicLight, AActor)
|
|
|
|
public:
|
|
|
|
virtual void Tick();
|
2016-09-23 23:47:44 +00:00
|
|
|
void Serialize(FSerializer &arc);
|
|
|
|
void PostSerialize();
|
2017-03-09 18:54:41 +00:00
|
|
|
uint8_t GetRed() const { return args[LIGHT_RED]; }
|
|
|
|
uint8_t GetGreen() const { return args[LIGHT_GREEN]; }
|
|
|
|
uint8_t GetBlue() const { return args[LIGHT_BLUE]; }
|
2016-04-17 11:53:29 +00:00
|
|
|
float GetRadius() const { return (IsActive() ? m_currentRadius * 2.f : 0.f); }
|
2013-06-23 07:49:34 +00:00
|
|
|
void LinkLight();
|
|
|
|
void UnlinkLight();
|
|
|
|
size_t PointerSubstitution (DObject *old, DObject *notOld);
|
|
|
|
|
2016-02-02 10:58:00 +00:00
|
|
|
void BeginPlay();
|
2016-04-03 10:54:47 +00:00
|
|
|
void SetOrigin (double x, double y, double z, bool moving = false);
|
2013-06-23 07:49:34 +00:00
|
|
|
void PostBeginPlay();
|
2017-01-12 21:49:18 +00:00
|
|
|
void OnDestroy() override;
|
2013-06-23 07:49:34 +00:00
|
|
|
void Activate(AActor *activator);
|
|
|
|
void Deactivate(AActor *activator);
|
2016-03-24 12:38:37 +00:00
|
|
|
void SetOffset(const DVector3 &pos);
|
2013-06-23 07:49:34 +00:00
|
|
|
void UpdateLocation();
|
|
|
|
bool IsOwned() const { return owned; }
|
|
|
|
bool IsActive() const { return !(flags2&MF2_DORMANT); }
|
|
|
|
bool IsSubtractive() { return !!(flags4&MF4_SUBTRACTIVE); }
|
|
|
|
bool IsAdditive() { return !!(flags4&MF4_ADDITIVE); }
|
|
|
|
FState *targetState;
|
|
|
|
FLightNode * touching_sides;
|
|
|
|
FLightNode * touching_subsectors;
|
2014-05-11 20:57:42 +00:00
|
|
|
FLightNode * touching_sector;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
private:
|
2016-03-30 18:01:44 +00:00
|
|
|
double DistToSeg(const DVector3 &pos, seg_t *seg);
|
|
|
|
void CollectWithinRadius(const DVector3 &pos, subsector_t *subSec, float radius);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
protected:
|
2016-03-24 12:38:37 +00:00
|
|
|
DVector3 m_off;
|
2016-04-17 11:53:29 +00:00
|
|
|
float m_currentRadius;
|
2013-06-23 07:49:34 +00:00
|
|
|
unsigned int m_lastUpdate;
|
|
|
|
FCycler m_cycler;
|
|
|
|
subsector_t * subsector;
|
|
|
|
|
|
|
|
public:
|
2016-12-06 17:35:34 +00:00
|
|
|
int m_tickCount;
|
2017-03-09 18:54:41 +00:00
|
|
|
uint8_t lightflags;
|
|
|
|
uint8_t lighttype;
|
2013-06-23 07:49:34 +00:00
|
|
|
bool owned;
|
|
|
|
bool halo;
|
2017-03-09 18:54:41 +00:00
|
|
|
uint8_t color2[3];
|
2016-05-04 09:33:18 +00:00
|
|
|
bool visibletoplayer;
|
2017-03-01 19:54:37 +00:00
|
|
|
bool swapped;
|
2013-06-23 07:49:34 +00:00
|
|
|
int bufferindex;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
STAT_DLIGHT=64
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FDynLightData
|
|
|
|
{
|
|
|
|
TArray<float> arrays[3];
|
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
arrays[0].Clear();
|
|
|
|
arrays[1].Clear();
|
|
|
|
arrays[2].Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Combine(int *siz, int max)
|
|
|
|
{
|
|
|
|
siz[0] = arrays[0].Size();
|
|
|
|
siz[1] = siz[0] + arrays[1].Size();
|
|
|
|
siz[2] = siz[1] + arrays[2].Size();
|
|
|
|
arrays[0].Resize(arrays[0].Size() + arrays[1].Size() + arrays[2].Size());
|
|
|
|
memcpy(&arrays[0][siz[0]], &arrays[1][0], arrays[1].Size() * sizeof(float));
|
|
|
|
memcpy(&arrays[0][siz[1]], &arrays[2][0], arrays[2].Size() * sizeof(float));
|
|
|
|
siz[0]>>=2;
|
|
|
|
siz[1]>>=2;
|
|
|
|
siz[2]>>=2;
|
|
|
|
if (siz[0] > max) siz[0] = max;
|
|
|
|
if (siz[1] > max) siz[1] = max;
|
|
|
|
if (siz[2] > max) siz[2] = max;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-04 10:35:26 +00:00
|
|
|
bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FDynLightData &data);
|
2014-05-11 20:57:42 +00:00
|
|
|
void gl_UploadLights(FDynLightData &data);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|