Generalized hitnormal functions (where possible).
This commit is contained in:
parent
1d759a109a
commit
b1683dae8e
24 changed files with 206 additions and 785 deletions
|
|
@ -424,24 +424,9 @@ Class FancyConfetti : SWWMNonInteractiveActor
|
|||
double ang = atan2(dir.y,dir.x);
|
||||
double pt = asin(-dir.z);
|
||||
LineTrace(ang,dist,pt,TRF_THRUACTORS|TRF_THRUHITSCAN|TRF_ABSPOSITION,newpos.z,newpos.x,newpos.y,d);
|
||||
Vector3 hitnormal = -d.HitDir;
|
||||
if ( d.HitType == TRACE_HitFloor )
|
||||
{
|
||||
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.top.Normal;
|
||||
else hitnormal = d.HitSector.floorplane.Normal;
|
||||
}
|
||||
else if ( d.HitType == TRACE_HitCeiling )
|
||||
{
|
||||
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.bottom.Normal;
|
||||
else hitnormal = d.HitSector.ceilingplane.Normal;
|
||||
}
|
||||
else if ( d.HitType == TRACE_HitWall )
|
||||
{
|
||||
hitnormal = (-d.HitLine.delta.y,d.HitLine.delta.x,0).unit();
|
||||
if ( !d.LineSide ) hitnormal *= -1;
|
||||
}
|
||||
if ( (d.HitType != TRACE_HitNone) && (d.HitType != TRACE_HitFloor) )
|
||||
{
|
||||
Vector3 hitnormal = SWWMUtility.GetLineTraceHitNormal(d);
|
||||
dist -= d.Distance;
|
||||
// should only happen if we bounced
|
||||
dir = d.HitDir-(1.2*hitnormal*(d.HitDir dot hitnormal));
|
||||
|
|
|
|||
|
|
@ -386,45 +386,7 @@ Class TheBall : Actor
|
|||
void A_HandleBounce()
|
||||
{
|
||||
lasthit = null;
|
||||
Vector3 HitNormal = -vel.unit();
|
||||
F3DFloor ff;
|
||||
if ( BlockingFloor )
|
||||
{
|
||||
// find closest 3d floor for its normal
|
||||
for ( int i=0; i<BlockingFloor.Get3DFloorCount(); i++ )
|
||||
{
|
||||
if ( !(BlockingFloor.Get3DFloor(i).flags&F3DFloor.FF_SOLID) ) continue;
|
||||
if ( !(BlockingFloor.Get3DFloor(i).top.ZAtPoint(pos.xy) ~== floorz) ) continue;
|
||||
ff = BlockingFloor.Get3DFloor(i);
|
||||
break;
|
||||
}
|
||||
if ( ff ) HitNormal = -ff.top.Normal;
|
||||
else HitNormal = BlockingFloor.floorplane.Normal;
|
||||
}
|
||||
else if ( BlockingCeiling )
|
||||
{
|
||||
// find closest 3d floor for its normal
|
||||
for ( int i=0; i<BlockingCeiling.Get3DFloorCount(); i++ )
|
||||
{
|
||||
if ( !(BlockingCeiling.Get3DFloor(i).flags&F3DFloor.FF_SOLID) ) continue;
|
||||
if ( !(BlockingCeiling.Get3DFloor(i).bottom.ZAtPoint(pos.xy) ~== ceilingz) ) continue;
|
||||
ff = BlockingCeiling.Get3DFloor(i);
|
||||
break;
|
||||
}
|
||||
if ( ff ) HitNormal = -ff.bottom.Normal;
|
||||
else HitNormal = BlockingCeiling.ceilingplane.Normal;
|
||||
}
|
||||
else if ( BlockingLine )
|
||||
{
|
||||
HitNormal = (-BlockingLine.delta.y,BlockingLine.delta.x,0).unit();
|
||||
int wside = SWWMUtility.PointOnLineSide(pos.xy,BlockingLine);
|
||||
if ( !wside ) HitNormal *= -1;
|
||||
}
|
||||
else if ( BlockingMobj )
|
||||
{
|
||||
Vector3 diff = level.Vec3Diff(BlockingMobj.Vec3Offset(0,0,BlockingMobj.Height/2),pos);
|
||||
HitNormal = diff.unit();
|
||||
}
|
||||
Vector3 HitNormal = SWWMUtility.GetActorHitNormal(self);
|
||||
// send the needed data for a bust
|
||||
if ( (special1 == 2) || swwm_omnibust )
|
||||
{
|
||||
|
|
@ -663,23 +625,8 @@ Class SaltBeam : SWWMNonInteractiveActor
|
|||
if ( t.Results.HitActor && t.Results.HitActor.bIsMonster && !Random[Spreadgun](0,3) )
|
||||
t.Results.HitActor.Howl();
|
||||
}
|
||||
Vector3 norm = -x;
|
||||
if ( t.Results.HitType == TRACE_HitWall )
|
||||
{
|
||||
norm = (t.Results.HitLine.delta.y,-t.Results.HitLine.delta.x,0).unit();
|
||||
if ( t.Results.Side ) norm *= -1;
|
||||
t.Results.HitLine.RemoteActivate(tracer,t.Results.Side,SPAC_Impact,t.Results.HitPos);
|
||||
}
|
||||
else if ( t.Results.HitType == TRACE_HitFloor )
|
||||
{
|
||||
if ( t.Results.ffloor ) norm = -t.Results.ffloor.top.Normal;
|
||||
else norm = t.Results.HitSector.floorplane.Normal;
|
||||
}
|
||||
else if ( t.Results.HitType == TRACE_HitCeiling )
|
||||
{
|
||||
if ( t.Results.ffloor ) norm = -t.Results.ffloor.bottom.Normal;
|
||||
else norm = t.Results.HitSector.ceilingplane.Normal;
|
||||
}
|
||||
Vector3 norm = SWWMUtility.GetLineTracerHitNormal(t.Results);
|
||||
if ( t.Results.HitType == TRACE_HitWall ) t.Results.HitLine.RemoteActivate(tracer,t.Results.Side,SPAC_Impact,t.Results.HitPos);
|
||||
if ( t.Results.HitType != TRACE_HasHitSky )
|
||||
{
|
||||
let i = Spawn("SaltImpact",level.Vec3Offset(t.Results.HitPos,norm*4));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue