Blender V5.3
gpu_py_matrix.cc File Reference
#include <Python.h>
#include "BLI_utildefines.hh"
#include "../mathutils/mathutils.hh"
#include "GPU_matrix.hh"
#include "gpu_py.hh"
#include "gpu_py_matrix.hh"

Go to the source code of this file.

Classes

struct  blender::BPyGPU_MatrixStackContext

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define USE_GPU_PY_MATRIX_API

Functions

Helper Functions
static bool blender::pygpu_stack_is_push_model_view_ok_or_error ()
static bool blender::pygpu_stack_is_push_projection_ok_or_error ()
static bool blender::pygpu_stack_is_pop_model_view_ok_or_error ()
static bool blender::pygpu_stack_is_pop_projection_ok_or_error ()
Manage Stack
 blender::PyDoc_STRVAR (pygpu_matrix_push_doc, ".. function:: push()\n" "\n" " Add to the model-view matrix stack.\n")
static PyObject * blender::pygpu_matrix_push (PyObject *)
 blender::PyDoc_STRVAR (pygpu_matrix_pop_doc, ".. function:: pop()\n" "\n" " Remove the last model-view matrix from the stack.\n")
static PyObject * blender::pygpu_matrix_pop (PyObject *)
 blender::PyDoc_STRVAR (pygpu_matrix_push_projection_doc, ".. function:: push_projection()\n" "\n" " Add to the projection matrix stack.\n")
static PyObject * blender::pygpu_matrix_push_projection (PyObject *)
 blender::PyDoc_STRVAR (pygpu_matrix_pop_projection_doc, ".. function:: pop_projection()\n" "\n" " Remove the last projection matrix from the stack.\n")
static PyObject * blender::pygpu_matrix_pop_projection (PyObject *)
Manipulate State
 blender::PyDoc_STRVAR (pygpu_matrix_multiply_matrix_doc, ".. function:: multiply_matrix(matrix)\n" "\n" " Multiply the current stack matrix.\n" "\n" " :param matrix: A 4x4 matrix.\n" " :type matrix: :class:`mathutils.Matrix`\n")
static PyObject * blender::pygpu_matrix_multiply_matrix (PyObject *, PyObject *value)
 blender::PyDoc_STRVAR (pygpu_matrix_scale_doc, ".. function:: scale(scale)\n" "\n" " Scale the current stack matrix.\n" "\n" " :param scale: Scale the current stack matrix with 2 or 3 floats.\n" " :type scale: Sequence[float]\n")
static PyObject * blender::pygpu_matrix_scale (PyObject *, PyObject *value)
 blender::PyDoc_STRVAR (pygpu_matrix_scale_uniform_doc, ".. function:: scale_uniform(scale)\n" "\n" " Scale the current stack matrix uniformly.\n" "\n" " :param scale: Uniform scale factor.\n" " :type scale: float\n")
static PyObject * blender::pygpu_matrix_scale_uniform (PyObject *, PyObject *value)
 blender::PyDoc_STRVAR (pygpu_matrix_translate_doc, ".. function:: translate(offset)\n" "\n" " Translate the current stack matrix.\n" "\n" " :param offset: Translate the current stack matrix with 2 or 3 floats.\n" " :type offset: Sequence[float]\n")
static PyObject * blender::pygpu_matrix_translate (PyObject *, PyObject *value)
Write State
 blender::PyDoc_STRVAR (pygpu_matrix_reset_doc, ".. function:: reset()\n" "\n" " Empty stack and set to identity.\n")
static PyObject * blender::pygpu_matrix_reset (PyObject *)
 blender::PyDoc_STRVAR (pygpu_matrix_load_identity_doc, ".. function:: load_identity()\n" "\n" " Load an identity matrix into the stack.\n")
static PyObject * blender::pygpu_matrix_load_identity (PyObject *)
 blender::PyDoc_STRVAR (pygpu_matrix_load_matrix_doc, ".. function:: load_matrix(matrix)\n" "\n" " Load a matrix into the stack.\n" "\n" " :param matrix: A 4x4 matrix.\n" " :type matrix: :class:`mathutils.Matrix`\n")
