refactoring
This commit is contained in:
@@ -16,13 +16,12 @@ enum TProjection {
|
||||
|
||||
// Camera methods
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setExposure(TCamera *camera, float aperture, float shutterSpeed, float sensitivity);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setModelMatrix(TCamera *camera, double4x4 matrix);
|
||||
EMSCRIPTEN_KEEPALIVE double4x4 Camera_getModelMatrix(TCamera *const camera);
|
||||
EMSCRIPTEN_KEEPALIVE double4x4 Camera_getViewMatrix(TCamera *const camera);
|
||||
EMSCRIPTEN_KEEPALIVE double4x4 Camera_getProjectionMatrix(TCamera *const camera);
|
||||
EMSCRIPTEN_KEEPALIVE double4x4 Camera_getCullingProjectionMatrix(TCamera *const camera);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_getFrustum(TCamera *camera, double* out);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setProjectionMatrix(TCamera *camera, double4x4 matrix, double near, double far);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setProjectionMatrix(TCamera *camera, double *matrix, double near, double far);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setProjectionFromFov(TCamera *camera, double fovInDegrees, double aspect, double near, double far, bool horizontal);
|
||||
EMSCRIPTEN_KEEPALIVE double Camera_getFocalLength(TCamera *const camera);
|
||||
EMSCRIPTEN_KEEPALIVE double4x4 Camera_getViewMatrix(TCamera *const camera);
|
||||
@@ -41,7 +40,7 @@ EMSCRIPTEN_KEEPALIVE void Camera_setCustomProjectionWithCulling(
|
||||
double near,
|
||||
double far
|
||||
);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setModelMatrix(TCamera* camera, double4x4 modelMatrix);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setModelMatrix(TCamera* camera, double *tModelMatrix);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setLensProjection(TCamera *camera, double near, double far, double aspect, double focalLength);
|
||||
EMSCRIPTEN_KEEPALIVE EntityId Camera_getEntity(TCamera* camera);
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setProjection(TCamera *const tCamera, TProjection projection, double left, double right,
|
||||
|
||||
@@ -77,8 +77,8 @@ namespace thermion
|
||||
EMSCRIPTEN_KEEPALIVE void Material_createInstanceRenderThread(TMaterial *tMaterial, void (*onComplete)(TMaterialInstance *));
|
||||
EMSCRIPTEN_KEEPALIVE void Material_createImageMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *));
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void View_setToneMappingRenderThread(TView *tView, TEngine *tEngine, TToneMapping toneMapping);
|
||||
EMSCRIPTEN_KEEPALIVE void View_setBloomRenderThread(TView *tView, bool enabled, double strength);
|
||||
EMSCRIPTEN_KEEPALIVE void View_setToneMappingRenderThread(TView *tView, TEngine *tEngine, TToneMapping toneMapping, void (*callback)());
|
||||
EMSCRIPTEN_KEEPALIVE void View_setBloomRenderThread(TView *tView, bool enabled, double strength, void (*callback)());
|
||||
EMSCRIPTEN_KEEPALIVE void View_setCameraRenderThread(TView *tView, TCamera *tCamera, void (*callback)());
|
||||
|
||||
FilamentRenderCallback make_render_callback_fn_pointer(FilamentRenderCallback);
|
||||
|
||||
@@ -43,13 +43,14 @@ namespace thermion
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setLensProjection(TCamera *tCamera, double near, double far, double aspect, double focalLength) {
|
||||
TRACE("Setting lens projection %f %f %f %f", near, far, aspect, focalLength);
|
||||
auto *camera = reinterpret_cast<Camera *>(tCamera);
|
||||
camera->setLensProjection(near, far, aspect, focalLength);
|
||||
camera->setLensProjection(focalLength, aspect, near, far);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setModelMatrix(TCamera *tCamera, double4x4 tModelMatrix) {
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setModelMatrix(TCamera *tCamera, double *tModelMatrix) {
|
||||
auto *camera = reinterpret_cast<Camera *>(tCamera);
|
||||
auto modelMatrix = convert_double4x4_to_mat4(tModelMatrix);
|
||||
auto modelMatrix = convert_double_to_mat4f(tModelMatrix);
|
||||
camera->setModelMatrix(modelMatrix);
|
||||
}
|
||||
|
||||
@@ -65,6 +66,12 @@ namespace thermion
|
||||
return camera->getFocusDistance();
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE double4x4 Camera_getProjectionMatrix(TCamera *const tCamera) {
|
||||
auto *camera = reinterpret_cast<Camera *>(tCamera);
|
||||
return convert_mat4_to_double4x4(camera->getProjectionMatrix());
|
||||
}
|
||||
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void Camera_setFocusDistance(TCamera *tCamera, float distance) {
|
||||
auto *camera = reinterpret_cast<Camera *>(tCamera);
|
||||
return camera->setFocusDistance(distance);
|
||||
|
||||
@@ -28,17 +28,20 @@ namespace thermion
|
||||
{
|
||||
auto *scene = reinterpret_cast<Scene *>(tScene);
|
||||
scene->addEntity(utils::Entity::import(entityId));
|
||||
TRACE("Added entity %d", entityId);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void Scene_removeEntity(TScene* tScene, EntityId entityId) {
|
||||
auto *scene = reinterpret_cast<Scene *>(tScene);
|
||||
scene->remove(utils::Entity::import(entityId));
|
||||
TRACE("Removed entity %d", entityId);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void Scene_setSkybox(TScene* tScene, TSkybox *tSkybox) {
|
||||
auto *scene = reinterpret_cast<Scene *>(tScene);
|
||||
auto *skybox = reinterpret_cast<Skybox *>(tSkybox);
|
||||
scene->setSkybox(skybox);
|
||||
TRACE("Set skybox");
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void Scene_setIndirectLight(TScene* tScene, TIndirectLight *tIndirectLight) {
|
||||
|
||||
@@ -32,6 +32,7 @@ using namespace filament;
|
||||
{
|
||||
auto view = reinterpret_cast<View *>(tView);
|
||||
view->setViewport({0, 0, width, height});
|
||||
TRACE("Set viewport to %dx%d", width, height);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE TRenderTarget *View_getRenderTarget(TView *tView) {
|
||||
|
||||
@@ -427,22 +427,24 @@ extern "C"
|
||||
auto fut = _rl->add_task(lambda);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void View_setToneMappingRenderThread(TView *tView, TEngine *tEngine, TToneMapping toneMapping)
|
||||
EMSCRIPTEN_KEEPALIVE void View_setToneMappingRenderThread(TView *tView, TEngine *tEngine, TToneMapping toneMapping, void (*callback)())
|
||||
{
|
||||
std::packaged_task<void()> lambda(
|
||||
[=]
|
||||
{
|
||||
View_setToneMapping(tView, tEngine, toneMapping);
|
||||
callback();
|
||||
});
|
||||
auto fut = _rl->add_task(lambda);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void View_setBloomRenderThread(TView *tView, bool enabled, double strength)
|
||||
EMSCRIPTEN_KEEPALIVE void View_setBloomRenderThread(TView *tView, bool enabled, double strength, void (*callback)())
|
||||
{
|
||||
std::packaged_task<void()> lambda(
|
||||
[=]
|
||||
{
|
||||
View_setBloom(tView, enabled, strength);
|
||||
callback();
|
||||
});
|
||||
auto fut = _rl->add_task(lambda);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user