Finished Teleport Functionality

Now Doom Guy is the teleport location marker
This commit is contained in:
Simon 2020-04-07 23:39:04 +01:00
parent f29d7530c8
commit 05f9c30e73
5 changed files with 46 additions and 53 deletions

View file

@ -754,24 +754,28 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
if (thruportal == 1) thingpos += Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup);
// Some added checks if the camera actor is not supposed to be seen. It can happen that some portal setup has this actor in view in which case it may not be skipped here
float transparencyOverride = -1;
if (thing == camera) {
DVector3 thingorigin = thing->Pos();
//If we get here, then we want to override the location of the camera actor
if (s3d::Stereo3DMode::getCurrentMode().GetTeleportLocation(thingpos))
{
thingorigin = thingpos;
//Scale Doom Guy up a bit
sprscale *= 1.2;
}
if (!r_viewpoint.showviewer) {
DVector3 thingorigin = thing->Pos();
if (thruportal == 1)
thingorigin += Displacements.getOffset(thing->Sector->PortalGroup,
sector->PortalGroup);
if (fabs(thingorigin.X - r_viewpoint.ActorPos.X) < 2 &&
fabs(thingorigin.Y - r_viewpoint.ActorPos.Y) < 2)
fabs(thingorigin.Y - r_viewpoint.ActorPos.Y) < 2) {
return;
}
//If we get here, then we want to override the location of the camera actor
if (s3d::Stereo3DMode::getCurrentMode().GetTeleportLocation(thingpos))
{
thing->SetXYZ(thingpos);
transparencyOverride = 0.5;
}
}
}
@ -1043,7 +1047,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
translation = thing->Translation;
OverrideShader = -1;
trans = (transparencyOverride == -1.f) ? (float)thing->Alpha : transparencyOverride;
trans = (float)thing->Alpha;
hw_styleflags = STYLEHW_Normal;
if (RenderStyle.BlendOp >= STYLEOP_Fuzz && RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub)

View file

