mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- exported secplane_t to scripting.
This commit is contained in:
parent
91981e25a8
commit
82adc5bf1e
3 changed files with 124 additions and 14 deletions
|
@ -1307,6 +1307,84 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool is3dlight, int *pfake
|
|||
return baselight;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, isSlope)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
ACTION_RETURN_BOOL(!self->normal.XY().isZero());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, PointOnSide)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
PARAM_FLOAT(z);
|
||||
ACTION_RETURN_INT(self->PointOnSide(DVector3(x, y, z)));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, ZatPoint)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
ACTION_RETURN_FLOAT(self->ZatPoint(x, y));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, ZatPointDist)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
PARAM_FLOAT(d);
|
||||
ACTION_RETURN_FLOAT((d + self->normal.X*x + self->normal.Y*y) * self->negiC);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, isEqual)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
PARAM_POINTER(other, secplane_t);
|
||||
ACTION_RETURN_BOOL(*self == *other);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, ChangeHeight)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
PARAM_FLOAT(hdiff);
|
||||
self->ChangeHeight(hdiff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, GetChangedHeight)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
PARAM_FLOAT(hdiff);
|
||||
ACTION_RETURN_FLOAT(self->GetChangedHeight(hdiff));
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, HeightDiff)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
PARAM_FLOAT(oldd);
|
||||
if (numparam == 2)
|
||||
{
|
||||
ACTION_RETURN_FLOAT(self->HeightDiff(oldd));
|
||||
}
|
||||
else
|
||||
{
|
||||
PARAM_FLOAT(newd);
|
||||
ACTION_RETURN_FLOAT(self->HeightDiff(oldd, newd));
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Secplane, PointToDist)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(secplane_t);
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
PARAM_FLOAT(z);
|
||||
ACTION_RETURN_FLOAT(self->PointToDist(DVector2(x, y), z));
|
||||
}
|
||||
|
||||
|
||||
DEFINE_FIELD_X(Sector, sector_t, floorplane)
|
||||
DEFINE_FIELD_X(Sector, sector_t, ceilingplane)
|
||||
|
@ -1366,3 +1444,7 @@ DEFINE_FIELD_X(Line, line_t, backsector)
|
|||
DEFINE_FIELD_X(Line, line_t, validcount)
|
||||
DEFINE_FIELD_X(Line, line_t, locknumber)
|
||||
DEFINE_FIELD_X(Line, line_t, portalindex)
|
||||
|
||||
DEFINE_FIELD_X(Secplane, secplane_t, normal)
|
||||
DEFINE_FIELD_X(Secplane, secplane_t, D)
|
||||
DEFINE_FIELD_X(Secplane, secplane_t, negiC)
|
||||
|
|
|
@ -711,6 +711,26 @@ static int fieldcmp(const void * a, const void * b)
|
|||
void InitThingdef()
|
||||
{
|
||||
// Create all global variables here because this cannot be done on the script side and really isn't worth adding support for.
|
||||
// Also create all special fields here that cannot be declared by script syntax.
|
||||
|
||||
auto secplanestruct = NewNativeStruct("Secplane", nullptr);
|
||||
secplanestruct->Size = sizeof(secplane_t);
|
||||
secplanestruct->Align = alignof(secplane_t);
|
||||
auto sectorstruct = NewNativeStruct("Sector", nullptr);
|
||||
sectorstruct->Size = sizeof(sector_t);
|
||||
sectorstruct->Align = alignof(sector_t);
|
||||
|
||||
|
||||
// set up the lines array in the sector struct. This is a bit messy because the type system is not prepared to handle a pointer to an array of pointers to a native struct even remotely well...
|
||||
// As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up.
|
||||
sectorstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(NewNativeStruct("line", nullptr), false)), false), myoffsetof(sector_t, Lines), VARF_Native);
|
||||
|
||||
// add the sector planes. These are value items of native structs so they have to be done here.
|
||||
sectorstruct->AddNativeField("ceilingplane", secplanestruct, myoffsetof(sector_t, ceilingplane), VARF_Native);
|
||||
sectorstruct->AddNativeField("floorplane", secplanestruct, myoffsetof(sector_t, floorplane), VARF_Native);
|
||||
|
||||
|
||||
|
||||
|
||||
// expose the global validcount variable.
|
||||
PField *vcf = new PField("validcount", TypeSInt32, VARF_Native | VARF_Static, (intptr_t)&validcount);
|
||||
|
@ -725,10 +745,12 @@ void InitThingdef()
|
|||
PField *levelf = new PField("level", lstruct, VARF_Native | VARF_Static, (intptr_t)&level);
|
||||
GlobalSymbols.AddSymbol(levelf);
|
||||
|
||||
// Add the sector array to LevelLocals.
|
||||
lstruct->AddNativeField("sectors", NewPointer(NewResizableArray(sectorstruct), false), myoffsetof(FLevelLocals, sectors), VARF_Native);
|
||||
|
||||
// set up a variable for the DEH data
|
||||
PStruct *dstruct = NewNativeStruct("DehInfo", nullptr);
|
||||
PField *dehf = new PField("deh", dstruct, VARF_Native | VARF_Static, (intptr_t)&deh);
|
||||
|
||||
GlobalSymbols.AddSymbol(dehf);
|
||||
|
||||
// set up a variable for the global players array.
|
||||
|
@ -739,17 +761,6 @@ void InitThingdef()
|
|||
PField *playerf = new PField("players", parray, VARF_Native | VARF_Static, (intptr_t)&players);
|
||||
GlobalSymbols.AddSymbol(playerf);
|
||||
|
||||
// set up the lines array in the sector struct. This is a bit messy because the type system is not prepared to handle a pointer to an array of pointers to a native struct even remotely well...
|
||||
// As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up.
|
||||
pstruct = NewNativeStruct("Sector", nullptr);
|
||||
pstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(NewNativeStruct("line", nullptr), false)), false), myoffsetof(sector_t, Lines), VARF_Native);
|
||||
|
||||
// Add the sector array to LevelLocals.
|
||||
pstruct->Size = sizeof(sector_t);
|
||||
pstruct->Align = alignof(sector_t);
|
||||
parray = NewArray(pstruct, MAXPLAYERS);
|
||||
lstruct->AddNativeField("sectors", NewPointer(NewResizableArray(pstruct), false), myoffsetof(FLevelLocals, sectors), VARF_Native);
|
||||
|
||||
parray = NewArray(TypeBool, MAXPLAYERS);
|
||||
playerf = new PField("playeringame", parray, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&playeringame);
|
||||
GlobalSymbols.AddSymbol(playerf);
|
||||
|
|
|
@ -236,10 +236,27 @@ struct Line native
|
|||
native readonly uint portalindex;
|
||||
}
|
||||
|
||||
struct SecPlane native
|
||||
{
|
||||
native Vector3 Normal;
|
||||
native double D;
|
||||
native double negiC;
|
||||
|
||||
native bool isSlope();
|
||||
native int PointOnSide(Vector3 pos);
|
||||
native double ZatPoint (Vector2 v);
|
||||
native double ZatPointDist(Vector2 v, double dist);
|
||||
native bool isEqual(Secplane other);
|
||||
native void ChangeHeight(double hdiff);
|
||||
native double GetChangedHeight(double hdiff);
|
||||
native double HeightDiff(double oldd, double newd = 0.0);
|
||||
native double PointToDist(const DVector2 &xy, double z);
|
||||
}
|
||||
|
||||
struct Sector native
|
||||
{
|
||||
//secplane_t floorplane, ceilingplane;
|
||||
//FDynamicColormap *ColorMap; // [RH] Per-sector colormap
|
||||
//secplane_t floorplane, ceilingplane; // defined internally
|
||||
//FDynamicColormap *ColorMap;
|
||||
|
||||
native Actor SoundTarget;
|
||||
|
||||
|
|
Loading…
Reference in a new issue