You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.1 KiB
67 lines
2.1 KiB
#include <mimalloc.h>
|
|
|
|
#include <data/data_center.hpp>
|
|
|
|
#include "io_primitive.h"
|
|
|
|
EXTERN_C_BEGIN
|
|
|
|
API primitive_data_center_t* create_primitive_data_center() noexcept
|
|
{
|
|
void* res = mi_malloc(sizeof(primitive_data_center_t));
|
|
::new (res) primitive_data_center_t();
|
|
return (primitive_data_center_t*)res;
|
|
}
|
|
|
|
API void destroy_primitive_data_center(primitive_data_center_t* data_center) noexcept
|
|
{
|
|
if (data_center == nullptr) return;
|
|
data_center->~primitive_data_center_t();
|
|
mi_free(data_center);
|
|
}
|
|
|
|
API primitive* create_primitive(void* data_center, primitive_type type)
|
|
{
|
|
if (data_center == nullptr) return nullptr;
|
|
primitive* primitive_ptr{internal::new_primitive(type)};
|
|
if (primitive_ptr != nullptr) primitive_ptr->initialize(*static_cast<primitive_data_center_t*>(data_center));
|
|
return primitive_ptr;
|
|
}
|
|
|
|
API void destroy_primitive(primitive* primitive_ptr)
|
|
{
|
|
if (primitive_ptr == nullptr) return;
|
|
primitive_ptr->destroy();
|
|
mi_free(primitive_ptr);
|
|
}
|
|
|
|
API void primitive_apply_scale(primitive* primitive_ptr, vector3d scale)
|
|
{
|
|
if (primitive_ptr == nullptr) return;
|
|
Eigen::Vector4d scale_eigen;
|
|
std::move(&scale.x, &scale.x + 3, scale_eigen.data());
|
|
primitive_ptr->apply_transform(internal::transform_type::scale, scale_eigen);
|
|
}
|
|
|
|
API void primitive_apply_rotation(primitive* primitive_ptr, vector4d quaternion)
|
|
{
|
|
if (primitive_ptr == nullptr) return;
|
|
Eigen::Vector4d quat_eigen;
|
|
std::move(&quaternion.x, &quaternion.x + 4, quat_eigen.data());
|
|
primitive_ptr->apply_transform(internal::transform_type::rotation, quat_eigen);
|
|
}
|
|
|
|
API void primitive_apply_translation(primitive* primitive_ptr, vector3d translation)
|
|
{
|
|
if (primitive_ptr == nullptr) return;
|
|
Eigen::Vector4d translation_eigen;
|
|
std::move(&translation.x, &translation.x + 3, translation_eigen.data());
|
|
primitive_ptr->apply_transform(internal::transform_type::translation, translation_eigen);
|
|
}
|
|
|
|
API primitive* duplicate_primitive(const primitive* primitive_ptr)
|
|
{
|
|
return internal::copy_primitive(const_cast<primitive*>(primitive_ptr));
|
|
}
|
|
|
|
EXTERN_C_END
|