Animation and Scene clean up functions. Playground build target

This commit is contained in:
John McCardle 2026-02-01 21:17:29 -05:00
commit 2fb29a102e
11 changed files with 323 additions and 123 deletions

View file

@ -111,6 +111,10 @@ static PyObject* mcrfpy_module_getattr(PyObject* self, PyObject* args)
return McRFPy_API::api_get_timers();
}
if (strcmp(name, "animations") == 0) {
return McRFPy_API::api_get_animations();
}
if (strcmp(name, "default_transition") == 0) {
return PyTransition::to_python(PyTransition::default_transition);
}
@ -144,6 +148,11 @@ static int mcrfpy_module_setattro(PyObject* self, PyObject* name, PyObject* valu
return -1;
}
if (strcmp(name_str, "animations") == 0) {
PyErr_SetString(PyExc_AttributeError, "'animations' is read-only");
return -1;
}
if (strcmp(name_str, "default_transition") == 0) {
TransitionType trans;
if (!PyTransition::from_arg(value, &trans, nullptr)) {
@ -1252,6 +1261,33 @@ PyObject* McRFPy_API::api_get_timers()
return tuple;
}
// Module-level animation collection accessor
PyObject* McRFPy_API::api_get_animations()
{
auto& manager = AnimationManager::getInstance();
const auto& animations = manager.getActiveAnimations();
PyObject* tuple = PyTuple_New(animations.size());
if (!tuple) return NULL;
Py_ssize_t i = 0;
for (const auto& anim : animations) {
// Create a PyAnimation wrapper for each animation
PyAnimationObject* pyAnim = (PyAnimationObject*)mcrfpydef::PyAnimationType.tp_alloc(&mcrfpydef::PyAnimationType, 0);
if (pyAnim) {
pyAnim->data = anim;
PyTuple_SET_ITEM(tuple, i, (PyObject*)pyAnim);
} else {
// Failed to allocate - fill with None
Py_INCREF(Py_None);
PyTuple_SET_ITEM(tuple, i, Py_None);
}
i++;
}
return tuple;
}
// #153 - Headless simulation control
PyObject* McRFPy_API::_step(PyObject* self, PyObject* args) {
PyObject* dt_obj = Py_None;