Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add set/get plane reflectivity #2766

Merged
merged 4 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/gamedata/r_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "r_sky.h"
#include "p_terrain.h"
#include "p_effect.h"
#include "vm.h"

#include "hwrenderer/data/buffers.h"

Expand Down Expand Up @@ -1029,6 +1030,18 @@ struct sector_t
return pos == floor? floorplane:ceilingplane;
}

void SetPlaneReflectivity(int pos, double val)
{
if (pos < 0 || pos > 1) ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "pos must be either 0 or 1");
reflect[pos] = val;
}

double GetPlaneReflectivity(int pos)
{
if (pos < 0 || pos > 1) ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "pos must be either 0 or 1");
return reflect[pos];
}

bool isSecret() const
{
return !!(Flags & SECF_SECRET);
Expand Down
26 changes: 26 additions & 0 deletions src/scripting/vmthunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,32 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset)
ACTION_RETURN_INT(self->GetLightLevel());
}

static void SetPlaneReflectivity(sector_t* self, int pos, double val)
{
self->SetPlaneReflectivity(pos, val);
}

DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetPlaneReflectivity, SetPlaneReflectivity)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
PARAM_FLOAT(val)
self->SetPlaneReflectivity(pos, val);
return 0;
}

static double GetPlaneReflectivity(sector_t* self, int pos)
{
return self->GetPlaneReflectivity(pos);
}

DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetPlaneReflectivity, GetPlaneReflectivity)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
ACTION_RETURN_FLOAT(self->GetPlaneReflectivity(pos));
}

static int PortalBlocksView(sector_t *self, int pos)
{
return self->PortalBlocksView(pos);
Expand Down
2 changes: 2 additions & 0 deletions wadsrc/static/zscript/mapdata.zs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ struct Sector native play
native void ChangeLightLevel(int newval);
native void SetLightLevel(int newval);
native clearscope int GetLightLevel() const;
native void SetPlaneReflectivity(int pos, double val);
native clearscope double GetPlaneReflectivity(int pos);
native void AdjustFloorClip();
native clearscope bool IsLinked(Sector other, bool ceiling) const;

Expand Down