Refactor KRResourceBinding load and isLoaded methods to reflect binding rather than loading
This commit is contained in:
@@ -170,8 +170,8 @@ void KRAudioSource::loadXML(tinyxml2::XMLElement* e)
|
|||||||
void KRAudioSource::prime()
|
void KRAudioSource::prime()
|
||||||
{
|
{
|
||||||
if (!m_isPrimed) {
|
if (!m_isPrimed) {
|
||||||
m_sample.load(&getContext());
|
m_sample.bind(&getContext());
|
||||||
if (m_sample.isLoaded()) {
|
if (m_sample.isBound()) {
|
||||||
// Prime the buffer queue
|
// Prime the buffer queue
|
||||||
m_nextBufferIndex = 0;
|
m_nextBufferIndex = 0;
|
||||||
for (int i = 0; i < KRENGINE_AUDIO_BUFFERS_PER_SOURCE; i++) {
|
for (int i = 0; i < KRENGINE_AUDIO_BUFFERS_PER_SOURCE; i++) {
|
||||||
@@ -374,7 +374,7 @@ std::string KRAudioSource::getSample()
|
|||||||
|
|
||||||
KRAudioSample* KRAudioSource::getAudioSample()
|
KRAudioSample* KRAudioSource::getAudioSample()
|
||||||
{
|
{
|
||||||
m_sample.load(&getContext());
|
m_sample.bind(&getContext());
|
||||||
return m_sample.get();
|
return m_sample.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,9 +154,9 @@ void KRCamera::render(KRNode::RenderInfo& ri)
|
|||||||
|
|
||||||
GL_PUSH_GROUP_MARKER("Sky Box");
|
GL_PUSH_GROUP_MARKER("Sky Box");
|
||||||
|
|
||||||
m_skyBox.load(&getContext());
|
m_skyBox.bind(&getContext());
|
||||||
|
|
||||||
if (m_skyBox.isLoaded()) {
|
if (m_skyBox.isBound()) {
|
||||||
m_skyBox.get()->resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
|
m_skyBox.get()->resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
|
||||||
|
|
||||||
std::string shader_name("sky_box");
|
std::string shader_name("sky_box");
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ void KRCollider::loadXML(tinyxml2::XMLElement* e)
|
|||||||
void KRCollider::loadModel()
|
void KRCollider::loadModel()
|
||||||
{
|
{
|
||||||
KRMesh* prevModel = m_model.get();
|
KRMesh* prevModel = m_model.get();
|
||||||
m_model.load(&getContext());
|
m_model.bind(&getContext());
|
||||||
if (m_model.get() != prevModel) {
|
if (m_model.get() != prevModel) {
|
||||||
getScene().notify_sceneGraphModify(this);
|
getScene().notify_sceneGraphModify(this);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ void KRCollider::loadModel()
|
|||||||
AABB KRCollider::getBounds()
|
AABB KRCollider::getBounds()
|
||||||
{
|
{
|
||||||
loadModel();
|
loadModel();
|
||||||
if (m_model.isLoaded()) {
|
if (m_model.isBound()) {
|
||||||
return AABB::Create(m_model.get()->getMinPoint(), m_model.get()->getMaxPoint(), getModelMatrix());
|
return AABB::Create(m_model.get()->getMinPoint(), m_model.get()->getMaxPoint(), getModelMatrix());
|
||||||
} else {
|
} else {
|
||||||
return AABB::Infinite();
|
return AABB::Infinite();
|
||||||
@@ -120,7 +120,7 @@ bool KRCollider::lineCast(const Vector3& v0, const Vector3& v1, HitInfo& hitinfo
|
|||||||
{
|
{
|
||||||
if (layer_mask & m_layer_mask) { // Only test if layer masks have a common bit set
|
if (layer_mask & m_layer_mask) { // Only test if layer masks have a common bit set
|
||||||
loadModel();
|
loadModel();
|
||||||
if (m_model.isLoaded()) {
|
if (m_model.isBound()) {
|
||||||
if (getBounds().intersectsLine(v0, v1)) {
|
if (getBounds().intersectsLine(v0, v1)) {
|
||||||
Vector3 v0_model_space = Matrix4::Dot(getInverseModelMatrix(), v0);
|
Vector3 v0_model_space = Matrix4::Dot(getInverseModelMatrix(), v0);
|
||||||
Vector3 v1_model_space = Matrix4::Dot(getInverseModelMatrix(), v1);
|
Vector3 v1_model_space = Matrix4::Dot(getInverseModelMatrix(), v1);
|
||||||
@@ -145,7 +145,7 @@ bool KRCollider::rayCast(const Vector3& v0, const Vector3& dir, HitInfo& hitinfo
|
|||||||
{
|
{
|
||||||
if (layer_mask & m_layer_mask) { // Only test if layer masks have a common bit set
|
if (layer_mask & m_layer_mask) { // Only test if layer masks have a common bit set
|
||||||
loadModel();
|
loadModel();
|
||||||
if (m_model.isLoaded()) {
|
if (m_model.isBound()) {
|
||||||
if (getBounds().intersectsRay(v0, dir)) {
|
if (getBounds().intersectsRay(v0, dir)) {
|
||||||
Vector3 v0_model_space = Matrix4::Dot(getInverseModelMatrix(), v0);
|
Vector3 v0_model_space = Matrix4::Dot(getInverseModelMatrix(), v0);
|
||||||
Vector3 dir_model_space = Vector3::Normalize(Matrix4::DotNoTranslate(getInverseModelMatrix(), dir));
|
Vector3 dir_model_space = Vector3::Normalize(Matrix4::DotNoTranslate(getInverseModelMatrix(), dir));
|
||||||
@@ -170,7 +170,7 @@ bool KRCollider::sphereCast(const Vector3& v0, const Vector3& v1, float radius,
|
|||||||
{
|
{
|
||||||
if (layer_mask & m_layer_mask) { // Only test if layer masks have a common bit set
|
if (layer_mask & m_layer_mask) { // Only test if layer masks have a common bit set
|
||||||
loadModel();
|
loadModel();
|
||||||
if (m_model.isLoaded()) {
|
if (m_model.isBound()) {
|
||||||
AABB sphereCastBounds = AABB::Create( // TODO - Need to cache this; perhaps encasulate within a "spherecast" class to be passed through these functions
|
AABB sphereCastBounds = AABB::Create( // TODO - Need to cache this; perhaps encasulate within a "spherecast" class to be passed through these functions
|
||||||
Vector3::Create(KRMIN(v0.x, v1.x) - radius, KRMIN(v0.y, v1.y) - radius, KRMIN(v0.z, v1.z) - radius),
|
Vector3::Create(KRMIN(v0.x, v1.x) - radius, KRMIN(v0.y, v1.y) - radius, KRMIN(v0.z, v1.z) - radius),
|
||||||
Vector3::Create(KRMAX(v0.x, v1.x) + radius, KRMAX(v0.y, v1.y) + radius, KRMAX(v0.z, v1.z) + radius)
|
Vector3::Create(KRMAX(v0.x, v1.x) + radius, KRMAX(v0.y, v1.y) + radius, KRMAX(v0.z, v1.z) + radius)
|
||||||
@@ -214,7 +214,7 @@ void KRCollider::render(RenderInfo& ri)
|
|||||||
|
|
||||||
if (ri.renderPass->getType() == RenderPassType::RENDER_PASS_FORWARD_TRANSPARENT && ri.camera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_COLLIDERS) {
|
if (ri.renderPass->getType() == RenderPassType::RENDER_PASS_FORWARD_TRANSPARENT && ri.camera->settings.debug_display == KRRenderSettings::KRENGINE_DEBUG_DISPLAY_COLLIDERS) {
|
||||||
loadModel();
|
loadModel();
|
||||||
if (m_model.isLoaded()) {
|
if (m_model.isBound()) {
|
||||||
|
|
||||||
GL_PUSH_GROUP_MARKER("Debug Overlays");
|
GL_PUSH_GROUP_MARKER("Debug Overlays");
|
||||||
|
|
||||||
|
|||||||
@@ -393,9 +393,9 @@ void KRLight::render(RenderInfo& ri)
|
|||||||
GLDEBUG(glDeleteQueriesEXT(1, &m_occlusionQuery));
|
GLDEBUG(glDeleteQueriesEXT(1, &m_occlusionQuery));
|
||||||
|
|
||||||
if (params) {
|
if (params) {
|
||||||
m_flareTexture.load(&getContext());
|
m_flareTexture.bind(&getContext());
|
||||||
|
|
||||||
if (m_flareTexture.isLoaded()) {
|
if (m_flareTexture.isBound()) {
|
||||||
m_flareTexture.get()->resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_LIGHT_FLARE);
|
m_flareTexture.get()->resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_LIGHT_FLARE);
|
||||||
KRMeshManager::KRVBOData& vertices = getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES;
|
KRMeshManager::KRVBOData& vertices = getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES;
|
||||||
|
|
||||||
|
|||||||
@@ -210,11 +210,11 @@ void KRModel::loadModel()
|
|||||||
for (int lod = 0; lod < kMeshLODCount; lod++) {
|
for (int lod = 0; lod < kMeshLODCount; lod++) {
|
||||||
KRMesh* prevMesh = nullptr;
|
KRMesh* prevMesh = nullptr;
|
||||||
prevMesh = m_meshes[lod].get();
|
prevMesh = m_meshes[lod].get();
|
||||||
m_meshes[lod].load(&getContext());
|
m_meshes[lod].bind(&getContext());
|
||||||
if (m_meshes[lod].get() != prevMesh) {
|
if (m_meshes[lod].get() != prevMesh) {
|
||||||
meshChanged = true;
|
meshChanged = true;
|
||||||
}
|
}
|
||||||
if (m_meshes[lod].isLoaded()) {
|
if (m_meshes[lod].isBound()) {
|
||||||
KRMesh* model = m_meshes[lod].get();
|
KRMesh* model = m_meshes[lod].get();
|
||||||
std::vector<KRBone*> model_bones;
|
std::vector<KRBone*> model_bones;
|
||||||
int bone_count = model->getBoneCount();
|
int bone_count = model->getBoneCount();
|
||||||
@@ -279,7 +279,7 @@ void KRModel::render(KRNode::RenderInfo& ri)
|
|||||||
int bestLOD = -1;
|
int bestLOD = -1;
|
||||||
KRMesh* pModel = nullptr;
|
KRMesh* pModel = nullptr;
|
||||||
for (int lod = 0; lod < kMeshLODCount; lod++) {
|
for (int lod = 0; lod < kMeshLODCount; lod++) {
|
||||||
if (m_meshes[lod].isLoaded()) {
|
if (m_meshes[lod].isBound()) {
|
||||||
KRMesh* pLODModel = m_meshes[lod].get();
|
KRMesh* pLODModel = m_meshes[lod].get();
|
||||||
|
|
||||||
if ((float)pLODModel->getLODCoverage() / 100.0f > lod_coverage) {
|
if ((float)pLODModel->getLODCoverage() / 100.0f > lod_coverage) {
|
||||||
@@ -292,9 +292,9 @@ void KRModel::render(KRNode::RenderInfo& ri)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lightMap.load(&getContext());
|
m_lightMap.bind(&getContext());
|
||||||
|
|
||||||
if (m_lightMap.isLoaded() && ri.camera->settings.bEnableLightMap && ri.renderPass->getType() != RENDER_PASS_SHADOWMAP && ri.renderPass->getType() != RENDER_PASS_SHADOWMAP) {
|
if (m_lightMap.isBound() && ri.camera->settings.bEnableLightMap && ri.renderPass->getType() != RENDER_PASS_SHADOWMAP && ri.renderPass->getType() != RENDER_PASS_SHADOWMAP) {
|
||||||
m_lightMap.get()->resetPoolExpiry(lod_coverage, KRTexture::TEXTURE_USAGE_LIGHT_MAP);
|
m_lightMap.get()->resetPoolExpiry(lod_coverage, KRTexture::TEXTURE_USAGE_LIGHT_MAP);
|
||||||
// TODO - Vulkan refactoring. We need to bind the shadow map in KRMesh::Render
|
// TODO - Vulkan refactoring. We need to bind the shadow map in KRMesh::Render
|
||||||
// m_pContext->getTextureManager()->selectTexture(5, m_pLightMap, lod_coverage, KRTexture::TEXTURE_USAGE_LIGHT_MAP);
|
// m_pContext->getTextureManager()->selectTexture(5, m_pLightMap, lod_coverage, KRTexture::TEXTURE_USAGE_LIGHT_MAP);
|
||||||
@@ -321,14 +321,14 @@ void KRModel::preStream(const KRViewport& viewport)
|
|||||||
float lod_coverage = viewport.coverage(getBounds());
|
float lod_coverage = viewport.coverage(getBounds());
|
||||||
|
|
||||||
for (int i = 0; i < kMeshLODCount; i++) {
|
for (int i = 0; i < kMeshLODCount; i++) {
|
||||||
if (m_meshes[i].isLoaded()) {
|
if (m_meshes[i].isBound()) {
|
||||||
m_meshes[i].get()->preStream(lod_coverage);
|
m_meshes[i].get()->preStream(lod_coverage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lightMap.load(&getContext());
|
m_lightMap.bind(&getContext());
|
||||||
|
|
||||||
if (m_lightMap.isLoaded()) {
|
if (m_lightMap.isBound()) {
|
||||||
m_lightMap.get()->resetPoolExpiry(lod_coverage, KRTexture::TEXTURE_USAGE_LIGHT_MAP);
|
m_lightMap.get()->resetPoolExpiry(lod_coverage, KRTexture::TEXTURE_USAGE_LIGHT_MAP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,7 @@ kraken_stream_level KRModel::getStreamLevel(const KRViewport& viewport)
|
|||||||
loadModel();
|
loadModel();
|
||||||
|
|
||||||
for (int lod = 0; lod < kMeshLODCount; lod++) {
|
for (int lod = 0; lod < kMeshLODCount; lod++) {
|
||||||
if (m_meshes[lod].isLoaded()) {
|
if (m_meshes[lod].isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_meshes[lod].get()->getStreamLevel());
|
stream_level = KRMIN(stream_level, m_meshes[lod].get()->getStreamLevel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,7 +355,7 @@ AABB KRModel::getBounds()
|
|||||||
|
|
||||||
// Get the bounds of the lowest lod mesh
|
// Get the bounds of the lowest lod mesh
|
||||||
for(int lod=0; lod<kMeshLODCount; lod++) {
|
for(int lod=0; lod<kMeshLODCount; lod++) {
|
||||||
if (!m_meshes[lod].isLoaded()) {
|
if (!m_meshes[lod].isBound()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
KRMesh* mesh = m_meshes[lod].get();
|
KRMesh* mesh = m_meshes[lod].get();
|
||||||
|
|||||||
@@ -117,9 +117,9 @@ void KRSprite::preStream(const KRViewport& viewport)
|
|||||||
KRNode::preStream(viewport);
|
KRNode::preStream(viewport);
|
||||||
|
|
||||||
// Pre-stream sprites, even if the alpha is zero
|
// Pre-stream sprites, even if the alpha is zero
|
||||||
m_spriteTexture.load(&getContext());
|
m_spriteTexture.bind(&getContext());
|
||||||
|
|
||||||
if (m_spriteTexture.isLoaded()) {
|
if (m_spriteTexture.isBound()) {
|
||||||
m_spriteTexture.get()->resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_SPRITE);
|
m_spriteTexture.get()->resetPoolExpiry(0.0f, KRTexture::TEXTURE_USAGE_SPRITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ void KRSprite::render(RenderInfo& ri)
|
|||||||
|
|
||||||
if (ri.renderPass->getType() == RenderPassType::RENDER_PASS_ADDITIVE_PARTICLES) {
|
if (ri.renderPass->getType() == RenderPassType::RENDER_PASS_ADDITIVE_PARTICLES) {
|
||||||
if (m_spriteAlpha > 0.0f) {
|
if (m_spriteAlpha > 0.0f) {
|
||||||
if (m_spriteTexture.isLoaded()) {
|
if (m_spriteTexture.isBound()) {
|
||||||
// TODO - Sprites are currently additive only. Need to expose this and allow for multiple blending modes
|
// TODO - Sprites are currently additive only. Need to expose this and allow for multiple blending modes
|
||||||
|
|
||||||
KRMeshManager::KRVBOData& vertices = m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES;
|
KRMeshManager::KRVBOData& vertices = m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void KRResourceBinding::clear()
|
|||||||
set(nullptr);
|
set(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRResourceBinding::isLoaded() const
|
bool KRResourceBinding::isBound() const
|
||||||
{
|
{
|
||||||
return m_resource != nullptr;
|
return m_resource != nullptr;
|
||||||
}
|
}
|
||||||
@@ -52,8 +52,8 @@ public:
|
|||||||
const std::string& getName() const;
|
const std::string& getName() const;
|
||||||
void setName(const std::string& name);
|
void setName(const std::string& name);
|
||||||
|
|
||||||
virtual bool load(KRContext* context) = 0;
|
virtual bool bind(KRContext* context) = 0;
|
||||||
bool isLoaded() const;
|
bool isBound() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
KRResource* m_resource;
|
KRResource* m_resource;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ KRAudioSample* KRAudioSampleBinding::get()
|
|||||||
return static_cast<KRAudioSample*>(m_resource);
|
return static_cast<KRAudioSample*>(m_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRAudioSampleBinding::load(KRContext* context)
|
bool KRAudioSampleBinding::bind(KRContext* context)
|
||||||
{
|
{
|
||||||
if (m_name.size() == 0) {
|
if (m_name.size() == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ class KRAudioSampleBinding : public KRResourceBinding
|
|||||||
public:
|
public:
|
||||||
KRAudioSample* get();
|
KRAudioSample* get();
|
||||||
|
|
||||||
bool load(KRContext* context) override final;
|
bool bind(KRContext* context) override final;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
@@ -232,27 +232,27 @@ void KRMaterial::preStream(float lodCoverage)
|
|||||||
{
|
{
|
||||||
getTextures();
|
getTextures();
|
||||||
|
|
||||||
if (m_ambientMap.isLoaded()) {
|
if (m_ambientMap.isBound()) {
|
||||||
m_ambientMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_AMBIENT_MAP);
|
m_ambientMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_AMBIENT_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_diffuseMap.isLoaded()) {
|
if (m_diffuseMap.isBound()) {
|
||||||
m_diffuseMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_DIFFUSE_MAP);
|
m_diffuseMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_DIFFUSE_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_normalMap.isLoaded()) {
|
if (m_normalMap.isBound()) {
|
||||||
m_normalMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_NORMAL_MAP);
|
m_normalMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_NORMAL_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_specularMap.isLoaded()) {
|
if (m_specularMap.isBound()) {
|
||||||
m_specularMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_SPECULAR_MAP);
|
m_specularMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_SPECULAR_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_reflectionMap.isLoaded()) {
|
if (m_reflectionMap.isBound()) {
|
||||||
m_reflectionMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_REFLECTION_MAP);
|
m_reflectionMap.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_REFLECTION_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_reflectionCube.isLoaded()) {
|
if (m_reflectionCube.isBound()) {
|
||||||
m_reflectionCube.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_REFECTION_CUBE);
|
m_reflectionCube.get()->resetPoolExpiry(lodCoverage, KRTexture::TEXTURE_USAGE_REFECTION_CUBE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,27 +264,27 @@ kraken_stream_level KRMaterial::getStreamLevel()
|
|||||||
|
|
||||||
getTextures();
|
getTextures();
|
||||||
|
|
||||||
if (m_ambientMap.isLoaded()) {
|
if (m_ambientMap.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_ambientMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_AMBIENT_MAP));
|
stream_level = KRMIN(stream_level, m_ambientMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_AMBIENT_MAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_diffuseMap.isLoaded()) {
|
if (m_diffuseMap.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_diffuseMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_DIFFUSE_MAP));
|
stream_level = KRMIN(stream_level, m_diffuseMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_DIFFUSE_MAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_normalMap.isLoaded()) {
|
if (m_normalMap.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_normalMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_NORMAL_MAP));
|
stream_level = KRMIN(stream_level, m_normalMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_NORMAL_MAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_specularMap.isLoaded()) {
|
if (m_specularMap.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_specularMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_SPECULAR_MAP));
|
stream_level = KRMIN(stream_level, m_specularMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_SPECULAR_MAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_reflectionMap.isLoaded()) {
|
if (m_reflectionMap.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_reflectionMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_REFLECTION_MAP));
|
stream_level = KRMIN(stream_level, m_reflectionMap.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_REFLECTION_MAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_reflectionCube.isLoaded()) {
|
if (m_reflectionCube.isBound()) {
|
||||||
stream_level = KRMIN(stream_level, m_reflectionCube.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_REFECTION_CUBE));
|
stream_level = KRMIN(stream_level, m_reflectionCube.get()->getStreamLevel(KRTexture::TEXTURE_USAGE_REFECTION_CUBE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,12 +293,12 @@ kraken_stream_level KRMaterial::getStreamLevel()
|
|||||||
|
|
||||||
void KRMaterial::getTextures()
|
void KRMaterial::getTextures()
|
||||||
{
|
{
|
||||||
m_ambientMap.load(&getContext());
|
m_ambientMap.bind(&getContext());
|
||||||
m_diffuseMap.load(&getContext());
|
m_diffuseMap.bind(&getContext());
|
||||||
m_normalMap.load(&getContext());
|
m_normalMap.bind(&getContext());
|
||||||
m_specularMap.load(&getContext());
|
m_specularMap.bind(&getContext());
|
||||||
m_reflectionMap.load(&getContext());
|
m_reflectionMap.bind(&getContext());
|
||||||
m_reflectionCube.load(&getContext());
|
m_reflectionCube.bind(&getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_t vertexAttributes, CullMode cullMode, const std::vector<KRBone*>& bones, const std::vector<Matrix4>& bind_poses, const Matrix4& matModel, KRTexture* pLightMap, float lod_coverage)
|
void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_t vertexAttributes, CullMode cullMode, const std::vector<KRBone*>& bones, const std::vector<Matrix4>& bind_poses, const Matrix4& matModel, KRTexture* pLightMap, float lod_coverage)
|
||||||
@@ -311,11 +311,11 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
|
|||||||
Vector2 default_offset = Vector2::Zero();
|
Vector2 default_offset = Vector2::Zero();
|
||||||
|
|
||||||
bool bHasReflection = m_reflectionColor != Vector3::Zero();
|
bool bHasReflection = m_reflectionColor != Vector3::Zero();
|
||||||
bool bDiffuseMap = m_diffuseMap.isLoaded() && ri.camera->settings.bEnableDiffuseMap;
|
bool bDiffuseMap = m_diffuseMap.isBound() && ri.camera->settings.bEnableDiffuseMap;
|
||||||
bool bNormalMap = m_normalMap.isLoaded() && ri.camera->settings.bEnableNormalMap;
|
bool bNormalMap = m_normalMap.isBound() && ri.camera->settings.bEnableNormalMap;
|
||||||
bool bSpecMap = m_specularMap.isLoaded() && ri.camera->settings.bEnableSpecMap;
|
bool bSpecMap = m_specularMap.isBound() && ri.camera->settings.bEnableSpecMap;
|
||||||
bool bReflectionMap = m_reflectionMap.isLoaded() && ri.camera->settings.bEnableReflectionMap && ri.camera->settings.bEnableReflection && bHasReflection;
|
bool bReflectionMap = m_reflectionMap.isBound() && ri.camera->settings.bEnableReflectionMap && ri.camera->settings.bEnableReflection && bHasReflection;
|
||||||
bool bReflectionCubeMap = m_reflectionCube.isLoaded() && ri.camera->settings.bEnableReflection && bHasReflection;
|
bool bReflectionCubeMap = m_reflectionCube.isBound() && ri.camera->settings.bEnableReflection && bHasReflection;
|
||||||
bool bAlphaTest = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_TEST) && bDiffuseMap;
|
bool bAlphaTest = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_TEST) && bDiffuseMap;
|
||||||
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ KRMesh* KRMeshBinding::get()
|
|||||||
return static_cast<KRMesh*>(m_resource);
|
return static_cast<KRMesh*>(m_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRMeshBinding::load(KRContext* context)
|
bool KRMeshBinding::bind(KRContext* context)
|
||||||
{
|
{
|
||||||
if (m_name.size() == 0) {
|
if (m_name.size() == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ class KRMeshBinding : public KRResourceBinding
|
|||||||
public:
|
public:
|
||||||
KRMesh* get();
|
KRMesh* get();
|
||||||
|
|
||||||
bool load(KRContext* context) override final;
|
bool bind(KRContext* context) override final;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
@@ -39,7 +39,7 @@ KRTexture* KRTextureBinding::get()
|
|||||||
return static_cast<KRTexture*>(m_resource);
|
return static_cast<KRTexture*>(m_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRTextureBinding::load(KRContext* context)
|
bool KRTextureBinding::bind(KRContext* context)
|
||||||
{
|
{
|
||||||
if (m_name.size() == 0) {
|
if (m_name.size() == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ class KRTextureBinding : public KRResourceBinding
|
|||||||
public:
|
public:
|
||||||
KRTexture* get();
|
KRTexture* get();
|
||||||
|
|
||||||
bool load(KRContext* context) override final;
|
bool bind(KRContext* context) override final;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user