This commit is contained in:
Christoph Oelckers 2018-09-29 12:59:11 +02:00
commit 86c7e87767
6 changed files with 37 additions and 13 deletions

View file

@ -438,6 +438,7 @@ PClassActor *PClassActor::GetReplacement(bool lookskill)
}
// The Replacement field is temporarily NULLed to prevent
// potential infinite recursion.
PClassActor *oldrep = ActorInfo()->Replacement;
ActorInfo()->Replacement = nullptr;
PClassActor *rep = Replacement;
// Handle skill-based replacement here. It has precedence on DECORATE replacement
@ -451,7 +452,7 @@ PClassActor *PClassActor::GetReplacement(bool lookskill)
// Skill replacements are not recursive, contrarily to DECORATE replacements
rep = rep->GetReplacement(false);
// Reset the temporarily NULLed field
ActorInfo()->Replacement = Replacement;
ActorInfo()->Replacement = oldrep;
return rep;
}

View file

@ -1158,6 +1158,14 @@ AInventory *AActor::DropInventory (AInventory *item, int amt)
drop->Vel += Vel;
drop->flags &= ~MF_NOGRAVITY; // Don't float
drop->ClearCounters(); // do not count for statistics again
{
// [MK] call OnDrop so item can change its drop behaviour
IFVIRTUALPTR(drop, AInventory, OnDrop)
{
VMValue params[] = { drop, this };
VMCall(func, params, 2, nullptr, 0);
}
}
return drop;
}

View file

@ -123,11 +123,14 @@ void FUE1Model::LoadGeometry()
// unpack coords
for ( int j=0; j<3; j++ )
Poly.C[j] = FVector2(dpolys[i].uv[j][0]/255.f,dpolys[i].uv[j][1]/255.f);
// compute facet normal
FVector3 dir[2];
dir[0] = verts[Poly.V[1]].Pos-verts[Poly.V[0]].Pos;
dir[1] = verts[Poly.V[2]].Pos-verts[Poly.V[0]].Pos;
Poly.Normal = dir[0]^dir[1];
// compute facet normals
for ( int j=0; j<numFrames; j++ )
{
FVector3 dir[2];
dir[0] = verts[Poly.V[1]+numVerts*j].Pos-verts[Poly.V[0]+numVerts*j].Pos;
dir[1] = verts[Poly.V[2]+numVerts*j].Pos-verts[Poly.V[0]+numVerts*j].Pos;
Poly.Normals.Push(dir[0]^dir[1]);
}
// push
polys.Push(Poly);
}
@ -142,7 +145,7 @@ void FUE1Model::LoadGeometry()
for ( int k=0; k<numPolys; k++ )
{
if ( (polys[k].V[0] != j) && (polys[k].V[1] != j) && (polys[k].V[2] != j) ) continue;
nsum += polys[k].Normal;
nsum += polys[k].Normals[i];
}
verts[j+numVerts*i].Normal = nsum.Unit();
}
@ -198,6 +201,8 @@ void FUE1Model::UnloadGeometry()
numPolys = 0;
numGroups = 0;
verts.Reset();
for ( int i=0; i<numPolys; i++ )
polys[i].Normals.Reset();
polys.Reset();
for ( int i=0; i<numGroups; i++ )
groups[i].P.Reset();
@ -275,9 +280,9 @@ void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
vert->Set(V.Pos.X,V.Pos.Y,V.Pos.Z,C.X,C.Y);
if ( groups[j].type&PT_Curvy ) // use facet normal
{
vert->SetNormal(polys[groups[j].P[k]].Normal.X,
polys[groups[j].P[k]].Normal.Y,
polys[groups[j].P[k]].Normal.Z);
vert->SetNormal(polys[groups[j].P[k]].Normals[i].X,
polys[groups[j].P[k]].Normals[i].Y,
polys[groups[j].P[k]].Normals[i].Z);
}
else vert->SetNormal(V.Normal.X,V.Normal.Y,V.Normal.Z);
}

View file

@ -89,7 +89,7 @@ private:
{
int V[3];
FVector2 C[3];
FVector3 Normal;
TArray<FVector3> Normals;
};
struct UE1Group
{

View file

@ -147,7 +147,7 @@ float R_DoomLightingEquation(float light)
lightscale = shade - vis;
// Result is the normalized colormap index (0 bright .. 1 dark)
return clamp(lightscale, 0.0, 31.0 / 32.0);
return clamp(lightscale, 1.0 - light, 31.0 / 32.0);
}
//===========================================================================

View file

@ -906,7 +906,17 @@ class Inventory : Actor native
return item;
}
//===========================================================================
//
// AInventory :: OnDrop
//
// Called by AActor::DropInventory. Allows items to modify how they behave
// after being dropped.
//
//===========================================================================
virtual void OnDrop (Actor dropper) {}
}
//===========================================================================