Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-11-01 17:20:31 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-11-01 17:20:50 +0300
commit623574ffa23badf767d8a445f1c18aabdbd10e26 (patch)
tree0a200bb397590031fb658eeaccb6b139a5876f6b /source/blender/blenkernel/intern/subdiv_inline.h
parentd710cb91b9281e94851bddc8b49b570dc6326b5f (diff)
Subdiv: Cleanup, de-duplicate some code
Diffstat (limited to 'source/blender/blenkernel/intern/subdiv_inline.h')
-rw-r--r--source/blender/blenkernel/intern/subdiv_inline.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_inline.h b/source/blender/blenkernel/intern/subdiv_inline.h
index c9e924ced82..0e715506ed3 100644
--- a/source/blender/blenkernel/intern/subdiv_inline.h
+++ b/source/blender/blenkernel/intern/subdiv_inline.h
@@ -31,6 +31,7 @@
#define __BKE_SUBDIV_INLINE_H__
#include "BKE_subdiv.h"
+#include "BLI_utildefines.h"
BLI_INLINE void BKE_subdiv_ptex_face_uv_to_grid_uv(
const float ptex_u, const float ptex_v,
@@ -45,4 +46,33 @@ BLI_INLINE int BKE_subdiv_grid_size_from_level(const int level)
return (1 << (level - 1)) + 1;
}
+BLI_INLINE int BKE_subdiv_rotate_quad_to_corner(
+ const float u, const float v,
+ float *r_u, float *r_v)
+{
+ int corner;
+ if (u <= 0.5f && v <= 0.5f) {
+ corner = 0;
+ *r_u = 2.0f * u;
+ *r_v = 2.0f * v;
+ }
+ else if (u > 0.5f && v <= 0.5f) {
+ corner = 1;
+ *r_u = 2.0f * v;
+ *r_v = 2.0f * (1.0f - u);
+ }
+ else if (u > 0.5f && v > 0.5f) {
+ corner = 2;
+ *r_u = 2.0f * (1.0f - u);
+ *r_v = 2.0f * (1.0f - v);
+ }
+ else {
+ BLI_assert(u <= 0.5f && v >= 0.5f);
+ corner = 3;
+ *r_u = 2.0f * (1.0f - v);
+ *r_v = 2.0f * u;
+ }
+ return corner;
+}
+
#endif /* __BKE_SUBDIV_INLINE_H__ */