forked from blender/blender
Rename some functions #25
@ -45,17 +45,17 @@ void BlenderSceneDelegate::update_world()
|
||||
|
||||
bool BlenderSceneDelegate::GetVisible(pxr::SdfPath const &id)
|
||||
{
|
||||
if (id == WorldData::prim_id(this)) {
|
||||
if (id == WorldData::get_prim_id(this)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return object_data(id)->visible;
|
||||
return get_object_data(id)->visible;
|
||||
}
|
||||
|
||||
pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id)
|
||||
{
|
||||
CLOG_INFO(LOG_BSD, 3, "%s", prim_id.GetText());
|
||||
InstancerData *i_data = instancer_data(prim_id, true);
|
||||
InstancerData *i_data = get_instancer_data(prim_id, true);
|
||||
if (i_data) {
|
||||
return i_data->instancer_id;
|
||||
}
|
||||
@ -74,15 +74,15 @@ pxr::VtIntArray BlenderSceneDelegate::GetInstanceIndices(pxr::SdfPath const &ins
|
||||
pxr::SdfPath const &prototype_id)
|
||||
{
|
||||
CLOG_INFO(LOG_BSD, 3, "%s, %s", instancer_id.GetText(), prototype_id.GetText());
|
||||
InstancerData *i_data = instancer_data(instancer_id);
|
||||
return i_data->instance_indices();
|
||||
InstancerData *i_data = get_instancer_data(instancer_id);
|
||||
return i_data->get_instance_indices();
|
||||
}
|
||||
|
||||
pxr::GfMatrix4d BlenderSceneDelegate::GetInstancerTransform(pxr::SdfPath const &instancer_id)
|
||||
{
|
||||
CLOG_INFO(LOG_BSD, 3, "%s", instancer_id.GetText());
|
||||
InstancerData *i_data = instancer_data(instancer_id);
|
||||
return i_data->transform();
|
||||
InstancerData *i_data = get_instancer_data(instancer_id);
|
||||
return i_data->get_transform();
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
||||
@ -114,19 +114,19 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
||||
object) {
|
||||
|
||||
CLOG_INFO(LOG_BSD, 2, "Add %s", ((ID *)object)->name);
|
||||
if (!ObjectData::supported(object)) {
|
||||
if (!ObjectData::is_supported(object)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
id = ObjectData::prim_id(this, object);
|
||||
id = ObjectData::get_prim_id(this, object);
|
||||
if (remove) {
|
||||
available_objects.insert(id);
|
||||
if ((object->transflag & OB_DUPLI) && InstancerData::supported(object)) {
|
||||
available_objects.insert(InstancerData::prim_id(this, object));
|
||||
if ((object->transflag & OB_DUPLI) && InstancerData::is_supported(object)) {
|
||||
available_objects.insert(InstancerData::get_prim_id(this, object));
|
||||
}
|
||||
}
|
||||
|
||||
if (!object_data(id)) {
|
||||
if (!get_object_data(id)) {
|
||||
add_update_object(object);
|
||||
}
|
||||
}
|
||||
@ -150,7 +150,7 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
||||
if (!m_data) {
|
||||
continue;
|
||||
}
|
||||
pxr::SdfPath mat_id = m_data->material_id();
|
||||
pxr::SdfPath mat_id = m_data->get_material_id();
|
||||
if (!mat_id.IsEmpty()) {
|
||||
available_materials.insert(mat_id);
|
||||
}
|
||||
@ -168,16 +168,16 @@ void BlenderSceneDelegate::update_collection(bool remove, bool visibility)
|
||||
|
||||
void BlenderSceneDelegate::add_update_object(Object *object)
|
||||
{
|
||||
if ((object->transflag & OB_DUPLI) && InstancerData::supported(object)) {
|
||||
if ((object->transflag & OB_DUPLI) && InstancerData::is_supported(object)) {
|
||||
add_update_instancer(object);
|
||||
}
|
||||
InstancerData *i_data = instancer_data(object);
|
||||
InstancerData *i_data = get_instancer_data(object);
|
||||
if (i_data) {
|
||||
i_data->update();
|
||||
}
|
||||
|
||||
pxr::SdfPath id = ObjectData::prim_id(this, object);
|
||||
ObjectData *obj_data = object_data(id);
|
||||
pxr::SdfPath id = ObjectData::get_prim_id(this, object);
|
||||
ObjectData *obj_data = get_object_data(id);
|
||||
if (obj_data) {
|
||||
obj_data->update();
|
||||
return;
|
||||
@ -186,24 +186,24 @@ void BlenderSceneDelegate::add_update_object(Object *object)
|
||||
return;
|
||||
}
|
||||
objects[id] = ObjectData::create(this, object);
|
||||
obj_data = object_data(id);
|
||||
obj_data = get_object_data(id);
|
||||
obj_data->update_visibility(view3d);
|
||||
}
|
||||
|
||||
void BlenderSceneDelegate::add_update_instancer(Object *object)
|
||||
{
|
||||
pxr::SdfPath id = InstancerData::prim_id(this, object);
|
||||
InstancerData *i_data = instancer_data(id, true);
|
||||
pxr::SdfPath id = InstancerData::get_prim_id(this, object);
|
||||
InstancerData *i_data = get_instancer_data(id, true);
|
||||
if (i_data) {
|
||||
i_data->update();
|
||||
return;
|
||||
}
|
||||
objects[id] = InstancerData::create(this, object);
|
||||
i_data = instancer_data(id, true);
|
||||
i_data = get_instancer_data(id, true);
|
||||
i_data->update_visibility(view3d);
|
||||
}
|
||||
|
||||
ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id)
|
||||
ObjectData *BlenderSceneDelegate::get_object_data(pxr::SdfPath const &id)
|
||||
{
|
||||
auto it = objects.find(id);
|
||||
if (it == objects.end()) {
|
||||
@ -212,17 +212,17 @@ ObjectData *BlenderSceneDelegate::object_data(pxr::SdfPath const &id)
|
||||
return it->second.get();
|
||||
}
|
||||
|
||||
MeshData *BlenderSceneDelegate::mesh_data(pxr::SdfPath const &id)
|
||||
MeshData *BlenderSceneDelegate::get_mesh_data(pxr::SdfPath const &id)
|
||||
{
|
||||
return dynamic_cast<MeshData *>(object_data(id));
|
||||
return dynamic_cast<MeshData *>(get_object_data(id));
|
||||
}
|
||||
|
||||
LightData *BlenderSceneDelegate::light_data(pxr::SdfPath const &id)
|
||||
LightData *BlenderSceneDelegate::get_light_data(pxr::SdfPath const &id)
|
||||
{
|
||||
return dynamic_cast<LightData *>(object_data(id));
|
||||
return dynamic_cast<LightData *>(get_object_data(id));
|
||||
}
|
||||
|
||||
MaterialData *BlenderSceneDelegate::material_data(pxr::SdfPath const &id)
|
||||
MaterialData *BlenderSceneDelegate::get_material_data(pxr::SdfPath const &id)
|
||||
{
|
||||
auto it = materials.find(id);
|
||||
if (it == materials.end()) {
|
||||
@ -231,15 +231,15 @@ MaterialData *BlenderSceneDelegate::material_data(pxr::SdfPath const &id)
|
||||
return it->second.get();
|
||||
}
|
||||
|
||||
InstancerData *BlenderSceneDelegate::instancer_data(pxr::SdfPath const &id, bool base_prim)
|
||||
InstancerData *BlenderSceneDelegate::get_instancer_data(pxr::SdfPath const &id, bool base_prim)
|
||||
{
|
||||
if (base_prim) {
|
||||
return dynamic_cast<InstancerData *>(object_data(id));
|
||||
return dynamic_cast<InstancerData *>(get_object_data(id));
|
||||
}
|
||||
return dynamic_cast<InstancerData *>(object_data(id.GetParentPath()));
|
||||
return dynamic_cast<InstancerData *>(get_object_data(id.GetParentPath()));
|
||||
}
|
||||
|
||||
InstancerData *BlenderSceneDelegate::instancer_data(Object *object)
|
||||
InstancerData *BlenderSceneDelegate::get_instancer_data(Object *object)
|
||||
{
|
||||
InstancerData *i_data;
|
||||
for (auto &it : objects) {
|
||||
@ -310,14 +310,14 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
switch (GS(id->name)) {
|
||||
case ID_OB: {
|
||||
Object *object = (Object *)id;
|
||||
if (!ObjectData::supported(object)) {
|
||||
if (!ObjectData::is_supported(object)) {
|
||||
break;
|
||||
}
|
||||
add_update_object(object);
|
||||
} break;
|
||||
|
||||
case ID_MA: {
|
||||
MaterialData *mat_data = material_data(MaterialData::prim_id(this, (Material *)id));
|
||||
MaterialData *mat_data = get_material_data(MaterialData::get_prim_id(this, (Material *)id));
|
||||
if (mat_data) {
|
||||
mat_data->update();
|
||||
}
|
||||
@ -343,25 +343,25 @@ void BlenderSceneDelegate::populate(Depsgraph *deps, bContext *cont)
|
||||
pxr::HdMeshTopology BlenderSceneDelegate::GetMeshTopology(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_BSD, 3, "%s", id.GetText());
|
||||
MeshData *m_data = mesh_data(id);
|
||||
return m_data->mesh_topology();
|
||||
MeshData *m_data = get_mesh_data(id);
|
||||
return m_data->get_mesh_topology();
|
||||
}
|
||||
|
||||
pxr::VtValue BlenderSceneDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
|
||||
{
|
||||
CLOG_INFO(LOG_BSD, 3, "%s, %s", id.GetText(), key.GetText());
|
||||
|
||||
ObjectData *obj_data = object_data(id);
|
||||
ObjectData *obj_data = get_object_data(id);
|
||||
if (obj_data) {
|
||||
return obj_data->get_data(key);
|
||||
}
|
||||
|
||||
MaterialData *mat_data = material_data(id);
|
||||
MaterialData *mat_data = get_material_data(id);
|
||||
if (mat_data) {
|
||||
return mat_data->get_data(key);
|
||||
}
|
||||
|
||||
InstancerData *i_data = instancer_data(id);
|
||||
InstancerData *i_data = get_instancer_data(id);
|
||||
if (i_data) {
|
||||
return i_data->get_data(key);
|
||||
}
|
||||
@ -374,14 +374,14 @@ pxr::HdPrimvarDescriptorVector BlenderSceneDelegate::GetPrimvarDescriptors(
|
||||
{
|
||||
CLOG_INFO(LOG_BSD, 3, "%s, %d", id.GetText(), interpolation);
|
||||
|
||||
MeshData *m_data = mesh_data(id);
|
||||
MeshData *m_data = get_mesh_data(id);
|
||||
if (m_data) {
|
||||
return m_data->primvar_descriptors(interpolation);
|
||||
return m_data->get_primvar_descriptors(interpolation);
|
||||
}
|
||||
|
||||
InstancerData *i_data = instancer_data(id);
|
||||
InstancerData *i_data = get_instancer_data(id);
|
||||
if (i_data) {
|
||||
return i_data->instancer_primvar_descriptors(interpolation);
|
||||
return i_data->get_instancer_primvar_descriptors(interpolation);
|
||||
}
|
||||
|
||||
return pxr::HdPrimvarDescriptorVector();
|
||||
@ -389,14 +389,14 @@ pxr::HdPrimvarDescriptorVector BlenderSceneDelegate::GetPrimvarDescriptors(
|
||||
|
||||
pxr::SdfPath BlenderSceneDelegate::GetMaterialId(pxr::SdfPath const &rprim_id)
|
||||
{
|
||||
return mesh_data(rprim_id)->material_id();
|
||||
return get_mesh_data(rprim_id)->get_material_id();
|
||||
}
|
||||
|
||||
pxr::VtValue BlenderSceneDelegate::GetMaterialResource(pxr::SdfPath const &id)
|
||||
{
|
||||
MaterialData *mat_data = material_data(id);
|
||||
MaterialData *mat_data = get_material_data(id);
|
||||
if (mat_data) {
|
||||
return mat_data->material_resource();
|
||||
return mat_data->get_material_resource();
|
||||
}
|
||||
return pxr::VtValue();
|
||||
}
|
||||
@ -404,18 +404,18 @@ pxr::VtValue BlenderSceneDelegate::GetMaterialResource(pxr::SdfPath const &id)
|
||||
pxr::GfMatrix4d BlenderSceneDelegate::GetTransform(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_BSD, 3, "%s", id.GetText());
|
||||
ObjectData *obj_data = object_data(id);
|
||||
ObjectData *obj_data = get_object_data(id);
|
||||
if (obj_data) {
|
||||
return obj_data->transform();
|
||||
return obj_data->get_transform();
|
||||
}
|
||||
|
||||
if (id == WorldData::prim_id(this)) {
|
||||
return world_data->transform();
|
||||
if (id == WorldData::get_prim_id(this)) {
|
||||
return world_data->get_transform();
|
||||
}
|
||||
|
||||
InstancerData *i_data = instancer_data(id);
|
||||
InstancerData *i_data = get_instancer_data(id);
|
||||
if (i_data) {
|
||||
return i_data->transform();
|
||||
return i_data->get_transform();
|
||||
}
|
||||
|
||||
return pxr::GfMatrix4d();
|
||||
@ -424,11 +424,11 @@ pxr::GfMatrix4d BlenderSceneDelegate::GetTransform(pxr::SdfPath const &id)
|
||||
pxr::VtValue BlenderSceneDelegate::GetLightParamValue(pxr::SdfPath const &id,
|
||||
pxr::TfToken const &key)
|
||||
{
|
||||
LightData *l_data = light_data(id);
|
||||
LightData *l_data = get_light_data(id);
|
||||
if (l_data) {
|
||||
return l_data->get_data(key);
|
||||
}
|
||||
if (id == WorldData::prim_id(this)) {
|
||||
if (id == WorldData::get_prim_id(this)) {
|
||||
return world_data->get_data(key);
|
||||
}
|
||||
return pxr::VtValue();
|
||||
|
@ -51,15 +51,16 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
pxr::SdfPath const &prototype_id) override;
|
||||
pxr::GfMatrix4d GetInstancerTransform(pxr::SdfPath const &instancer_id) override;
|
||||
|
||||
public:
|
||||
EngineType engine_type;
|
||||
|
||||
private:
|
||||
ObjectData *object_data(pxr::SdfPath const &id);
|
||||
MeshData *mesh_data(pxr::SdfPath const &id);
|
||||
LightData *light_data(pxr::SdfPath const &id);
|
||||
MaterialData *material_data(pxr::SdfPath const &id);
|
||||
InstancerData *instancer_data(pxr::SdfPath const &id, bool base_prim = false);
|
||||
InstancerData *instancer_data(Object *object);
|
||||
ObjectData *get_object_data(pxr::SdfPath const &id);
|
||||
MeshData *get_mesh_data(pxr::SdfPath const &id);
|
||||
LightData *get_light_data(pxr::SdfPath const &id);
|
||||
MaterialData *get_material_data(pxr::SdfPath const &id);
|
||||
InstancerData *get_instancer_data(pxr::SdfPath const &id, bool base_prim = false);
|
||||
InstancerData *get_instancer_data(Object *object);
|
||||
|
||||
void add_update_object(Object *object);
|
||||
void add_update_instancer(Object *object);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
bool InstancerData::supported(Object *object)
|
||||
bool InstancerData::is_supported(Object *object)
|
||||
{
|
||||
switch (object->type) {
|
||||
case OB_MESH:
|
||||
@ -34,7 +34,7 @@ std::unique_ptr<InstancerData> InstancerData::create(BlenderSceneDelegate *scene
|
||||
return data;
|
||||
}
|
||||
|
||||
pxr::SdfPath InstancerData::prim_id(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||
pxr::SdfPath InstancerData::get_prim_id(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||
{
|
||||
/* Making id of instancer in form like I_<pointer in 16 hex digits format>. Example:
|
||||
* I_000002073e369608 */
|
||||
@ -47,7 +47,7 @@ InstancerData::InstancerData(BlenderSceneDelegate *scene_delegate, Object *objec
|
||||
: MeshData(scene_delegate, object), parent_obj(object)
|
||||
{
|
||||
id = nullptr;
|
||||
p_id = prim_id(scene_delegate, object);
|
||||
p_id = get_prim_id(scene_delegate, object);
|
||||
instancer_id = p_id.AppendElementString("Instancer");
|
||||
CLOG_INFO(LOG_BSD, 2, "%s, instancer_id=%s", ((ID *)parent_obj)->name, instancer_id.GetText());
|
||||
}
|
||||
@ -60,7 +60,7 @@ void InstancerData::init()
|
||||
MeshData::init();
|
||||
}
|
||||
|
||||
pxr::GfMatrix4d InstancerData::transform()
|
||||
pxr::GfMatrix4d InstancerData::get_transform()
|
||||
{
|
||||
return pxr::GfMatrix4d(1.0);
|
||||
}
|
||||
@ -91,7 +91,7 @@ pxr::VtValue InstancerData::get_data(pxr::TfToken const &key) const
|
||||
return MeshData::get_data(key);
|
||||
}
|
||||
|
||||
pxr::HdPrimvarDescriptorVector InstancerData::instancer_primvar_descriptors(
|
||||
pxr::HdPrimvarDescriptorVector InstancerData::get_instancer_primvar_descriptors(
|
||||
pxr::HdInterpolation interpolation)
|
||||
{
|
||||
pxr::HdPrimvarDescriptorVector primvars;
|
||||
@ -102,7 +102,7 @@ pxr::HdPrimvarDescriptorVector InstancerData::instancer_primvar_descriptors(
|
||||
return primvars;
|
||||
}
|
||||
|
||||
pxr::VtIntArray InstancerData::instance_indices()
|
||||
pxr::VtIntArray InstancerData::get_instance_indices()
|
||||
{
|
||||
pxr::VtIntArray ret(transforms.size());
|
||||
for (size_t i = 0; i < ret.size(); ++i) {
|
||||
|
@ -11,10 +11,10 @@ namespace blender::render::hydra {
|
||||
|
||||
class InstancerData : public MeshData {
|
||||
public:
|
||||
static bool supported(Object *object);
|
||||
static bool is_supported(Object *object);
|
||||
static std::unique_ptr<InstancerData> create(BlenderSceneDelegate *scene_delegate,
|
||||
Object *object);
|
||||
static pxr::SdfPath prim_id(BlenderSceneDelegate *scene_delegate, Object *object);
|
||||
static pxr::SdfPath get_prim_id(BlenderSceneDelegate *scene_delegate, Object *object);
|
||||
|
||||
InstancerData(BlenderSceneDelegate *scene_delegate, Object *object);
|
||||
|
||||
@ -22,12 +22,13 @@ class InstancerData : public MeshData {
|
||||
void insert() override;
|
||||
void remove() override;
|
||||
void update() override;
|
||||
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
pxr::GfMatrix4d transform() override;
|
||||
pxr::GfMatrix4d get_transform() override;
|
||||
bool update_visibility(View3D *view3d) override;
|
||||
|
||||
pxr::HdPrimvarDescriptorVector instancer_primvar_descriptors(pxr::HdInterpolation interpolation);
|
||||
pxr::VtIntArray instance_indices();
|
||||
pxr::HdPrimvarDescriptorVector get_instancer_primvar_descriptors(pxr::HdInterpolation interpolation);
|
||||
pxr::VtIntArray get_instance_indices();
|
||||
|
||||
bool is_base(Object *object) const;
|
||||
pxr::SdfPath instancer_id;
|
||||
|
@ -79,13 +79,13 @@ void LightData::init()
|
||||
break;
|
||||
}
|
||||
|
||||
p_type = prim_type(light);
|
||||
p_type = get_prim_type(light);
|
||||
|
||||
/* TODO: temporary value, it should be delivered through Python UI */
|
||||
data[pxr::HdLightTokens->exposure] = 1.0f;
|
||||
}
|
||||
|
||||
pxr::TfToken LightData::prim_type(Light *light)
|
||||
pxr::TfToken LightData::get_prim_type(Light *light)
|
||||
{
|
||||
pxr::TfToken ret;
|
||||
switch (light->type) {
|
||||
@ -169,7 +169,7 @@ void LightData::update()
|
||||
CLOG_INFO(LOG_BSD, 2, "%s", id->name);
|
||||
|
||||
Light *light = (Light *)((Object *)id)->data;
|
||||
if (prim_type(light) != p_type) {
|
||||
if (get_prim_type(light) != p_type) {
|
||||
remove();
|
||||
init();
|
||||
insert();
|
||||
|
@ -21,13 +21,16 @@ class LightData : public ObjectData {
|
||||
void insert() override;
|
||||
void remove() override;
|
||||
void update() override;
|
||||
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
bool update_visibility(View3D *view3d) override;
|
||||
|
||||
private:
|
||||
pxr::TfToken get_prim_type(Light *light);
|
||||
|
||||
private:
|
||||
std::map<pxr::TfToken, pxr::VtValue> data;
|
||||
pxr::TfToken p_type;
|
||||
pxr::TfToken prim_type(Light *light);
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -29,7 +29,7 @@ std::unique_ptr<MaterialData> MaterialData::create(BlenderSceneDelegate *scene_d
|
||||
return data;
|
||||
}
|
||||
|
||||
pxr::SdfPath MaterialData::prim_id(BlenderSceneDelegate *scene_delegate, Material *material)
|
||||
pxr::SdfPath MaterialData::get_prim_id(BlenderSceneDelegate *scene_delegate, Material *material)
|
||||
{
|
||||
/* Making id of material in form like M_<pointer in 16 hex digits format>.
|
||||
* Example: M_000002074e812088 */
|
||||
@ -41,7 +41,7 @@ pxr::SdfPath MaterialData::prim_id(BlenderSceneDelegate *scene_delegate, Materia
|
||||
MaterialData::MaterialData(BlenderSceneDelegate *scene_delegate, Material *material)
|
||||
: IdData(scene_delegate, (ID *)material)
|
||||
{
|
||||
p_id = prim_id(scene_delegate, material);
|
||||
p_id = get_prim_id(scene_delegate, material);
|
||||
CLOG_INFO(LOG_BSD, 2, "%s, id=%s", id->name, p_id.GetText());
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ pxr::VtValue MaterialData::get_data(pxr::TfToken const &key) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
pxr::VtValue MaterialData::material_resource()
|
||||
pxr::VtValue MaterialData::get_material_resource()
|
||||
{
|
||||
if (material_network_map.IsEmpty()) {
|
||||
const std::string &path = mtlx_path.GetResolvedPath();
|
||||
@ -110,7 +110,7 @@ pxr::VtValue MaterialData::material_resource()
|
||||
pxr::TfTokenVector render_contexts = render_delegate->GetMaterialRenderContexts();
|
||||
|
||||
pxr::HdMaterialNetworkMap network_map;
|
||||
HdMtlxConvertToMaterialNetworkMap(path, shader_source_types, render_contexts, &network_map);
|
||||
hdmtlx_convert_to_materialnetworkmap(path, shader_source_types, render_contexts, &network_map);
|
||||
|
||||
material_network_map = network_map;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class MaterialData : IdData {
|
||||
public:
|
||||
static std::unique_ptr<MaterialData> create(BlenderSceneDelegate *scene_delegate,
|
||||
Material *material);
|
||||
static pxr::SdfPath prim_id(BlenderSceneDelegate *scene_delegate, Material *material);
|
||||
static pxr::SdfPath get_prim_id(BlenderSceneDelegate *scene_delegate, Material *material);
|
||||
|
||||
MaterialData(BlenderSceneDelegate *scene_delegate, Material *material);
|
||||
|
||||
@ -29,10 +29,9 @@ class MaterialData : IdData {
|
||||
void insert() override;
|
||||
void remove() override;
|
||||
void update() override;
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
|
||||
pxr::VtValue material_resource();
|
||||
void export_mtlx();
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
pxr::VtValue get_material_resource();
|
||||
|
||||
private:
|
||||
pxr::SdfAssetPath mtlx_path;
|
||||
|
@ -49,7 +49,7 @@ bool MeshData::update_visibility(View3D *view3d)
|
||||
return ret;
|
||||
}
|
||||
|
||||
pxr::HdMeshTopology MeshData::mesh_topology()
|
||||
pxr::HdMeshTopology MeshData::get_mesh_topology()
|
||||
{
|
||||
return pxr::HdMeshTopology(pxr::PxOsdOpenSubdivTokens->none,
|
||||
pxr::HdTokens->rightHanded,
|
||||
@ -57,7 +57,7 @@ pxr::HdMeshTopology MeshData::mesh_topology()
|
||||
face_vertex_indices);
|
||||
}
|
||||
|
||||
pxr::HdPrimvarDescriptorVector MeshData::primvar_descriptors(pxr::HdInterpolation interpolation)
|
||||
pxr::HdPrimvarDescriptorVector MeshData::get_primvar_descriptors(pxr::HdInterpolation interpolation)
|
||||
{
|
||||
pxr::HdPrimvarDescriptorVector primvars;
|
||||
if (interpolation == pxr::HdInterpolationVertex) {
|
||||
@ -79,7 +79,7 @@ pxr::HdPrimvarDescriptorVector MeshData::primvar_descriptors(pxr::HdInterpolatio
|
||||
return primvars;
|
||||
}
|
||||
|
||||
pxr::SdfPath MeshData::material_id()
|
||||
pxr::SdfPath MeshData::get_material_id()
|
||||
{
|
||||
if (!mat_data) {
|
||||
return pxr::SdfPath();
|
||||
@ -87,7 +87,7 @@ pxr::SdfPath MeshData::material_id()
|
||||
return mat_data->p_id;
|
||||
}
|
||||
|
||||
void MeshData::set_mesh(Mesh *mesh)
|
||||
void MeshData::write_mesh(Mesh *mesh)
|
||||
{
|
||||
face_vertex_counts.clear();
|
||||
face_vertex_indices.clear();
|
||||
@ -122,30 +122,11 @@ void MeshData::set_mesh(Mesh *mesh)
|
||||
vertices.push_back(pxr::GfVec3f(v.x, v.y, v.z));
|
||||
}
|
||||
|
||||
/* normals */
|
||||
const float(*lnors)[3] = (float(*)[3])CustomData_get_layer(&mesh->ldata, CD_NORMAL);
|
||||
if (lnors) {
|
||||
normals.reserve(loopTris.size() * 3);
|
||||
for (MLoopTri lt : loopTris) {
|
||||
normals.push_back(pxr::GfVec3f(lnors[lt.tri[0]]));
|
||||
normals.push_back(pxr::GfVec3f(lnors[lt.tri[1]]));
|
||||
normals.push_back(pxr::GfVec3f(lnors[lt.tri[2]]));
|
||||
}
|
||||
}
|
||||
|
||||
/* uvs*/
|
||||
const float(*luvs)[2] = (float(*)[2])CustomData_get_layer(&mesh->ldata, CD_PROP_FLOAT2);
|
||||
if (luvs) {
|
||||
uvs.reserve(loopTris.size() * 3);
|
||||
for (MLoopTri lt : loopTris) {
|
||||
uvs.push_back(pxr::GfVec2f(luvs[lt.tri[0]]));
|
||||
uvs.push_back(pxr::GfVec2f(luvs[lt.tri[1]]));
|
||||
uvs.push_back(pxr::GfVec2f(luvs[lt.tri[2]]));
|
||||
}
|
||||
}
|
||||
write_normals(mesh);
|
||||
write_uv_maps(mesh);
|
||||
}
|
||||
|
||||
void MeshData::set_material()
|
||||
void MeshData::write_material()
|
||||
{
|
||||
Object *object = (Object *)id;
|
||||
Material *mat = nullptr;
|
||||
@ -157,11 +138,39 @@ void MeshData::set_material()
|
||||
mat_data = nullptr;
|
||||
return;
|
||||
}
|
||||
pxr::SdfPath id = MaterialData::prim_id(scene_delegate, mat);
|
||||
mat_data = scene_delegate->material_data(id);
|
||||
pxr::SdfPath id = MaterialData::get_prim_id(scene_delegate, mat);
|
||||
mat_data = scene_delegate->get_material_data(id);
|
||||
if (!mat_data) {
|
||||
scene_delegate->materials[id] = MaterialData::create(scene_delegate, mat);
|
||||
mat_data = scene_delegate->material_data(id);
|
||||
mat_data = scene_delegate->get_material_data(id);
|
||||
}
|
||||
}
|
||||
|
||||
void MeshData::write_uv_maps(Mesh *mesh)
|
||||
{
|
||||
blender::Span<MLoopTri> loopTris = mesh->looptris();
|
||||
const float(*luvs)[2] = (float(*)[2])CustomData_get_layer(&mesh->ldata, CD_PROP_FLOAT2);
|
||||
if (luvs) {
|
||||
uvs.reserve(loopTris.size() * 3);
|
||||
for (MLoopTri lt : loopTris) {
|
||||
uvs.push_back(pxr::GfVec2f(luvs[lt.tri[0]]));
|
||||
uvs.push_back(pxr::GfVec2f(luvs[lt.tri[1]]));
|
||||
uvs.push_back(pxr::GfVec2f(luvs[lt.tri[2]]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MeshData::write_normals(Mesh *mesh)
|
||||
{
|
||||
blender::Span<MLoopTri> loopTris = mesh->looptris();
|
||||
const float(*lnors)[3] = (float(*)[3])CustomData_get_layer(&mesh->ldata, CD_NORMAL);
|
||||
if (lnors) {
|
||||
normals.reserve(loopTris.size() * 3);
|
||||
for (MLoopTri lt : loopTris) {
|
||||
normals.push_back(pxr::GfVec3f(lnors[lt.tri[0]]));
|
||||
normals.push_back(pxr::GfVec3f(lnors[lt.tri[1]]));
|
||||
normals.push_back(pxr::GfVec3f(lnors[lt.tri[2]]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,17 +181,17 @@ void MeshData::init()
|
||||
Object *object = (Object *)id;
|
||||
if (object->type == OB_MESH && object->mode == OB_MODE_OBJECT &&
|
||||
BLI_listbase_is_empty(&object->modifiers)) {
|
||||
set_mesh((Mesh *)object->data);
|
||||
write_mesh((Mesh *)object->data);
|
||||
}
|
||||
else {
|
||||
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
|
||||
if (mesh) {
|
||||
set_mesh(mesh);
|
||||
write_mesh(mesh);
|
||||
}
|
||||
BKE_object_to_mesh_clear(object);
|
||||
}
|
||||
|
||||
set_material();
|
||||
write_material();
|
||||
}
|
||||
|
||||
void MeshData::insert()
|
||||
@ -215,7 +224,7 @@ void MeshData::update()
|
||||
}
|
||||
else {
|
||||
if (id->recalc & ID_RECALC_SHADING) {
|
||||
set_material();
|
||||
write_material();
|
||||
bits |= pxr::HdChangeTracker::DirtyMaterialId;
|
||||
}
|
||||
if (id->recalc & ID_RECALC_TRANSFORM) {
|
||||
|
@ -21,23 +21,26 @@ class MeshData : public ObjectData {
|
||||
void insert() override;
|
||||
void remove() override;
|
||||
void update() override;
|
||||
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
bool update_visibility(View3D *view3d) override;
|
||||
|
||||
pxr::HdMeshTopology mesh_topology();
|
||||
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation);
|
||||
pxr::SdfPath material_id();
|
||||
pxr::HdMeshTopology get_mesh_topology();
|
||||
pxr::HdPrimvarDescriptorVector get_primvar_descriptors(pxr::HdInterpolation interpolation);
|
||||
pxr::SdfPath get_material_id();
|
||||
|
||||
protected:
|
||||
void set_mesh(Mesh *mesh);
|
||||
void set_material();
|
||||
void write_mesh(Mesh *mesh);
|
||||
void write_material();
|
||||
void write_uv_maps(Mesh *mesh);
|
||||
void write_normals(Mesh *mesh);
|
||||
|
||||
protected:
|
||||
pxr::VtIntArray face_vertex_counts;
|
||||
pxr::VtIntArray face_vertex_indices;
|
||||
pxr::VtVec3fArray vertices;
|
||||
pxr::VtVec3fArray normals;
|
||||
pxr::VtVec2fArray uvs;
|
||||
|
||||
pxr::VtVec3fArray normals;
|
||||
pxr::VtMatrix4dArray instances;
|
||||
|
||||
MaterialData *mat_data;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
namespace mx = MaterialX;
|
||||
|
||||
void HdMtlxConvertToMaterialNetworkMap(std::string const &mtlx_path,
|
||||
void hdmtlx_convert_to_materialnetworkmap(std::string const &mtlx_path,
|
||||
pxr::TfTokenVector const &shader_source_types,
|
||||
pxr::TfTokenVector const &render_contexts,
|
||||
pxr::HdMaterialNetworkMap *out)
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
struct pxr::HdMaterialNetworkMap;
|
||||
|
||||
void HdMtlxConvertToMaterialNetworkMap(std::string const &mtlx_path,
|
||||
pxr::TfTokenVector const &shader_source_types,
|
||||
pxr::TfTokenVector const &render_contexts,
|
||||
pxr::HdMaterialNetworkMap *out);
|
||||
void hdmtlx_convert_to_materialnetworkmap(std::string const &mtlx_path,
|
||||
pxr::TfTokenVector const &shader_source_types,
|
||||
pxr::TfTokenVector const &render_contexts,
|
||||
pxr::HdMaterialNetworkMap *out);
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
bool ObjectData::supported(Object *object)
|
||||
bool ObjectData::is_supported(Object *object)
|
||||
{
|
||||
switch (object->type) {
|
||||
case OB_MESH:
|
||||
@ -56,7 +56,7 @@ std::unique_ptr<ObjectData> ObjectData::create(BlenderSceneDelegate *scene_deleg
|
||||
return data;
|
||||
}
|
||||
|
||||
pxr::SdfPath ObjectData::prim_id(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||
pxr::SdfPath ObjectData::get_prim_id(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||
{
|
||||
/* Making id of object in form like O_<pointer in 16 hex digits format>. Example:
|
||||
* O_000002073e369608 */
|
||||
@ -68,10 +68,10 @@ pxr::SdfPath ObjectData::prim_id(BlenderSceneDelegate *scene_delegate, Object *o
|
||||
ObjectData::ObjectData(BlenderSceneDelegate *scene_delegate, Object *object)
|
||||
: IdData(scene_delegate, (ID *)object), visible(true)
|
||||
{
|
||||
p_id = prim_id(scene_delegate, object);
|
||||
p_id = get_prim_id(scene_delegate, object);
|
||||
}
|
||||
|
||||
pxr::GfMatrix4d ObjectData::transform()
|
||||
pxr::GfMatrix4d ObjectData::get_transform()
|
||||
{
|
||||
return gf_matrix_from_transform(((Object *)id)->object_to_world);
|
||||
}
|
||||
|
@ -16,15 +16,16 @@ namespace blender::render::hydra {
|
||||
|
||||
class ObjectData : public IdData {
|
||||
public:
|
||||
static bool supported(Object *object);
|
||||
static bool is_supported(Object *object);
|
||||
static std::unique_ptr<ObjectData> create(BlenderSceneDelegate *scene_delegate, Object *object);
|
||||
static pxr::SdfPath prim_id(BlenderSceneDelegate *scene_delegate, Object *object);
|
||||
static pxr::SdfPath get_prim_id(BlenderSceneDelegate *scene_delegate, Object *object);
|
||||
|
||||
ObjectData(BlenderSceneDelegate *scene_delegate, Object *object);
|
||||
|
||||
virtual pxr::GfMatrix4d transform();
|
||||
virtual pxr::GfMatrix4d get_transform();
|
||||
virtual bool update_visibility(View3D *view3d);
|
||||
|
||||
public:
|
||||
bool visible;
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,7 @@ std::unique_ptr<WorldData> WorldData::create(BlenderSceneDelegate *scene_delegat
|
||||
return data;
|
||||
}
|
||||
|
||||
pxr::SdfPath WorldData::prim_id(BlenderSceneDelegate *scene_delegate)
|
||||
pxr::SdfPath WorldData::get_prim_id(BlenderSceneDelegate *scene_delegate)
|
||||
{
|
||||
return scene_delegate->GetDelegateID().AppendElementString("World");
|
||||
}
|
||||
@ -46,7 +46,7 @@ pxr::SdfPath WorldData::prim_id(BlenderSceneDelegate *scene_delegate)
|
||||
WorldData::WorldData(BlenderSceneDelegate *scene_delegate, World *world, bContext *context)
|
||||
: IdData(scene_delegate, (ID *)world), context(context)
|
||||
{
|
||||
p_id = prim_id(scene_delegate);
|
||||
p_id = get_prim_id(scene_delegate);
|
||||
CLOG_INFO(LOG_BSD, 2, "%s, id=%s", id->name, p_id.GetText());
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ void WorldData::init()
|
||||
}
|
||||
}
|
||||
|
||||
pxr::GfMatrix4d WorldData::transform()
|
||||
pxr::GfMatrix4d WorldData::get_transform()
|
||||
{
|
||||
pxr::GfMatrix4d transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90),
|
||||
pxr::GfVec3d());
|
||||
|
@ -23,7 +23,7 @@ class WorldData : public IdData {
|
||||
static std::unique_ptr<WorldData> create(BlenderSceneDelegate *scene_delegate,
|
||||
World *world,
|
||||
bContext *context);
|
||||
static pxr::SdfPath prim_id(BlenderSceneDelegate *scene_delegate);
|
||||
static pxr::SdfPath get_prim_id(BlenderSceneDelegate *scene_delegate);
|
||||
|
||||
WorldData(BlenderSceneDelegate *scene_delegate, World *world, bContext *context);
|
||||
|
||||
@ -33,8 +33,7 @@ class WorldData : public IdData {
|
||||
void update() override;
|
||||
void update(World *world);
|
||||
|
||||
pxr::GfMatrix4d transform();
|
||||
|
||||
pxr::GfMatrix4d get_transform();
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user