Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 9d1ee36
  • /
  • pySPlisHSPlasH
  • /
  • RigidBodyModule.cpp
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:9d8922181da10c144bbc82e23997b12464dd7a02
directory badge Iframe embedding
swh:1:dir:39b20ac81eeac3e59492345b4b824b0a458280c6
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
RigidBodyModule.cpp
//
// Created by sjeske on 1/22/20.
//
#include "common.h"

#include <SPlisHSPlasH/StaticRigidBody.h>
#include <SPlisHSPlasH/RigidBodyObject.h>

#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>

namespace py = pybind11;

void RigidBodyModule(py::module m_sub){
    // ---------------------------------------
    // Class Rigid Body Object
    // ---------------------------------------
    py::class_<SPH::RigidBodyObject>(m_sub, "RigidBodyObject")
            .def("isDynamic", &SPH::RigidBodyObject::isDynamic)
            .def("isAnimated", &SPH::RigidBodyObject::isAnimated)
            .def("setIsAnimated", &SPH::RigidBodyObject::setIsAnimated)
            .def("getMass", &SPH::RigidBodyObject::getMass)
            .def("getPosition", &SPH::RigidBodyObject::getPosition)
            .def("setPosition", &SPH::RigidBodyObject::setPosition)
            .def("getWorldSpacePosition", &SPH::RigidBodyObject::getWorldSpacePosition)
            .def("getVelocity", &SPH::RigidBodyObject::getVelocity)
            .def("setVelocity", &SPH::RigidBodyObject::setVelocity)
            .def("getRotation", [](SPH::RigidBodyObject& obj) -> Vector4r {
                return obj.getRotation().coeffs();
            })
            .def("setRotation", [](SPH::RigidBodyObject& obj, const Vector4r &qVec) {
                    Quaternionr q;
                    q.coeffs() = qVec;
                    obj.setRotation(q);
                })
            .def("getWorldSpaceRotation", &SPH::RigidBodyObject::getWorldSpaceRotation)
            .def("getAngularVelocity", &SPH::RigidBodyObject::getAngularVelocity)
            .def("setAngularVelocity", &SPH::RigidBodyObject::setAngularVelocity)
            .def("addForce", &SPH::RigidBodyObject::addForce)
            .def("addTorque", &SPH::RigidBodyObject::addTorque)
            .def("getVertices", &SPH::RigidBodyObject::getVertices)
            .def("getVertexNormals", &SPH::RigidBodyObject::getVertexNormals)
            .def("getFaces", &SPH::RigidBodyObject::getFaces)
            .def("updateMeshTransformation", &SPH::RigidBodyObject::updateMeshTransformation);

    // ---------------------------------------
    // Class Static Rigid Body
    // ---------------------------------------
    py::class_<SPH::StaticRigidBody, SPH::RigidBodyObject>(m_sub, "StaticRigidBody")
            .def(py::init<>())
            .def("setWorldSpacePosition", &SPH::StaticRigidBody::setWorldSpacePosition)
            .def("setWorldSpaceRotation", &SPH::StaticRigidBody::setWorldSpaceRotation)
            .def("animate", &SPH::StaticRigidBody::animate)
            .def("getGeometry", &SPH::StaticRigidBody::getGeometry)
            .def("getVertexBuffer", [](SPH::StaticRigidBody &obj) -> py::memoryview {
                auto vertices = obj.getVertices();
                void* base_ptr = &vertices[0][0];
                int num_vert = vertices.size();
                return py::memoryview::from_buffer((Real*)base_ptr, { num_vert, 3 }, { sizeof(Real) * 3, sizeof(Real) });
             })
            .def("getFaceBuffer", [](SPH::StaticRigidBody &obj) -> py::memoryview {
                    auto faces = obj.getFaces();
                    unsigned int* base_ptr = faces.data();
                    return py::memoryview::from_buffer(base_ptr, { faces.size() }, { sizeof(unsigned int) });
             });

}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API