Some strange shit happens
This commit is contained in:
1 parent
4d9a5b0a6e
commit
c655678486
10 files changed
+148
-36
No files matched your search
+56
-13
@@ -74,6 +74,27 @@ void Character::setPathPlanner(PathPlanner planner) {
|
||||
pathPlanner = std::move(planner);
|
||||
}
|
||||
|
||||
void Character::setTexture(std::shared_ptr<ZL::Texture> texture)
|
||||
{
|
||||
for (auto& animEntry : animations) {
|
||||
for (const auto& name : animEntry.second.model.meshNamesOrdered) {
|
||||
meshTextures[name] = texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Character::setTexture(const std::string& meshName, std::shared_ptr<Texture> tex) {
|
||||
meshTextures[meshName] = std::move(tex);
|
||||
}
|
||||
/*
|
||||
void Character::setTexture(std::shared_ptr<Texture> tex) {
|
||||
for (auto& animEntry : animations) {
|
||||
for (const auto& name : animEntry.second.model.meshNamesOrdered) {
|
||||
meshTextures[name] = tex;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
AnimationState Character::resolveActiveState() const {
|
||||
|
||||
if (animations.count(currentState)) return currentState;
|
||||
@@ -299,7 +320,7 @@ void Character::draw(Renderer& renderer) {
|
||||
|
||||
AnimationState drawState = resolveActiveState();
|
||||
auto it = animations.find(drawState);
|
||||
if (it == animations.end() || !texture) return;
|
||||
if (it == animations.end()) return;
|
||||
|
||||
renderer.shaderManager.PushShader(defaultShaderName);
|
||||
renderer.RenderUniform1i(textureUniformName, 0);
|
||||
@@ -315,10 +336,12 @@ void Character::draw(Renderer& renderer) {
|
||||
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
||||
|
||||
auto& anim = it->second;
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||
auto mit = anim.model.meshes.find(name);
|
||||
if (mit == anim.model.meshes.end()) continue;
|
||||
auto tit = meshTextures.find(name);
|
||||
if (tit == meshTextures.end() || !tit->second) continue;
|
||||
glBindTexture(GL_TEXTURE_2D, tit->second->getTexID());
|
||||
modelMutable.AssignFrom(mit->second.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
@@ -335,7 +358,7 @@ void Character::draw(Renderer& renderer) {
|
||||
void Character::drawGpuSkinning(Renderer& renderer) {
|
||||
AnimationState drawState = resolveActiveState();
|
||||
auto it = animations.find(drawState);
|
||||
if (it == animations.end() || !texture)
|
||||
if (it == animations.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -372,9 +395,14 @@ void Character::drawGpuSkinning(Renderer& renderer) {
|
||||
static_cast<int>(anim.gpuSkinningShaderData.skinningMatrices.size()), false,
|
||||
anim.gpuSkinningShaderData.skinningMatrices[0].data());
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
||||
|
||||
anim.gpuSkinningShaderData.RenderVBO(renderer, anim.model.meshNamesOrdered);
|
||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||
auto pit = anim.gpuSkinningShaderData.perMesh.find(name);
|
||||
if (pit == anim.gpuSkinningShaderData.perMesh.end()) continue;
|
||||
auto tit = meshTextures.find(name);
|
||||
if (tit == meshTextures.end() || !tit->second) continue;
|
||||
glBindTexture(GL_TEXTURE_2D, tit->second->getTexID());
|
||||
pit->second.RenderVBO(renderer);
|
||||
}
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
@@ -474,6 +502,8 @@ void Character::drawShadowDepthCpu(Renderer& renderer) {
|
||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||
auto mit = anim.model.meshes.find(name);
|
||||
if (mit == anim.model.meshes.end()) continue;
|
||||
auto tit = meshTextures.find(name);
|
||||
if (tit == meshTextures.end() || !tit->second) continue;
|
||||
modelMutable.AssignFrom(mit->second.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
@@ -514,7 +544,13 @@ void Character::drawShadowDepthGpuSkinning(Renderer& renderer) {
|
||||
it->second.gpuSkinningShaderData.skinningMatrices[0].data());
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
it->second.gpuSkinningShaderData.RenderVBO(renderer, it->second.model.meshNamesOrdered);
|
||||
for (const auto& name : it->second.model.meshNamesOrdered) {
|
||||
auto pit = it->second.gpuSkinningShaderData.perMesh.find(name);
|
||||
if (pit == it->second.gpuSkinningShaderData.perMesh.end()) continue;
|
||||
auto tit = meshTextures.find(name);
|
||||
if (tit == meshTextures.end() || !tit->second) continue;
|
||||
pit->second.RenderVBO(renderer);
|
||||
}
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
renderer.PopMatrix();
|
||||
@@ -538,7 +574,7 @@ void Character::drawWithShadow(Renderer& renderer, const Eigen::Matrix4f& lightF
|
||||
void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lightFromCamera, GLuint shadowMapTex, const Eigen::Vector3f& lightDirCamera) {
|
||||
AnimationState drawState = resolveActiveState();
|
||||
auto it = animations.find(drawState);
|
||||
if (it == animations.end() || !texture) return;
|
||||
if (it == animations.end()) return;
|
||||
|
||||
static const std::string shadowShader = "default_shadow";
|
||||
|
||||
@@ -563,10 +599,12 @@ void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lig
|
||||
renderer.RotateMatrix(modelCorrectionRotation.toRotationMatrix());
|
||||
|
||||
auto& anim = it->second;
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
||||
for (const auto& name : anim.model.meshNamesOrdered) {
|
||||
auto mit = anim.model.meshes.find(name);
|
||||
if (mit == anim.model.meshes.end()) continue;
|
||||
auto tit = meshTextures.find(name);
|
||||
if (tit == meshTextures.end() || !tit->second) continue;
|
||||
glBindTexture(GL_TEXTURE_2D, tit->second->getTexID());
|
||||
modelMutable.AssignFrom(mit->second.mesh);
|
||||
modelMutable.RefreshVBO();
|
||||
renderer.DrawVertexRenderStruct(modelMutable);
|
||||
@@ -586,7 +624,7 @@ void Character::drawCpuWithShadow(Renderer& renderer, const Eigen::Matrix4f& lig
|
||||
void Character::drawGpuSkinningWithShadow(Renderer& renderer, const Eigen::Matrix4f& lightFromCamera, GLuint shadowMapTex, const Eigen::Vector3f& lightDirCamera) {
|
||||
AnimationState drawState = resolveActiveState();
|
||||
auto it = animations.find(drawState);
|
||||
if (it == animations.end() || !texture) return;
|
||||
if (it == animations.end()) return;
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
|
||||
@@ -627,10 +665,15 @@ void Character::drawGpuSkinningWithShadow(Renderer& renderer, const Eigen::Matri
|
||||
it->second.gpuSkinningShaderData.skinningMatrices[0].data());
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getTexID());
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
it->second.gpuSkinningShaderData.RenderVBO(renderer, it->second.model.meshNamesOrdered);
|
||||
for (const auto& name : it->second.model.meshNamesOrdered) {
|
||||
auto pit = it->second.gpuSkinningShaderData.perMesh.find(name);
|
||||
if (pit == it->second.gpuSkinningShaderData.perMesh.end()) continue;
|
||||
auto tit = meshTextures.find(name);
|
||||
if (tit == meshTextures.end() || !tit->second) continue;
|
||||
glBindTexture(GL_TEXTURE_2D, tit->second->getTexID());
|
||||
pit->second.RenderVBO(renderer);
|
||||
}
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
|
||||
Reference in new issue
Block a user