Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/gpu/gpu_py_matrix.c
| Show All 26 Lines | |||||
| * Mixing Python and C functions may still crash on invalid use. | * Mixing Python and C functions may still crash on invalid use. | ||||
| * | * | ||||
| * - Use ``bpygpu_`` for local API. | * - Use ``bpygpu_`` for local API. | ||||
| * - Use ``BPyGPU`` for public API. | * - Use ``BPyGPU`` for public API. | ||||
| */ | */ | ||||
| #include <Python.h> | #include <Python.h> | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "CLG_log.h" | |||||
| #include "../mathutils/mathutils.h" | #include "../mathutils/mathutils.h" | ||||
| #include "../generic/py_capi_utils.h" | #include "../generic/py_capi_utils.h" | ||||
| #define USE_GPU_PY_MATRIX_API | #define USE_GPU_PY_MATRIX_API | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #undef USE_GPU_PY_MATRIX_API | #undef USE_GPU_PY_MATRIX_API | ||||
| #include "gpu_py_matrix.h" /* own include */ | #include "gpu_py_matrix.h" /* own include */ | ||||
| static CLG_LogRef LOG = {"bpygpu.matrix"}; | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Helper Functions | /** \name Helper Functions | ||||
| * \{ */ | * \{ */ | ||||
| static bool bpygpu_stack_is_push_model_view_ok_or_error(void) | static bool bpygpu_stack_is_push_model_view_ok_or_error(void) | ||||
| { | { | ||||
| if (GPU_matrix_stack_level_get_model_view() >= GPU_PY_MATRIX_STACK_LEN) { | if (GPU_matrix_stack_level_get_model_view() >= GPU_PY_MATRIX_STACK_LEN) { | ||||
| PyErr_SetString(PyExc_RuntimeError, | PyErr_SetString(PyExc_RuntimeError, | ||||
| ▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | static PyObject *bpygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self) | ||||
| } | } | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| static PyObject *bpygpu_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self, PyObject *UNUSED(args)) | static PyObject *bpygpu_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self, PyObject *UNUSED(args)) | ||||
| { | { | ||||
| /* sanity - should never happen */ | /* sanity - should never happen */ | ||||
| if (self->level == -1) { | if (self->level == -1) { | ||||
| fprintf(stderr, "Not yet in use\n"); | CLOG_ERROR(&LOG, "Not yet in use"); | ||||
| goto finally; | goto finally; | ||||
| } | } | ||||
| if (self->type == PYGPU_MATRIX_TYPE_MODEL_VIEW) { | if (self->type == PYGPU_MATRIX_TYPE_MODEL_VIEW) { | ||||
| const int level = GPU_matrix_stack_level_get_model_view(); | const int level = GPU_matrix_stack_level_get_model_view(); | ||||
| if (level != self->level) { | if (level != self->level) { | ||||
| fprintf(stderr, "Level push/pop mismatch, expected %d, got %d\n", self->level, level); | CLOG_ERROR(&LOG, "Level push/pop mismatch, expected %d, got %d", self->level, level); | ||||
| } | } | ||||
| if (level != 0) { | if (level != 0) { | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| } | } | ||||
| } | } | ||||
| else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) { | else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) { | ||||
| const int level = GPU_matrix_stack_level_get_projection(); | const int level = GPU_matrix_stack_level_get_projection(); | ||||
| if (level != self->level) { | if (level != self->level) { | ||||
| fprintf(stderr, "Level push/pop mismatch, expected %d, got %d", self->level, level); | CLOG_ERROR(&LOG, "Level push/pop mismatch, expected %d, got %d", self->level, level); | ||||
| } | } | ||||
| if (level != 0) { | if (level != 0) { | ||||
| GPU_matrix_pop_projection(); | GPU_matrix_pop_projection(); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 328 Lines • Show Last 20 Lines | |||||