Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/util.h
| Show All 12 Lines | |||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #ifndef __BLENDER_UTIL_H__ | #ifndef __BLENDER_UTIL_H__ | ||||
| #define __BLENDER_UTIL_H__ | #define __BLENDER_UTIL_H__ | ||||
| #include "scene/mesh.h" | #include "scene/mesh.h" | ||||
| #include "scene/scene.h" | |||||
| #include "util/algorithm.h" | #include "util/algorithm.h" | ||||
| #include "util/array.h" | #include "util/array.h" | ||||
| #include "util/map.h" | #include "util/map.h" | ||||
| #include "util/path.h" | #include "util/path.h" | ||||
| #include "util/set.h" | #include "util/set.h" | ||||
| #include "util/transform.h" | #include "util/transform.h" | ||||
| #include "util/types.h" | #include "util/types.h" | ||||
| #include "util/vector.h" | #include "util/vector.h" | ||||
| /* Hacks to hook into Blender API | /* Hacks to hook into Blender API | ||||
| * todo: clean this up ... */ | * todo: clean this up ... */ | ||||
| extern "C" { | extern "C" { | ||||
| void BKE_image_user_frame_calc(void *ima, void *iuser, int cfra); | void BKE_image_user_frame_calc(void *ima, void *iuser, int cfra); | ||||
| void BKE_image_user_file_path(void *iuser, void *ima, char *path); | void BKE_image_user_file_path_ex(void *iuser, void *ima, char *path, bool resolve_udim); | ||||
| unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame, int tile); | unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame, int tile); | ||||
| float *BKE_image_get_float_pixels_for_frame(void *image, int frame, int tile); | float *BKE_image_get_float_pixels_for_frame(void *image, int frame, int tile); | ||||
| } | } | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| struct BObjectInfo { | struct BObjectInfo { | ||||
| /* Object directly provided by the depsgraph iterator. This object is only valid during one | /* Object directly provided by the depsgraph iterator. This object is only valid during one | ||||
| ▲ Show 20 Lines • Show All 240 Lines • ▼ Show 20 Lines | static inline int render_resolution_x(BL::RenderSettings &b_render) | ||||
| return b_render.resolution_x() * b_render.resolution_percentage() / 100; | return b_render.resolution_x() * b_render.resolution_percentage() / 100; | ||||
| } | } | ||||
| static inline int render_resolution_y(BL::RenderSettings &b_render) | static inline int render_resolution_y(BL::RenderSettings &b_render) | ||||
| { | { | ||||
| return b_render.resolution_y() * b_render.resolution_percentage() / 100; | return b_render.resolution_y() * b_render.resolution_percentage() / 100; | ||||
| } | } | ||||
| static inline string image_user_file_path(BL::ImageUser &iuser, | static inline string image_user_file_path(BL::ImageUser &iuser, BL::Image &ima, int cfra) | ||||
| BL::Image &ima, | |||||
| int cfra, | |||||
| bool load_tiled) | |||||
| { | { | ||||
| char filepath[1024]; | char filepath[1024]; | ||||
| iuser.tile(0); | iuser.tile(0); | ||||
| BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra); | BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra); | ||||
| BKE_image_user_file_path(iuser.ptr.data, ima.ptr.data, filepath); | BKE_image_user_file_path_ex(iuser.ptr.data, ima.ptr.data, filepath, false); | ||||
| string filepath_str = string(filepath); | return string(filepath); | ||||
| if (load_tiled && ima.source() == BL::Image::source_TILED) { | |||||
| string udim; | |||||
| if (!ima.tiles.empty()) { | |||||
| udim = to_string(ima.tiles[0].number()); | |||||
| } | |||||
| string_replace(filepath_str, udim, "<UDIM>"); | |||||
| } | |||||
| return filepath_str; | |||||
| } | } | ||||
| static inline int image_user_frame_number(BL::ImageUser &iuser, BL::Image &ima, int cfra) | static inline int image_user_frame_number(BL::ImageUser &iuser, BL::Image &ima, int cfra) | ||||
| { | { | ||||
| BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra); | BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra); | ||||
| return iuser.frame_current(); | return iuser.frame_current(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 356 Lines • ▼ Show 20 Lines | static inline uint object_ray_visibility(BL::Object &b_ob) | ||||
| flag |= b_ob.visible_glossy() ? PATH_RAY_GLOSSY : 0; | flag |= b_ob.visible_glossy() ? PATH_RAY_GLOSSY : 0; | ||||
| flag |= b_ob.visible_transmission() ? PATH_RAY_TRANSMIT : 0; | flag |= b_ob.visible_transmission() ? PATH_RAY_TRANSMIT : 0; | ||||
| flag |= b_ob.visible_shadow() ? PATH_RAY_SHADOW : 0; | flag |= b_ob.visible_shadow() ? PATH_RAY_SHADOW : 0; | ||||
| flag |= b_ob.visible_volume_scatter() ? PATH_RAY_VOLUME_SCATTER : 0; | flag |= b_ob.visible_volume_scatter() ? PATH_RAY_VOLUME_SCATTER : 0; | ||||
| return flag; | return flag; | ||||
| } | } | ||||
| /* Check whether some of "built-in" motion-related attributes are needed to be exported (includes | |||||
| * things like velocity from cache modifier, fluid simulation). | |||||
| * | |||||
| * NOTE: This code is run prior to object motion blur initialization. so can not access properties | |||||
| * set by `sync_object_motion_init()`. */ | |||||
| static inline bool object_need_motion_attribute(BObjectInfo &b_ob_info, Scene *scene) | |||||
| { | |||||
| const Scene::MotionType need_motion = scene->need_motion(); | |||||
| if (need_motion == Scene::MOTION_NONE) { | |||||
| /* Simple case: neither motion pass nor motion blur is needed, no need in the motion related | |||||
| * attributes. */ | |||||
| return false; | |||||
| } | |||||
| if (need_motion == Scene::MOTION_BLUR) { | |||||
| /* A bit tricky and implicit case: | |||||
| * - Motion blur is enabled in the scene, which implies specific number of time steps for | |||||
| * objects. | |||||
| * - If the object has motion blur disabled on it, it will have 0 time steps. | |||||
| * - Motion attribute expects non-zero time steps. | |||||
| * | |||||
| * Avoid adding motion attributes if the motion blur will enforce 0 motion steps. */ | |||||
| PointerRNA cobject = RNA_pointer_get(&b_ob_info.real_object.ptr, "cycles"); | |||||
| const bool use_motion = get_boolean(cobject, "use_motion_blur"); | |||||
| if (!use_motion) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| /* Motion pass which implies 3 motion steps, or motion blur which is not disabled on object | |||||
| * level. */ | |||||
| return true; | |||||
| } | |||||
| class EdgeMap { | class EdgeMap { | ||||
| public: | public: | ||||
| EdgeMap() | EdgeMap() | ||||
| { | { | ||||
| } | } | ||||
| void clear() | void clear() | ||||
| { | { | ||||
| Show All 29 Lines | |||||