Collection of bugfixes #76

Merged
Brecht Van Lommel merged 6 commits from brecht/blender:hydra-fixes into hydra-render 2023-07-27 13:38:26 +02:00
7 changed files with 25 additions and 17 deletions
Showing only changes of commit 875716a7f8 - Show all commits

View File

@ -141,7 +141,7 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
lens_shift_[1] / t_size[1] + (t_pos[1] + t_size[1] * 0.5 - 0.5) / t_size[1]); lens_shift_[1] / t_size[1] + (t_pos[1] + t_size[1] * 0.5 - 0.5) / t_size[1]);
switch (camera->type) { switch (camera->type) {
case CAM_PERSP: case CAM_PERSP: {
focal_length_ = camera->lens; focal_length_ = camera->lens;
switch (camera->sensor_fit) { switch (camera->sensor_fit) {
@ -165,8 +165,9 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
} }
sensor_size_ = pxr::GfVec2f(sensor_size_[0] * t_size[0], sensor_size_[1] * t_size[1]); sensor_size_ = pxr::GfVec2f(sensor_size_[0] * t_size[0], sensor_size_[1] * t_size[1]);
break; break;
}
case CAM_ORTHO: case CAM_ORTHO: {
focal_length_ = 0.0f; focal_length_ = 0.0f;
switch (camera->sensor_fit) { switch (camera->sensor_fit) {
case CAMERA_SENSOR_FIT_VERT: case CAMERA_SENSOR_FIT_VERT:
@ -189,8 +190,9 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
} }
ortho_size_ = pxr::GfVec2f(ortho_size_[0] * t_size[0], ortho_size_[1] * t_size[1]); ortho_size_ = pxr::GfVec2f(ortho_size_[0] * t_size[0], ortho_size_[1] * t_size[1]);
break; break;
}
case CAM_PANO: case CAM_PANO: {
/* TODO: Recheck parameters for PANO camera */ /* TODO: Recheck parameters for PANO camera */
focal_length_ = camera->lens; focal_length_ = camera->lens;
@ -214,10 +216,14 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
break; break;
} }
sensor_size_ = pxr::GfVec2f(sensor_size_[0] * t_size[0], sensor_size_[1] * t_size[1]); sensor_size_ = pxr::GfVec2f(sensor_size_[0] * t_size[0], sensor_size_[1] * t_size[1]);
break;
}
default: default: {
focal_length_ = camera->lens; focal_length_ = camera->lens;
sensor_size_ = pxr::GfVec2f(camera->sensor_y * ratio, camera->sensor_y); sensor_size_ = pxr::GfVec2f(camera->sensor_y * ratio, camera->sensor_y);
break;
}
} }
} }

View File

