diff options
| -rw-r--r-- | indra/llmath/llvolume.cpp | 9 | ||||
| -rw-r--r-- | indra/llmath/llvolume.h | 8 | ||||
| -rw-r--r-- | indra/newview/llmeshrepository.cpp | 5 | ||||
| -rw-r--r-- | indra/newview/llmeshrepository.h | 1 | ||||
| -rw-r--r-- | indra/newview/llspatialpartition.cpp | 70 | 
5 files changed, 74 insertions, 19 deletions
| diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index b3a6880011..3da9c9ca79 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -1828,6 +1828,10 @@ LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL ge  	mSculptLevel = -2;  	mIsTetrahedron = FALSE;  	mLODScaleBias.setVec(1,1,1); +	mHullPoints = NULL; +	mHullIndices = NULL; +	mNumHullPoints = 0; +	mNumHullIndices = 0;  	// set defaults  	if (mParams.getPathParams().getCurveType() == LL_PCODE_PATH_FLEXIBLE) @@ -1879,6 +1883,11 @@ LLVolume::~LLVolume()  	mPathp = NULL;  	mProfilep = NULL;  	mVolumeFaces.clear(); + +	free(mHullPoints); +	mHullPoints = NULL; +	free(mHullIndices); +	mHullIndices = NULL;  }  BOOL LLVolume::generate() diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 857188ed28..6e080f4877 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -1068,10 +1068,16 @@ public:  	LLPath *mPathp;  	LLProfile *mProfilep;  	std::vector<Point> mMesh; - +	  	BOOL mGenerateSingleFace;  	typedef std::vector<LLVolumeFace> face_list_t;  	face_list_t mVolumeFaces; + +public: +	LLVector4a* mHullPoints; +	U16* mHullIndices; +	S32 mNumHullPoints; +	S32 mNumHullIndices;  };  std::ostream& operator<<(std::ostream &s, const LLVolumeParams &volume_params); diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 757497060a..9aba84acb4 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2130,6 +2130,11 @@ const LLMeshDecomposition* LLMeshRepository::getDecomposition(const LLUUID& mesh  	return NULL;  } +void LLMeshRepository::buildHull(const LLVolumeParams& params, S32 detail) +{ + +} +  const LLSD& LLMeshRepository::getMeshHeader(const LLUUID& mesh_id)  {  	return mThread->getMeshHeader(mesh_id); diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 736d236e2e..0bc63a8469 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -407,6 +407,7 @@ public:  	U32 getResourceCost(const LLUUID& mesh_params);  	const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id);  	const LLMeshDecomposition* getDecomposition(const LLUUID& mesh_id); +	void buildHull(const LLVolumeParams& params, S32 detail);  	const LLSD& getMeshHeader(const LLUUID& mesh_id);  	void uploadModel(std::vector<LLModelInstance>& data, LLVector3& scale, bool upload_textures, diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 327e29c6e4..148c222014 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2779,6 +2779,27 @@ void renderNormals(LLDrawable* drawablep)  	}  } +S32 get_physics_detail(const LLVolumeParams& volume_params, const LLVector3& scale) +{ +	const S32 DEFAULT_DETAIL = 1; +	const F32 LARGE_THRESHOLD = 5.f; +	const F32 MEGA_THRESHOLD = 25.f; + +	S32 detail = DEFAULT_DETAIL; +	F32 avg_scale = (scale[0]+scale[1]+scale[2])/3.f; + +	if (avg_scale > LARGE_THRESHOLD) +	{ +		detail += 1; +		if (avg_scale > MEGA_THRESHOLD) +		{ +			detail += 1; +		} +	} + +	return detail; +} +  void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)  {  	U8 physics_type = volume->getPhysicsShapeType(); @@ -2904,23 +2925,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)  	else if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::PRIM_MESH)  	{  		LLVolumeParams volume_params = volume->getVolume()->getParams(); - -		const S32 DEFAULT_DETAIL = 1; -		const F32 LARGE_THRESHOLD = 5.f; -		const F32 MEGA_THRESHOLD = 25.f; - -		S32 detail = DEFAULT_DETAIL; -		LLVector3 scale = volume->getScale(); -		F32 avg_scale = (scale[0]+scale[1]+scale[2])/3.f; - -		if (avg_scale > LARGE_THRESHOLD) -		{ -			detail += 1; -			if (avg_scale > MEGA_THRESHOLD) -			{ -				detail += 1; -			} -		} +		S32 detail = get_physics_detail(volume_params, volume->getScale());  		LLVolume* phys_volume = LLPrimitive::sVolumeManager->refVolume(volume_params, detail);  		gGL.pushMatrix(); @@ -2936,7 +2941,36 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)  		gGL.popMatrix();  		LLPrimitive::sVolumeManager->unrefVolume(phys_volume);  	} -	 +	else if (type == LLPhysicsShapeBuilderUtil::PhysicsShapeSpecification::PRIM_CONVEX) +	{ +		LLVolumeParams volume_params = volume->getVolume()->getParams(); +		S32 detail = get_physics_detail(volume_params, volume->getScale()); + +		LLVolume* phys_volume = LLPrimitive::sVolumeManager->refVolume(volume_params, detail); + +		if (phys_volume->mHullPoints && phys_volume->mHullIndices) +		{ +			gGL.pushMatrix(); +			glMultMatrixf((GLfloat*) volume->getRelativeXform().mMatrix); +			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); +			 +			LLVertexBuffer::unbind(); +			glVertexPointer(3, GL_FLOAT, 16, phys_volume->mHullPoints); +			glColor3fv(color.mV); +			glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices); +			 +			glColor4fv(color.mV); +			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); +			glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices);			 +			gGL.popMatrix(); +		} +		else +		{ +			gMeshRepo.buildHull(volume_params, detail); +		} +		LLPrimitive::sVolumeManager->unrefVolume(phys_volume); +	} +  	/*{ //analytical shape, just push visual rep.  		glColor3fv(color.mV);  		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | 