static PyObject * blender::pygpu_matrix_load_matrix (PyObject *, PyObject *value)
 blender::PyDoc_STRVAR (pygpu_matrix_load_projection_matrix_doc, ".. function:: load_projection_matrix(matrix)\n" "\n" " Load a projection matrix into the stack.\n" "\n" " :param matrix: A 4x4 matrix.\n" " :type matrix: :class:`mathutils.Matrix`\n")
static PyObject * blender::pygpu_matrix_load_projection_matrix (PyObject *, PyObject *value)
Read State
 blender::PyDoc_STRVAR (pygpu_matrix_get_projection_matrix_doc, ".. function:: get_projection_matrix()\n" "\n" " Return a copy of the projection matrix.\n" "\n" " :return: A 4x4 projection matrix.\n" " :rtype: :class:`mathutils.Matrix`\n")
static PyObject * blender::pygpu_matrix_get_projection_matrix (PyObject *)
 blender::PyDoc_STRVAR (pygpu_matrix_get_model_view_matrix_doc, ".. function:: get_model_view_matrix()\n" "\n" " Return a copy of the model-view matrix.\n" "\n" " :return: A 4x4 view matrix.\n" " :rtype: :class:`mathutils.Matrix`\n")
static PyObject * blender::pygpu_matrix_get_model_view_matrix (PyObject *)
 blender::PyDoc_STRVAR (pygpu_matrix_get_normal_matrix_doc, ".. function:: get_normal_matrix()\n" "\n" " Return a copy of the normal matrix.\n" "\n" " :return: A 3x3 normal matrix.\n" " :rtype: :class:`mathutils.Matrix`\n")
static PyObject * blender::pygpu_matrix_get_normal_matrix (PyObject *)

Stack (Context Manager)

Safer alternative to ensure balanced push/pop calls.

enum  { blender::PYGPU_MATRIX_TYPE_MODEL_VIEW = 1 , blender::PYGPU_MATRIX_TYPE_PROJECTION = 2 }
static PyMethodDef blender::pygpu_matrix_stack_context__tp_methods []
PyTypeObject blender::PyGPUMatrixStackContext_Type
static PyObject * blender::pygpu_matrix_stack_context_enter (BPyGPU_MatrixStackContext *self)
static PyObject * blender::pygpu_matrix_stack_context_exit (BPyGPU_MatrixStackContext *self, PyObject *args)
 blender::PyDoc_STRVAR (pygpu_matrix_stack_context__tp_doc, "Context manager for matrix stack push/pop.")
static PyObject * blender::pygpu_matrix_push_pop_impl (int type)
 blender::PyDoc_STRVAR (pygpu_matrix_push_pop_doc, ".. function:: push_pop()\n" "\n" " Context manager to ensure balanced push/pop calls, even in the case of an error.\n" "\n" " :return: The context manager.\n" " :rtype: :class:`gpu.types.MatrixStackContext`\n")
static PyObject * blender::pygpu_matrix_push_pop (PyObject *)
 blender::PyDoc_STRVAR (pygpu_matrix_push_pop_projection_doc, ".. function:: push_pop_projection()\n" "\n" " Context manager to ensure balanced push/pop calls, even in the case of an error.\n" "\n" " :return: The context manager.\n" " :rtype: :class:`gpu.types.MatrixStackContext`\n")
static PyObject * blender::pygpu_matrix_push_pop_projection (PyObject *)

Module

static PyMethodDef blender::pygpu_matrix__tp_methods []
static PyModuleDef blender::pygpu_matrix_module_def
 blender::PyDoc_STRVAR (pygpu_matrix__tp_doc, "This module provides access to the matrix stack.")
PyObject * blender::bpygpu_matrix_init ()

Detailed Description

This file defines the gpu.matrix stack API.

Warning
While these functions attempt to ensure correct stack usage. Mixing Python and C functions may still crash on invalid use.
  • Use bpygpu_ for local API.
  • Use BPyGPU for public API.

Definition in file gpu_py_matrix.cc.

Macro Definition Documentation

◆ USE_GPU_PY_MATRIX_API

#define USE_GPU_PY_MATRIX_API

Definition at line 23 of file gpu_py_matrix.cc.