@ -5,9 +5,9 @@
namespace blender::render::hydra { namespace blender::render::hydra {
void PreviewEngine::notify_status(float progress, void PreviewEngine::notify_status(float /* progress */,
const std::string &title, const std::string & /* title */,
const std::string &info) const std::string & /* info */)
{ {
/* Empty fucntion */ /* Empty fucntion */
} }

View File

@ -258,6 +258,8 @@ static struct PyModuleDef module = {
extern "C" { extern "C" {
#endif #endif
PyObject *BPyInit_hydra(void);
PyObject *BPyInit_hydra(void) PyObject *BPyInit_hydra(void)
{ {
PyObject *mod = PyModule_Create(&blender::render::hydra::module); PyObject *mod = PyModule_Create(&blender::render::hydra::module);

View File

@ -96,7 +96,7 @@ std::string cache_image_color(float color[4])
char name[128]; char name[128];
snprintf(name, snprintf(name,
sizeof(name), sizeof(name),
"color_%02x%02x%02x.hdr", "color_%02d%02d%02d.hdr",
int(color[0] * 255), int(color[0] * 255),
int(color[1] * 255), int(color[1] * 255),
int(color[2] * 255)); int(color[2] * 255));

View File

@ -128,7 +128,7 @@ void InstancerData::pre_update()
} }
} }
void InstancerData::update_instance(Object *parent_ob, DupliObject *dupli) void InstancerData::update_instance(Object * /* parent_ob */, DupliObject *dupli)
{ {
Object *object = dupli->ob; Object *object = dupli->ob;
pxr::SdfPath p_id = object_prim_id(object); pxr::SdfPath p_id = object_prim_id(object);
@ -207,14 +207,14 @@ pxr::SdfPath InstancerData::object_prim_id(Object *object) const
pxr::SdfPath InstancerData::nonmesh_prim_id(pxr::SdfPath const &prim_id, int index) const pxr::SdfPath InstancerData::nonmesh_prim_id(pxr::SdfPath const &prim_id, int index) const
{ {
char name[16]; char name[16];
snprintf(name, sizeof(name), "NM_%08x", index); snprintf(name, sizeof(name), "NM_%08d", index);
return prim_id.AppendElementString(name); return prim_id.AppendElementString(name);
} }
int InstancerData::nonmesh_prim_id_index(pxr::SdfPath const &id) const int InstancerData::nonmesh_prim_id_index(pxr::SdfPath const &id) const
{ {
int index; int index;
sscanf(id.GetName().c_str(), "NM_%x", &index); sscanf(id.GetName().c_str(), "NM_%d", &index);
return index; return index;
} }
@ -275,7 +275,7 @@ InstancerData::MeshInstance *InstancerData::mesh_instance(pxr::SdfPath const &id
InstancerData::NonmeshInstance *InstancerData::nonmesh_instance(pxr::SdfPath const &id) const InstancerData::NonmeshInstance *InstancerData::nonmesh_instance(pxr::SdfPath const &id) const
{ {
auto nm_inst = nonmesh_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() : auto nm_inst = nonmesh_instances_.lookup_ptr(id.GetPathElementCount() == 4 ? id.GetParentPath() :
id); id);
if (!nm_inst) { if (!nm_inst) {
return nullptr; return nullptr;
} }

View File

@ -202,14 +202,14 @@ void MeshData::write_materials()
pxr::SdfPath MeshData::submesh_prim_id(int index) const pxr::SdfPath MeshData::submesh_prim_id(int index) const
{ {
char name[16]; char name[16];
snprintf(name, sizeof(name), "SM_%04x", index); snprintf(name, sizeof(name), "SM_%04d", index);
return prim_id.AppendElementString(name); return prim_id.AppendElementString(name);
} }
const MeshData::SubMesh &MeshData::submesh(pxr::SdfPath const &id) const const MeshData::SubMesh &MeshData::submesh(pxr::SdfPath const &id) const
{ {
int index; int index;
sscanf(id.GetName().c_str(), "SM_%x", &index); sscanf(id.GetName().c_str(), "SM_%d", &index);
return submeshes_[index]; return submeshes_[index];
} }

View File

@ -101,7 +101,7 @@ bool ObjectData::is_visible(BlenderSceneDelegate *scene_delegate, Object *object
return ret; return ret;
} }
pxr::VtValue ObjectData::get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const pxr::VtValue ObjectData::get_data(pxr::SdfPath const & /* id */, pxr::TfToken const &key) const
{ {
return get_data(key); return get_data(key);
} }
@ -111,12 +111,12 @@ pxr::SdfPath ObjectData::material_id() const
return pxr::SdfPath(); return pxr::SdfPath();
} }
pxr::SdfPath ObjectData::material_id(pxr::SdfPath const &id) const pxr::SdfPath ObjectData::material_id(pxr::SdfPath const & /* id */) const
{ {
return material_id(); return material_id();
} }
void ObjectData::available_materials(Set<pxr::SdfPath> &paths) const {} void ObjectData::available_materials(Set<pxr::SdfPath> & /* paths */) const {}
void ObjectData::write_transform() void ObjectData::write_transform()
{ {