NS/main/source/particles/particledefs.h
Brett Caswell 36c78acbce
PR Merge of Patch 63 to Patch 61 (#6)
* handle particles project VC++ compilation errors with MVCS and project property changes

 - retarget to v142 platformtoolset
 - remove explicit windows SDK version; use latest by default
 - remove settings that are otherwise default values in project or are best determined by solution

* attempt to handle clang++ issues regarding unsupported c++11 features

* reset file changes to particledefs.h

* removing PARTICLEDLL_API definition and replacing usage with extern "C" block statements

* add g++ compiler option to specify c++11 standard

* attempt to resolve forward enum errors by adding std to base cflags

* replacing deprecated libstdc++ and removing -lstdc++ flag, updating MacOSX10 sdk version

* small refactor to Makefiles, and add  libstdc++ back to linux build

* remove added type to enum

* reset makefile changes that may be causing unexpected linux build failures

* refactoring std=c++11 declarations in Makefile to mitgate linux build failing

* ensure std is set for hl_cdll make

* attempt to define a standard library to resolve vector initialization_list constructor issue

* attempt to update MacOS sdk, set minimum os to be 10.7, and include export in travis ci to define deployment target
2020-07-05 11:11:06 -05:00

96 lines
2.1 KiB
C

// general.h
//
// Copyright 1998 by David K. McAllister.
//
// This file implements the API calls that are not particle actions.
#ifndef particledefs_h
#define particledefs_h
#include "p_vector.h"
#ifdef WIN32
#include <windows.h>
#pragma warning (disable:4244)
#endif
// Actually this must be < sqrt(MAXFLOAT) since we store this value squared.
#define P_MAXFLOAT 1.0e16f
#ifdef MAXINT
#define P_MAXINT MAXINT
#else
#define P_MAXINT 0x7fffffff
#endif
#define P_EPS 1e-3f
//////////////////////////////////////////////////////////////////////
// Type codes for domains
extern "C" {
enum PDomainEnum
{
PDPoint = 0, // Single point
PDLine = 1, // Line segment
PDTriangle = 2, // Triangle
PDPlane = 3, // Arbitrarily-oriented plane
PDBox = 4, // Axis-aligned box
PDSphere = 5, // Sphere
PDCylinder = 6, // Cylinder
PDCone = 7, // Cone
PDBlob = 8, // Gaussian blob
PDDisc = 9, // Arbitrarily-oriented disc
PDRectangle = 10 // Rhombus-shaped planar region
};
}
// A single particle
struct Particle
{
pVector pos;
pVector posB;
pVector size;
pVector vel;
pVector velB; // Used to compute binormal, normal, etc.
pVector color; // Color must be next to alpha so glColor4fv works.
float alpha; // This is both cunning and scary.
float age;
};
// A group of particles - Info and an array of Particles
struct ParticleGroup
{
int p_count; // Number of particles currently existing.
int max_particles; // Max particles allowed in group.
int particles_allocated; // Actual allocated size.
Particle list[1]; // Actually, num_particles in size
inline void Remove(int i)
{
list[i] = list[--p_count];
}
inline bool Add(const pVector &pos, const pVector &posB,
const pVector &size, const pVector &vel, const pVector &color,
const float alpha = 1.0f,
const float age = 0.0f)
{
if(p_count >= max_particles)
return false;
else
{
list[p_count].pos = pos;
list[p_count].posB = posB;
list[p_count].size = size;
list[p_count].vel = vel;
list[p_count].velB = vel; // XXX This should be fixed.
list[p_count].color = color;
list[p_count].alpha = alpha;
list[p_count].age = age;
p_count++;
return true;
}
}
};
#endif