diff options
| author | Ben Marsh <[email protected]> | 2019-10-22 09:07:59 -0400 |
|---|---|---|
| committer | Ben Marsh <[email protected]> | 2019-10-22 09:07:59 -0400 |
| commit | bd0027e737c6512397f841c22786274ed74b927f (patch) | |
| tree | f7ffbdb8f3741bb7f24635616cc189cba5cb865c /vrayPlug/plugin/shaveVrayInstance.cpp | |
| download | archived-shave-and-a-haircut-bd0027e737c6512397f841c22786274ed74b927f.tar.xz archived-shave-and-a-haircut-bd0027e737c6512397f841c22786274ed74b927f.zip | |
Adding Shave-and-a-Haircut 9.6
Diffstat (limited to 'vrayPlug/plugin/shaveVrayInstance.cpp')
| -rw-r--r-- | vrayPlug/plugin/shaveVrayInstance.cpp | 233 |
1 files changed, 233 insertions, 0 deletions
diff --git a/vrayPlug/plugin/shaveVrayInstance.cpp b/vrayPlug/plugin/shaveVrayInstance.cpp new file mode 100644 index 0000000..65b9806 --- /dev/null +++ b/vrayPlug/plugin/shaveVrayInstance.cpp @@ -0,0 +1,233 @@ +// Shave and a Haircut +// (c) 2019 Epic Games +// US Patent 6720962 + +/********************************************************************** + *< + FILE: shaveVrayInstance.cpp + + DESCRIPTION: VRay mesh instance for regular hair + + CREATED BY: Vladimir Dubovoy <[email protected]> + + HISTORY: created 30-03-2010 + + *> + **********************************************************************/ + +#include "shaveVrayInstance.h" +#include "shaveVrayMovingVoxelPrim.h" +#include "shaveVrayStaticVoxelPrim.h" + + +shaveVrayInstance::shaveVrayInstance( + shaveVrayPlugin *vplugin, + VR::MaterialInterface *mtl, VR::BSDFInterface *bsdf, int renderID, + VR::VolumetricInterface *volume, VR::LightList *lightList, +#if defined(VRAY30) + const VR::TraceTransform &baseTM, +#elif defined(VRAY40) + const VR::Transform &baseTM, +#endif + int objectID, + const tchar *userAttributes, int primaryVisibility) + : +#if defined(VRAY30) + VR::BaseMeshInstance(vplugin, vplugin, mtl, bsdf, renderID, volume, lightList, baseTM, objectID, userAttributes, primaryVisibility), +#elif defined(VRAY40) + VR::BaseInstance(vplugin, mtl, bsdf, renderID, volume, lightList, baseTM, objectID, userAttributes, primaryVisibility), +#endif + shaveVrayInstanceBase(vplugin) +{ + _hair() = NULL; + _stackid() = plugin->GetStackIndex(); + _squirrel()= plugin->GetSquirrel(); + _tipfade() = plugin->GetTipFade(); + _ownbsdf() = plugin->GetUseOwnBSDF(); + _spectint()= plugin->GetSpecTint(); + _spectint2()= plugin->GetSpecTint2(); + _cameraVisibility() = plugin->GetCameraVisibility(); + _reflVisibility()= plugin->GetReflVisibility(); + _refrVisibility()= plugin->GetRefrVisibility(); + _lightVisibility() = plugin->GetLightVisibility(); + _giVisibility() = plugin->GetGiVisibility(); + _selfshadow() = plugin->GetSelfShadow(); + _recvshadow() = plugin->GetRecvShadow(); + + //printf("get selfShadow %f\n",plugin->GetSelfShadow());fflush(stdout); + + _shdata() = new shaveVrayShadeData(this); + +} + +shaveVrayInstance::~shaveVrayInstance() +{ + if(shdata()) + delete shdata(); +} + +void shaveVrayInstance::compileGeometry( + VR::VRayRenderer *vray, +#if defined(VRAY30) + VR::TraceTransform *tm, +#elif defined(VRAY40) + const VR::Transform *tm, +#endif + double *times, int tmCount) +{ + LOGMSG("SHAVE", "shaveVrayInstance::compileGeometry"); + LOGMSGI("SHAVE", "id",stackid()); + + loadHair(); + + if(!hair()) + return; + +#if defined(VRAY30) || defined(VRAY40) + LOGMSG("SHAVE", plugin->useGlobalHairTree ? "useGlobalHairTree - yes":"useGlobalHairTree - no"); +#endif + +#if defined(VRAY30) + BaseMeshInstance::compileGeometry(vray, tm, times, tmCount); +#elif defined(VRAY40) + BaseInstance::compileGeometry(vray, tm, times, tmCount); +#endif + + int num_voxels = hair()->GetNumVoxels(); +#if defined(VRAY30) + VR::RayServerInterface2 *rayserver = vray->getRayServer(); +#else + VR::RayServerInterface *rayserver = vray->getRayServer(); +#endif + int rendID = rayserver->getNewRenderIDArray(num_voxels/*100*//*0*/); + + const VR::VRaySequenceData& sdata = vray->getSequenceData(); + bool blurOn = sdata.params.moblur.on != 0; + + + + //tm is not animated + if (/*tmCount == 1*/ !blurOn ) + { + for(int i = 0; i < num_voxels; i++) + { + IHairVoxel* voxel = hair()->GetVoxel(i); + if(voxel) + { + shaveVrayStaticVoxelPrim* vox_prim = new shaveVrayStaticVoxelPrim(voxel,vray,this); + + vox_prim->SetTipFade(tipfade()); + vox_prim->SetUseOwnBSDF(ownbsdf()); + vox_prim->SetSpecTint(spectint()); + vox_prim->SetSpecTint2(spectint2()); + //vox_prim->SetAmbient(ambient()); +#if defined(VRAY30) || defined(VRAY40) +#if VRAY_DLL_VERSION >= 0x36000 + int primary_visibility = getPrimaryVisibility(); +#endif + if (plugin->useGlobalHairTree && primary_visibility) + { + vox_prim->storeInGlobalTree(rayserver); + _voxprims().push_back(vox_prim); + } + else + { + if(rayserver->storeStaticPrimitive(vox_prim, NULL, rendID+i)) + _voxprims().push_back(vox_prim); + else + { + LOGMSG("PRIM", "shaveVrayInstance failed to store voxel prmitive on rayserver"); + delete vox_prim; + } + } + +#else + if(rayserver->storeStaticPrimitive(vox_prim, NULL, rendID+i /*rayserver->getNewRenderID()*/)) + _voxprims().push_back(vox_prim); + else + { + LOGMSG("SHAVE", "shaveVrayInstance failed to store voxel prmitive on rayserver"); + delete vox_prim; + } +#endif + } + } + } + else + { + for(int i = 0; i < num_voxels; i++) + { + IHairVoxel* voxel = hair()->GetVoxel(i); + if(voxel) + { + shaveVrayMovingVoxelPrim* vox_prim = new shaveVrayMovingVoxelPrim(voxel,vray,this); + + vox_prim->SetTipFade(tipfade()); + vox_prim->SetUseOwnBSDF(ownbsdf()); + vox_prim->SetSpecTint(spectint()); + vox_prim->SetSpecTint2(spectint2()); + //vox_prim->SetAmbient(ambient()); +#if defined(VRAY30) || defined(VRAY40) +#if VRAY_DLL_VERSION >= 0x36000 + int primary_visibility = getPrimaryVisibility(); +#endif + if (plugin->useGlobalHairTree && primary_visibility) + { + vox_prim->storeInGlobalTree(rayserver); + _voxprims().push_back(vox_prim); + } + else + { + if(rayserver->storeMovingPrimitive(vox_prim, NULL, rendID+i)) + _voxprims().push_back(vox_prim); + else + { + LOGMSG("PRIM", "shaveVrayInstance failed to store voxel prmitive on rayserver"); + delete vox_prim; + } + } + +#else + if(rayserver->storeMovingPrimitive(vox_prim, NULL, rendID+i)) + _voxprims().push_back(vox_prim); + else + { + LOGMSG("PRIM", "shaveVrayInstance failed to store voxel prmitive on rayserver"); + delete vox_prim; + } +#endif + } + } + } +#ifdef DEBUG +#ifdef WIN32 + assert(_CrtCheckMemory()); +#endif +#endif + + LOGMSG("SHAVE", "shaveVrayInstance::compileGeometry - OK"); +} + +void shaveVrayInstance::clearGeometry(VR::VRayRenderer *vray) +{ + LOGMSG("SHAVE", "shaveVrayInstance::clearGeometry"); + + /////////// dbg ///////// + //return; + //////////////////////// + + shaveVrayInstanceBase::freeMem(); +#if defined(VRAY30) + BaseMeshInstance::clearGeometry(vray); +#elif defined(VRAY40) + BaseInstance::clearGeometry(vray); +#endif + + //if(stack) + //{ + // delete stack; + // stack = NULL; + //} + LOGMSG("SHAVE", "shaveVrayInstance::clearGeometry - OK"); +} + |