mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-12-02 09:02:32 +00:00
[renderer] Make R_BillboarFrame's comments true
While they weren't entirely false, they were overly verbose and thus clouded the point.
This commit is contained in:
parent
3a17e062da
commit
1df3c2eea0
1 changed files with 14 additions and 28 deletions
|
@ -54,17 +54,12 @@ R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case SPR_FACING_UPRIGHT:
|
case SPR_FACING_UPRIGHT:
|
||||||
// generate the sprite's axes, with vup straight up in worldspace,
|
// the billboard has its up vector parallel with world up, and
|
||||||
// and bbright perpendicular to cameravec. This will not work if
|
// its right vector perpendicular to cameravec.
|
||||||
// the camera origin is directly above the entity origin
|
// Undefined if the camera is too close to the entity.
|
||||||
// (cameravec is straight up or down), because the cross product
|
|
||||||
// will be between two nearly parallel vectors and starts to
|
|
||||||
// approach an undefined state, so we don't draw if the two
|
|
||||||
// vectors are less than 1 degree apart
|
|
||||||
VectorNegate (cameravec, tvec);
|
VectorNegate (cameravec, tvec);
|
||||||
VectorNormalize (tvec);
|
VectorNormalize (tvec);
|
||||||
dot = tvec[2]; // same as DotProduct (tvec, bbup) because
|
dot = tvec[2]; // DotProduct (tvec, world up)
|
||||||
// bbup is 0, 0, 1
|
|
||||||
if ((dot > 0.999848) || (dot < -0.999848)) // cos(1 degree)
|
if ((dot > 0.999848) || (dot < -0.999848)) // cos(1 degree)
|
||||||
return 0;
|
return 0;
|
||||||
VectorSet (0, 0, 1, bbup);
|
VectorSet (0, 0, 1, bbup);
|
||||||
|
@ -75,24 +70,17 @@ R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
||||||
VectorSet (-bbright[1], bbright[0], 0, bbpn);
|
VectorSet (-bbright[1], bbright[0], 0, bbpn);
|
||||||
break;
|
break;
|
||||||
case SPR_VP_PARALLEL:
|
case SPR_VP_PARALLEL:
|
||||||
// generate the sprite's axes, completely parallel to the
|
// the billboard always has the same orientation as the camera
|
||||||
// viewplane. There are no problem situations, because the
|
|
||||||
// sprite is always in the same orientation relative to the viewer
|
|
||||||
VectorCopy (vup, bbup);
|
VectorCopy (vup, bbup);
|
||||||
VectorCopy (vright, bbright);
|
VectorCopy (vright, bbright);
|
||||||
VectorCopy (vpn, bbpn);
|
VectorCopy (vpn, bbpn);
|
||||||
break;
|
break;
|
||||||
case SPR_VP_PARALLEL_UPRIGHT:
|
case SPR_VP_PARALLEL_UPRIGHT:
|
||||||
// generate the sprite's axes, with vup straight up in worldspace,
|
// the billboar has its up vector parallel with world up, and
|
||||||
// and bbright parallel to the viewplane.
|
// its right vector parallel with the view plane.
|
||||||
// This will not work if the view direction is very close to
|
// Undefined if the camera is looking straight up or down.
|
||||||
// straight up or down, because the cross product will be between
|
dot = vpn[2]; // DotProduct (vpn, world up)
|
||||||
// two nearly parallel vectors and starts to approach an undefined
|
if ((dot > 0.999848) || (dot < -0.999848)) // cos(1 degree)
|
||||||
// state, so we don't draw if the two vectors are less than 1
|
|
||||||
// degree apart
|
|
||||||
dot = vpn[2]; // same as DotProduct (vpn, bbup) because
|
|
||||||
// bbup is 0, 0, 1
|
|
||||||
if ((dot > 0.999848) || (dot < -0.999848)) // cos(1 degree) =
|
|
||||||
return 0;
|
return 0;
|
||||||
VectorSet (0, 0, 1, bbup);
|
VectorSet (0, 0, 1, bbup);
|
||||||
//CrossProduct(bbup, vpn, bbright)
|
//CrossProduct(bbup, vpn, bbright)
|
||||||
|
@ -103,8 +91,8 @@ R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
||||||
break;
|
break;
|
||||||
case SPR_ORIENTED:
|
case SPR_ORIENTED:
|
||||||
{
|
{
|
||||||
// generate the sprite's axes, according to the sprite's world
|
// The billboard's orientation is fully specified by the
|
||||||
// orientation
|
// entity's orientation.
|
||||||
mat4f_t mat;
|
mat4f_t mat;
|
||||||
Transform_GetWorldMatrix (ent->transform, mat);
|
Transform_GetWorldMatrix (ent->transform, mat);
|
||||||
VectorCopy (mat[0], bbpn);
|
VectorCopy (mat[0], bbpn);
|
||||||
|
@ -114,10 +102,8 @@ R_BillboardFrame (entity_t *ent, int orientation, const vec3_t cameravec,
|
||||||
break;
|
break;
|
||||||
case SPR_VP_PARALLEL_ORIENTED:
|
case SPR_VP_PARALLEL_ORIENTED:
|
||||||
{
|
{
|
||||||
// generate the sprite's axes, parallel to the viewplane, but
|
// The billboard is rotated relative to the camera using
|
||||||
// rotated in that plane around the center according to the
|
// the entity's local rotation.
|
||||||
// sprite entity's roll angle. So vpn stays the same, but
|
|
||||||
// vright and vup rotate
|
|
||||||
vec4f_t rot = Transform_GetLocalRotation (ent->transform);
|
vec4f_t rot = Transform_GetLocalRotation (ent->transform);
|
||||||
// FIXME needs proper testing (need to find, make, or fake a
|
// FIXME needs proper testing (need to find, make, or fake a
|
||||||
// parallel oriented sprite)
|
// parallel oriented sprite)
|
||||||
|
|
Loading…
Reference in a new issue