feat(web): wire Blender camera panorama controls
This commit is contained in:
@@ -5716,6 +5716,33 @@ bool web_engine_blend_main_set_camera_focus_object(WebBlendMainState *state,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_camera_panorama(WebBlendMainState *state,
|
||||
const char *target_id,
|
||||
const int panorama_type,
|
||||
const float fisheye_fov,
|
||||
std::string &error)
|
||||
{
|
||||
if (state == nullptr || state->main == nullptr || target_id == nullptr) {
|
||||
error = "RENDER_PROPERTY_INVALID: camera panorama target is missing";
|
||||
return false;
|
||||
}
|
||||
Camera *camera = find_camera(state->main, target_id);
|
||||
if (camera == nullptr || !ensure_single_user_data(state->main, &camera->id, error)) {
|
||||
if (error.empty()) error = "RENDER_PROPERTY_INVALID: camera was not found";
|
||||
return false;
|
||||
}
|
||||
if (panorama_type < CAM_PANORAMA_EQUIRECTANGULAR || panorama_type > CAM_PANORAMA_CENTRAL_CYLINDRICAL ||
|
||||
!std::isfinite(fisheye_fov) || fisheye_fov < 0.0001f || fisheye_fov > 6.28318531f) {
|
||||
error = "RENDER_PROPERTY_INVALID: camera panorama settings are outside the bounded range";
|
||||
return false;
|
||||
}
|
||||
camera->type = CAM_PANO;
|
||||
camera->panorama_type = eCamera_PanoType(panorama_type);
|
||||
camera->fisheye_fov = fisheye_fov;
|
||||
camera->id.recalc |= ID_RECALC_PARAMETERS;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
|
||||
const char *target_id,
|
||||
const char *properties_json,
|
||||
@@ -5798,7 +5825,7 @@ bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
|
||||
if (strncmp(target_id, "camera:", 7) == 0) {
|
||||
Camera *camera = find_camera(state->main, target_id);
|
||||
if (camera == nullptr || !ensure_single_user_data(state->main, &camera->id, error) ||
|
||||
!reject_unknown({"projection", "lensMm", "sensorWidthMm", "sensorHeightMm", "sensorFit",
|
||||
!reject_unknown({"projection", "panoramaType", "fisheyeFov", "lensMm", "sensorWidthMm", "sensorHeightMm", "sensorFit",
|
||||
"shift", "near", "far", "orthoScale", "depthOfField"}) ||
|
||||
!read_float("lensMm", 0.1f, 10000.0f, camera->lens) ||
|
||||
!read_float("sensorWidthMm", 0.1f, 10000.0f, camera->sensor_x) ||
|
||||
@@ -5821,11 +5848,22 @@ bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
|
||||
const std::string projection = properties["projection"].get<std::string>();
|
||||
if (projection == "PERSPECTIVE") camera->type = CAM_PERSP;
|
||||
else if (projection == "ORTHOGRAPHIC") camera->type = CAM_ORTHO;
|
||||
else if (projection == "PANORAMIC") camera->type = CAM_PANO;
|
||||
else {
|
||||
error = "RENDER_PROPERTY_INVALID: projection is unsupported";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (properties.contains("panoramaType") || properties.contains("fisheyeFov")) {
|
||||
int panorama_type = int(camera->panorama_type);
|
||||
if (properties.contains("panoramaType")) {
|
||||
if (!properties["panoramaType"].is_number_integer()) { error = "RENDER_PROPERTY_INVALID: panoramaType must be an integer"; return false; }
|
||||
panorama_type = properties["panoramaType"].get<int>();
|
||||
}
|
||||
if (properties.contains("fisheyeFov") && !properties["fisheyeFov"].is_number()) { error = "RENDER_PROPERTY_INVALID: fisheyeFov must be numeric"; return false; }
|
||||
const float fisheye_fov = properties.contains("fisheyeFov") ? properties["fisheyeFov"].get<float>() : camera->fisheye_fov;
|
||||
if (!web_engine_blend_main_set_camera_panorama(state, target_id, panorama_type, fisheye_fov, error)) return false;
|
||||
}
|
||||
if (properties.contains("sensorFit")) {
|
||||
if (!properties["sensorFit"].is_number_integer()) {
|
||||
error = "RENDER_PROPERTY_INVALID: sensorFit must be an integer";
|
||||
|
||||
@@ -577,6 +577,11 @@ bool web_engine_blend_main_set_camera_focus_object(WebBlendMainState *state,
|
||||
const char *target_id,
|
||||
const char *focus_object_id,
|
||||
std::string &error);
|
||||
bool web_engine_blend_main_set_camera_panorama(WebBlendMainState *state,
|
||||
const char *target_id,
|
||||
int panorama_type,
|
||||
float fisheye_fov,
|
||||
std::string &error);
|
||||
bool web_engine_blend_main_set_scene_properties(WebBlendMainState *state,
|
||||
const char *target_id,
|
||||
const char *properties_json,
|
||||
|
||||
Reference in New Issue
Block a user