MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / pvDecompress

Function pvDecompress

ogsr_engine/xrCore/_compressed_normal.cpp:103–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void pvDecompress(Fvector& vec, u16 mVec)
104{
105 // if we do a straightforward backward transform
106 // we will get points on the plane X0,Y0,Z0
107 // however we need points on a sphere that goes through these points.
108 // therefore we need to adjust x,y,z so that x^2+y^2+z^2=1
109
110 // by normalizing the vector3. We have already precalculated the amount
111 // by which we need to scale, so all we do is a table lookup and a
112 // multiplication
113
114 // get the x and y bits
115 int xbits = ((mVec & pvTOP_MASK) >> 7);
116 int ybits = (mVec & pvBOTTOM_MASK);
117
118 // map the numbers back to the triangle (0,0)-(0,126)-(126,0)
119 if ((xbits + ybits) >= 127)
120 {
121 xbits = 127 - xbits;
122 ybits = 127 - ybits;
123 }
124
125 // do the inverse transform and normalization
126 // costs 3 extra multiplies and 2 subtracts. No big deal.
127 float uvadj = pvUVAdjustment[mVec & ~pvSIGN_MASK];
128 vec.x = uvadj * float(xbits);
129 vec.y = uvadj * float(ybits);
130 vec.z = uvadj * float(126 - xbits - ybits);
131
132 // set all the sign bits
133 if (mVec & pvXSIGN_MASK)
134 set_negative(vec.x);
135 if (mVec & pvYSIGN_MASK)
136 set_negative(vec.y);
137 if (mVec & pvZSIGN_MASK)
138 set_negative(vec.z);
139}

Callers 11

draw_nodesMethod · 0.85
pitch_correctionMethod · 0.85
contourMethod · 0.85
vertex_plane_yMethod · 0.85
assign_y_valuesMethod · 0.85
r_dirMethod · 0.85
r_sdirMethod · 0.85
r_dirMethod · 0.85
r_sdirMethod · 0.85
r_dirFunction · 0.85
r_sdirFunction · 0.85

Calls 1

set_negativeFunction · 0.85

Tested by

no test coverage detected