@ -271,19 +271,6 @@ namespace s3d
gl_RenderState.EnableModelMatrix(false);
}
static void vSMatrixFromOvrMatrix(VSMatrix& m1, const ovrMatrix4f& m2)
{
float tmp[16];
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
//Do the transpose step at the same time
tmp[4 * j + 1] = m2.M[i][j];
}
}
m1.loadMatrix(&tmp[0]);
}
bool OculusQuestMode::GetHandTransform(int hand, VSMatrix* mat) const
{
AActor* playermo = r_viewpoint.camera->player->mo;
@ -384,20 +371,10 @@ namespace s3d
bool OculusQuestMode::GetTeleportLocation(DVector3 &out) const
{
// Teleport?
DAngle yaw((doomYaw - hmdorientation[YAW]) + offhandangles[YAW]);
DAngle pitch(offhandangles[PITCH]);
double pixelstretch = level.info ? level.info->pixelstretch : 1.2;
player_t* player = r_viewpoint.camera ? r_viewpoint.camera->player : nullptr;
FLineTraceData trace;
if (ready_teleport &&
P_LineTrace(player->mo, yaw, 8192, pitch, TRF_ABSOFFSET,
((hmdPosition[1] + offhandoffset[1] + vr_height_adjust) * vr_vunits_per_meter) / pixelstretch,
-(offhandoffset[2] * vr_vunits_per_meter),
-(offhandoffset[0] * vr_vunits_per_meter), &trace) &&
(trace.HitType == TRACE_HitFloor)) {
out = trace.HitLocation;
if (vr_teleport &&
ready_teleport &&
m_TeleportTarget == TRACE_HitFloor) {
out = m_TeleportLocation;
return true;
}
@ -478,19 +455,31 @@ namespace s3d
}
if (vr_teleport) {
// Teleport?
DAngle yaw((doomYaw - hmdorientation[YAW]) + offhandangles[YAW]);
DAngle pitch(offhandangles[PITCH]);
FLineTraceData trace;
if (trigger_teleport &&
P_LineTrace(player->mo, yaw, 8192, pitch, TRF_ABSOFFSET,
((hmdPosition[1] + offhandoffset[1] + vr_height_adjust) * vr_vunits_per_meter) / pixelstretch,
-(offhandoffset[2] * vr_vunits_per_meter),
-(offhandoffset[0] * vr_vunits_per_meter), &trace) &&
trace.HitType == TRACE_HitFloor) {
double pixelstretch = level.info ? level.info->pixelstretch : 1.2;
// Teleport Logic
if (ready_teleport) {
FLineTraceData trace;
if (P_LineTrace(player->mo, yaw, 8192, pitch, TRF_ABSOFFSET|TRF_BLOCKUSE|TRF_BLOCKSELF|TRF_SOLIDACTORS,
((hmdPosition[1] + offhandoffset[1] + vr_height_adjust) *
vr_vunits_per_meter) / pixelstretch,
-(offhandoffset[2] * vr_vunits_per_meter),
-(offhandoffset[0] * vr_vunits_per_meter), &trace))
{
m_TeleportTarget = trace.HitType;
m_TeleportLocation = trace.HitLocation;
} else {
m_TeleportTarget = TRACE_HitNone;
m_TeleportLocation = DVector3(0, 0, 0);
}
}
else if (trigger_teleport && m_TeleportTarget == TRACE_HitFloor) {
auto vel = player->mo->Vel;
player->mo->Vel = DVector3(trace.HitLocation.X - player->mo->X(),
trace.HitLocation.Y - player->mo->Y(), 0);
player->mo->Vel = DVector3(m_TeleportLocation.X - player->mo->X(),
m_TeleportLocation.Y - player->mo->Y(), 0);
bool wasOnGround = player->mo->Z() <= player->mo->floorz;
double oldZ = player->mo->Z();
P_XYMovement(player->mo, DVector2(0, 0));

View file

@ -94,14 +94,14 @@ protected:
OculusQuestEyePose rightEyeView;
mutable int cachedScreenBlocks;
mutable int cachedViewwidth, cachedViewheight, cachedViewwindowx, cachedViewwindowy;
mutable F2DDrawer * cached2DDrawer;
mutable F2DDrawer * crossHairDrawer;
mutable ovrTracking2 tracking;
private:
typedef Stereo3DMode super;
uint32_t sceneWidth, sceneHeight;
mutable DVector3 m_TeleportLocation;
mutable int m_TeleportTarget;
};
} /* namespace st3d */

View file

@ -2288,7 +2288,7 @@ OptionMenu VROptionsMenu protected
Option "Control Scheme", "vr_control_scheme", "ControlScheme"
Option "Off-hand Move Direction", "vr_move_use_offhand", "OffOn"
Option "Use Teleport", "vr_teleport", "OnOff"
Slider "Snap-turn Angle", "vr_snapTurn", 0.0, 90.0, 1.0, 2c
Slider "Snap-turn Angle", "vr_snapTurn", 0.0, 90.0, 1.0, 2
StaticText " "
Slider "Walking Speed", "vr_move_speed", 5, 50, 1, 2
@ -2298,7 +2298,7 @@ OptionMenu VROptionsMenu protected
Slider "Weapon Pitch Adjust", "vr_weaponRotate", -45, 45, 5, 2
Slider "Weapon Scale", "vr_weaponScale", 0.1, 1.0, 0.01, 2
Option "Weapon Sprite 3D", "r_PlayerSprites3DMode", "Sprites3DMode"
Slider "Weapon Fat Item Width", "gl_fatItemWidth", 0, 1, 0.05, 0
Slider "Weapon Fat Item Width", "gl_fatItemWidth", 0.0, 1.0, 0.1, 2
Option "Weapon Recoil", "vr_recoil", "OnOff"
StaticText " "

Binary file not shown.