mirror of
https://github.com/overte-org/overte.git
synced 2025-08-17 11:06:47 +02:00
Fixing the display of the collision hull mesh
This commit is contained in:
parent
353fe774ca
commit
b24af06589
6 changed files with 36 additions and 4 deletions
|
@ -71,6 +71,10 @@ void MeshPartPayload::initCache() {
|
|||
|
||||
}
|
||||
|
||||
void MeshPartPayload::updateDrawMaterial(model::MaterialPointer material) {
|
||||
_drawMaterial = material;
|
||||
}
|
||||
|
||||
void MeshPartPayload::updateModelLocation(glm::vec3 position, glm::quat orientation) {
|
||||
_modelPosition = position;
|
||||
_modelOrientation = orientation;
|
||||
|
|
|
@ -36,6 +36,9 @@ public:
|
|||
glm::vec3 _modelPosition;
|
||||
glm::quat _modelOrientation;
|
||||
|
||||
// can replace the material used to draw that item
|
||||
void updateDrawMaterial(model::MaterialPointer material);
|
||||
|
||||
void updateModelLocation(glm::vec3 position, glm::quat orientation);
|
||||
|
||||
// Render Item interface
|
||||
|
|
|
@ -544,6 +544,7 @@ void Model::removeFromScene(std::shared_ptr<render::Scene> scene, render::Pendin
|
|||
pendingChanges.removeItem(item);
|
||||
}
|
||||
_renderItems.clear();
|
||||
_renderItemsSet.clear();
|
||||
_readyWhenAdded = false;
|
||||
}
|
||||
|
||||
|
@ -1118,8 +1119,10 @@ AABox Model::getPartBounds(int meshIndex, int partIndex, glm::vec3 modelPosition
|
|||
|
||||
void Model::segregateMeshGroups() {
|
||||
QSharedPointer<NetworkGeometry> networkGeometry;
|
||||
bool showingCollisionHull = false;
|
||||
if (_showCollisionHull && _collisionGeometry && _collisionGeometry->isLoaded()) {
|
||||
networkGeometry = _collisionGeometry;
|
||||
showingCollisionHull = true;
|
||||
} else {
|
||||
networkGeometry = _geometry;
|
||||
}
|
||||
|
@ -1127,8 +1130,10 @@ void Model::segregateMeshGroups() {
|
|||
const std::vector<std::unique_ptr<NetworkMesh>>& networkMeshes = networkGeometry->getMeshes();
|
||||
|
||||
// all of our mesh vectors must match in size
|
||||
if ((int)networkMeshes.size() != geometry.meshes.size() ||
|
||||
geometry.meshes.size() != _meshStates.size()) {
|
||||
auto geoMeshesSize = geometry.meshes.size();
|
||||
if ((int)networkMeshes.size() != geoMeshesSize ||
|
||||
// geometry.meshes.size() != _meshStates.size()) {
|
||||
geoMeshesSize > _meshStates.size()) {
|
||||
qDebug() << "WARNING!!!! Mesh Sizes don't match! We will not segregate mesh groups yet.";
|
||||
return;
|
||||
}
|
||||
|
@ -1146,7 +1151,11 @@ void Model::segregateMeshGroups() {
|
|||
// Create the render payloads
|
||||
int totalParts = mesh.parts.size();
|
||||
for (int partIndex = 0; partIndex < totalParts; partIndex++) {
|
||||
_renderItemsSet << std::make_shared<MeshPartPayload>(this, i, partIndex, shapeID, _translation, _rotation);
|
||||
auto renderItem = std::make_shared<MeshPartPayload>(this, i, partIndex, shapeID, _translation, _rotation);
|
||||
if (showingCollisionHull) {
|
||||
renderItem->updateDrawMaterial(ModelRender::getCollisionHullMaterial());
|
||||
}
|
||||
_renderItemsSet << renderItem;
|
||||
shapeID++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,3 +280,14 @@ void ModelRender::pickPrograms(gpu::Batch& batch, RenderArgs::RenderMode mode, b
|
|||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
||||
}
|
||||
}
|
||||
|
||||
model::MaterialPointer ModelRender::_collisionHullMaterial;
|
||||
|
||||
model::MaterialPointer ModelRender::getCollisionHullMaterial() {
|
||||
if (!_collisionHullMaterial) {
|
||||
_collisionHullMaterial = std::make_shared<model::Material>();
|
||||
_collisionHullMaterial->setDiffuse(glm::vec3(1.0f, 0.5f, 0.0f));
|
||||
}
|
||||
return _collisionHullMaterial;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,6 +149,11 @@ public:
|
|||
|
||||
static const RenderPipelineLib& getRenderPipelineLib();
|
||||
|
||||
// Collision hull Material
|
||||
static model::MaterialPointer _collisionHullMaterial;
|
||||
|
||||
static model::MaterialPointer getCollisionHullMaterial();
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_ModelRender_h
|
|
@ -82,7 +82,7 @@ void avatarDataFromScriptValue(const QScriptValue &object, AvatarData* &out) {
|
|||
}
|
||||
|
||||
Q_DECLARE_METATYPE(controller::InputController*)
|
||||
static int inputControllerPointerId = qRegisterMetaType<controller::InputController*>();
|
||||
//static int inputControllerPointerId = qRegisterMetaType<controller::InputController*>();
|
||||
|
||||
QScriptValue inputControllerToScriptValue(QScriptEngine *engine, controller::InputController* const &in) {
|
||||
return engine->newQObject(in);
|
||||
|
|
Loading…
Reference in a new issue