mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibGfx+LibSoftGPU: Allow indexed reads into Gfx::Vector
This commit is contained in:
parent
20a5a4363c
commit
870b835115
2 changed files with 9 additions and 22 deletions
|
@ -56,6 +56,12 @@ public:
|
||||||
constexpr void set_z(T value) requires(N >= 3) { m_data[2] = value; }
|
constexpr void set_z(T value) requires(N >= 3) { m_data[2] = value; }
|
||||||
constexpr void set_w(T value) requires(N >= 4) { m_data[3] = value; }
|
constexpr void set_w(T value) requires(N >= 4) { m_data[3] = value; }
|
||||||
|
|
||||||
|
[[nodiscard]] constexpr T operator[](size_t index) const
|
||||||
|
{
|
||||||
|
VERIFY(index < N);
|
||||||
|
return m_data[index];
|
||||||
|
}
|
||||||
|
|
||||||
constexpr VectorN& operator+=(const VectorN& other)
|
constexpr VectorN& operator+=(const VectorN& other)
|
||||||
{
|
{
|
||||||
UNROLL_LOOP
|
UNROLL_LOOP
|
||||||
|
|
|
@ -609,7 +609,7 @@ static void generate_texture_coordinates(Vertex& vertex, RasterizerOptions const
|
||||||
auto const normal = vertex.normal;
|
auto const normal = vertex.normal;
|
||||||
auto reflection = eye_unit_xyz - normal * 2 * normal.dot(eye_unit_xyz);
|
auto reflection = eye_unit_xyz - normal * 2 * normal.dot(eye_unit_xyz);
|
||||||
reflection.set_z(reflection.z() + 1);
|
reflection.set_z(reflection.z() + 1);
|
||||||
auto const reflection_value = (config_index == 0) ? reflection.x() : reflection.y();
|
auto const reflection_value = reflection[config_index];
|
||||||
return reflection_value / (2 * reflection.length()) + 0.5f;
|
return reflection_value / (2 * reflection.length()) + 0.5f;
|
||||||
}
|
}
|
||||||
case TexCoordGenerationMode::ReflectionMap: {
|
case TexCoordGenerationMode::ReflectionMap: {
|
||||||
|
@ -617,29 +617,10 @@ static void generate_texture_coordinates(Vertex& vertex, RasterizerOptions const
|
||||||
FloatVector3 const eye_unit_xyz = eye_unit.xyz();
|
FloatVector3 const eye_unit_xyz = eye_unit.xyz();
|
||||||
auto const normal = vertex.normal;
|
auto const normal = vertex.normal;
|
||||||
auto reflection = eye_unit_xyz - normal * 2 * normal.dot(eye_unit_xyz);
|
auto reflection = eye_unit_xyz - normal * 2 * normal.dot(eye_unit_xyz);
|
||||||
switch (config_index) {
|
return reflection[config_index];
|
||||||
case 0:
|
|
||||||
return reflection.x();
|
|
||||||
case 1:
|
|
||||||
return reflection.y();
|
|
||||||
case 2:
|
|
||||||
return reflection.z();
|
|
||||||
default:
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case TexCoordGenerationMode::NormalMap: {
|
case TexCoordGenerationMode::NormalMap: {
|
||||||
auto const normal = vertex.normal;
|
return vertex.normal[config_index];
|
||||||
switch (config_index) {
|
|
||||||
case 0:
|
|
||||||
return normal.x();
|
|
||||||
case 1:
|
|
||||||
return normal.y();
|
|
||||||
case 2:
|
|
||||||
return normal.z();
|
|
||||||
default:
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue