2 * Copyright 2011, Blender Foundation.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef __OSL_SERVICES_H__
20 #define __OSL_SERVICES_H__
22 /* OSL Render Services
24 * Implementation of OSL render services, to retriever matrices, attributes,
25 * textures and point clouds. In principle this should only be accessing
26 * kernel data, but currently we also reach back into the Scene to retrieve
30 #include <OSL/oslexec.h>
31 #include <OSL/oslclosure.h>
42 class OSLRenderServices : public OSL::RendererServices
48 void thread_init(KernelGlobals *kernel_globals);
50 bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
51 bool get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
53 bool get_matrix(OSL::Matrix44 &result, ustring from, float time);
54 bool get_inverse_matrix(OSL::Matrix44 &result, ustring to, float time);
56 bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform);
57 bool get_matrix(OSL::Matrix44 &result, ustring from);
59 bool get_array_attribute(void *renderstate, bool derivatives,
60 ustring object, TypeDesc type, ustring name,
61 int index, void *val);
62 bool get_attribute(void *renderstate, bool derivatives, ustring object,
63 TypeDesc type, ustring name, void *val);
65 bool get_userdata(bool derivatives, ustring name, TypeDesc type,
66 void *renderstate, void *val);
67 bool has_userdata(ustring name, TypeDesc type, void *renderstate);
69 void *get_pointcloud_attr_query(ustring *attr_names,
70 TypeDesc *attr_types, int nattrs);
72 int pointcloud_search(OSL::ShaderGlobals *sg, ustring filename, const OSL::Vec3 ¢er,
73 float radius, int max_points, bool sort, size_t *out_indices,
74 float *out_distances, int derivs_offset);
76 int pointcloud_get(ustring filename, size_t *indices, int count, ustring attr_name,
77 TypeDesc attr_type, void *out_data);
80 KernelGlobals *kernel_globals;
82 static ustring u_distance;
83 static ustring u_index;
84 static ustring u_camera;
85 static ustring u_screen;
86 static ustring u_raster;
88 static ustring u_empty;
93 #endif /* __OSL_SERVICES_H__ */