From cacf9ebb7fd8df8845daca9da2fe55456cc179aa Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 9 Nov 2016 23:55:06 -0300 Subject: all light types and shadows are working, pending a lot of clean-up --- core/math/camera_matrix.cpp | 22 ++++++++++++++++++++++ core/math/camera_matrix.h | 2 ++ core/math/math_funcs.h | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'core/math') diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index f7dd8839b..3e3cd1af4 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -495,6 +495,28 @@ void CameraMatrix::set_light_bias() { } +void CameraMatrix::set_light_atlas_rect(const Rect2& p_rect) { + + float *m=&matrix[0][0]; + + m[0]=p_rect.size.width, + m[1]=0.0, + m[2]=0.0, + m[3]=0.0, + m[4]=0.0, + m[5]=p_rect.size.height, + m[6]=0.0, + m[7]=0.0, + m[8]=0.0, + m[9]=0.0, + m[10]=1.0, + m[11]=0.0, + m[12]=p_rect.pos.x, + m[13]=p_rect.pos.y, + m[14]=0.0, + m[15]=1.0; +} + CameraMatrix::operator String() const { String str; diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index d192b1fef..bf8cf3592 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -30,6 +30,7 @@ #define CAMERA_MATRIX_H #include "transform.h" +#include "math_2d.h" /** @author Juan Linietsky */ @@ -53,6 +54,7 @@ struct CameraMatrix { void set_identity(); void set_zero(); void set_light_bias(); + void set_light_atlas_rect(const Rect2& p_rect); void set_perspective(float p_fovy_degrees, float p_aspect, float p_z_near, float p_z_far,bool p_flip_fov=false); void set_orthogonal(float p_left, float p_right, float p_bottom, float p_top, float p_znear, float p_zfar); void set_orthogonal(float p_size, float p_aspect, float p_znear, float p_zfar,bool p_flip_fov=false); diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index c8ced0b30..9d7e881c6 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -208,7 +208,7 @@ public: } } - static _FORCE_INLINE_ float halfptr_to_float(uint16_t *h) { + static _FORCE_INLINE_ float halfptr_to_float(const uint16_t *h) { union { uint32_t u32; -- cgit v1.3.1