libpython: improved Texture bindings

metadata
Wenzel Jakob 2014-09-29 18:38:46 +02:00
parent 70f08931b9
commit b198521eb1
2 changed files with 14 additions and 1 deletions

View File

@ -48,6 +48,7 @@ public:
* two \ref Spectrum data structures corresponding to the U and V derivative.
*
* \remark This function is usually implemented pointwise without any kind of filtering.
* The Python signature is <tt>dx, dy = tex.evalGradient(its)</tt>.
*/
virtual void evalGradient(const Intersection &its, Spectrum *gradient) const;

View File

@ -21,6 +21,12 @@ static const Intersection &bsdfsamplingrecord_get_its(const BSDFSamplingRecord &
return bRec.its;
}
static bp::tuple texture_evalGradient(const Texture *texture, const Intersection &its) {
Spectrum grad[2];
texture->evalGradient(its, grad);
return bp::make_tuple(grad[0], grad[1]);
}
static unsigned int bsdf_getType_1(const BSDF *bsdf) {
return bsdf->getType();
}
@ -301,6 +307,8 @@ bp::tuple Sensor_getSamplePosition(Sensor *sensor, const PositionSamplingRecord
return bp::make_tuple(result, samplePos);
}
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getBitmap_overloads, getBitmap, 0, 1)
void export_render() {
bp::object renderModule(
bp::handle<>(bp::borrowed(PyImport_AddModule("mitsuba.render"))));
@ -756,12 +764,16 @@ void export_render() {
BP_CLASS(Texture, ConfigurableObject, bp::no_init)
.def("eval", &Texture::eval, BP_RETURN_VALUE)
.def("evalGradient", &texture_evalGradient)
.def("getAverage", &Texture::getAverage, BP_RETURN_VALUE)
.def("getMinimum", &Texture::getMinimum, BP_RETURN_VALUE)
.def("getMaximum", &Texture::getMaximum, BP_RETURN_VALUE)
.def("getResolution", &Texture::getResolution, BP_RETURN_VALUE)
.def("isConstant", &Texture::isConstant)
.def("usesRayDifferentials", &Texture::usesRayDifferentials);
.def("isMonochromatic", &Texture::isMonochromatic)
.def("expand", &Texture::expand, BP_RETURN_VALUE)
.def("usesRayDifferentials", &Texture::usesRayDifferentials)
.def("getBitmap", &Texture::getBitmap, getBitmap_overloads()[BP_RETURN_VALUE]);
bp::class_<Noise>("Noise")
.def("perlinNoise", &Noise::perlinNoise)