Skip to content

Commit

Permalink
Add scalar template specialisation to fix compilation in VC++ which h…
Browse files Browse the repository at this point in the history
…ad problems resolving the overloads.

Fix a precision loss warning.
Replace c_pi with math::PI.
Remove a duplicate _name member in OpenGLShader.
  • Loading branch information
codereader committed Mar 29, 2021
1 parent 3d14009 commit d16099e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libs/math/Vector3.h
Expand Up @@ -453,7 +453,7 @@ class BasicVector3
};

/// Multiply vector components with a scalar and return the result
template <typename T, typename S>
template <typename T, typename S, typename SMustBeScalar = std::enable_if<std::is_scalar<S>::value>::type>
BasicVector3<T> operator*(const BasicVector3<T>& v, S s)
{
T factor = static_cast<T>(s);
Expand Down
5 changes: 4 additions & 1 deletion libs/render/Colour4.h
Expand Up @@ -32,7 +32,10 @@ class Colour4: public Vector4f
/// Construct a Colour4 from a Vector3 and optional alpha
template<typename U>
Colour4(const BasicVector3<U>& vec, float alpha = 1.0f)
: Vector4f(vec.x(), vec.y(), vec.z(), alpha)
: Vector4f(static_cast<ElementType>(vec.x()),
static_cast<ElementType>(vec.y()),
static_cast<ElementType>(vec.z()),
alpha)
{}

/// Return true if this colour contains valid component values
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/materials/editor/MaterialPreview.cpp
Expand Up @@ -172,7 +172,7 @@ bool MaterialPreview::onPreRender()
auto time = _renderSystem->getTime();

// one full rotation per 10 seconds
auto newAngle = 2 * c_pi * time / 10000;
auto newAngle = 2 * math::PI * time / 10000;

Node_getEntity(_entity)->setKeyValue("angle", string::to_string(radians_to_degrees(newAngle)));
}
Expand Down
2 changes: 0 additions & 2 deletions radiantcore/rendersystem/backend/OpenGLShader.cpp
Expand Up @@ -641,8 +641,6 @@ void OpenGLShader::constructNormalShader()
// Main shader construction entry point
void OpenGLShader::construct()
{
_name = name;

// Retrieve the highlight colour from the colourschemes (once)
const static Colour4 highLightColour(
GlobalColourSchemeManager().getColour("selected_brush_camera"), 0.3f
Expand Down
5 changes: 1 addition & 4 deletions radiantcore/rendersystem/backend/OpenGLShader.h
Expand Up @@ -21,6 +21,7 @@ class OpenGLShader final :
public Shader
{
private:
// Name used to construct the shader
std::string _name;

// The state manager we will be inserting/removing OpenGL states from
Expand All @@ -30,10 +31,6 @@ class OpenGLShader final :
typedef std::list<OpenGLShaderPassPtr> Passes;
Passes _shaderPasses;

// Name used to construct the shader. Currently only used for
// tests/debugging.
std::string _name;

// The Material corresponding to this OpenGLShader
MaterialPtr _material;
sigc::connection _materialChanged;
Expand Down

0 comments on commit d16099e

Please sign in to comment.