Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Objects/decalobject.cpp')
-rw-r--r--Source/Objects/decalobject.cpp88
1 files changed, 43 insertions, 45 deletions
diff --git a/Source/Objects/decalobject.cpp b/Source/Objects/decalobject.cpp
index 9f9f2190..e4c2fc71 100644
--- a/Source/Objects/decalobject.cpp
+++ b/Source/Objects/decalobject.cpp
@@ -50,15 +50,14 @@
extern Timer game_timer;
-std::map<std::string,RC_DecalTexture> DecalObject::textureCache;
+std::map<std::string, RC_DecalTexture> DecalObject::textureCache;
extern bool g_debug_runtime_disable_decal_object_draw;
extern bool g_debug_runtime_disable_decal_object_pre_draw_frame;
-DecalObject::DecalObject()
-{
+DecalObject::DecalObject() {
collidable = false;
- box_.dims = vec3(1.0f);
+ box_.dims = vec3(1.0f);
spawn_time_ = game_timer.game_time;
}
@@ -68,16 +67,16 @@ bool DecalObject::Initialize() {
void DecalObject::Dispose() {
texture.Set(NULL);
- const std::map<std::string,RC_DecalTexture>::iterator& texit = textureCache.find(obj_file);
- if(texit != textureCache.end()) {
- if(texit->second.GetReferenceCount() == 1) { // Owned only by texture cache
+ const std::map<std::string, RC_DecalTexture>::iterator& texit = textureCache.find(obj_file);
+ if (texit != textureCache.end()) {
+ if (texit->second.GetReferenceCount() == 1) { // Owned only by texture cache
textureCache.erase(texit);
}
}
}
void DecalObject::GetDisplayName(char* buf, int buf_size) {
- if( GetName().empty() ) {
+ if (GetName().empty()) {
FormatString(buf, buf_size, "%d, Decal: %s", GetID(), obj_file.c_str());
} else {
FormatString(buf, buf_size, "%s, Decal: %s", GetName().c_str(), obj_file.c_str());
@@ -91,91 +90,90 @@ void DecalObject::Draw() {
// Add fading line in the direction of the decal projector
DebugDraw::Instance()->AddLine(
- GetTransform() * vec3(0.0f, 0.5f, 0.0f),
+ GetTransform() * vec3(0.0f, 0.5f, 0.0f),
GetTransform() * vec3(0.0f, -0.5f, 0.0f),
vec4(0.0f, 0.0f, 0.0f, 1.0f),
vec4(0.0f, 0.0f, 0.0f, 0.0f),
_delete_on_draw);
- // Add cross on the side from which the decal is projected
+ // Add cross on the side from which the decal is projected
DebugDraw::Instance()->AddLine(
GetTransform() * vec3(-0.5f, 0.5f, -0.5f),
- GetTransform() * vec3( 0.5f, 0.5f, 0.5f),
+ GetTransform() * vec3(0.5f, 0.5f, 0.5f),
vec4(0.0f, 0.0f, 0.0f, 1.0f),
vec4(0.0f, 0.0f, 0.0f, 1.0f),
_delete_on_draw);
DebugDraw::Instance()->AddLine(
- GetTransform() * vec3(-0.5f, 0.5f, 0.5f),
- GetTransform() * vec3( 0.5f, 0.5f, -0.5f),
+ GetTransform() * vec3(-0.5f, 0.5f, 0.5f),
+ GetTransform() * vec3(0.5f, 0.5f, -0.5f),
vec4(0.0f, 0.0f, 0.0f, 1.0f),
vec4(0.0f, 0.0f, 0.0f, 1.0f),
_delete_on_draw);
}
-void DecalObject::ReceiveObjectMessageVAList( OBJECT_MSG::Type type, va_list args ) {
- switch(type){
- case OBJECT_MSG::SET_COLOR:
- case OBJECT_MSG::SET_OVERBRIGHT: {
- //vec3 old_color = color_tint_component_.temp_tint();
- color_tint_component_.ReceiveObjectMessageVAList(type, args);
- break;}
- default:
- Object::ReceiveObjectMessageVAList(type, args);
- break;
+void DecalObject::ReceiveObjectMessageVAList(OBJECT_MSG::Type type, va_list args) {
+ switch (type) {
+ case OBJECT_MSG::SET_COLOR:
+ case OBJECT_MSG::SET_OVERBRIGHT: {
+ // vec3 old_color = color_tint_component_.temp_tint();
+ color_tint_component_.ReceiveObjectMessageVAList(type, args);
+ break;
+ }
+ default:
+ Object::ReceiveObjectMessageVAList(type, args);
+ break;
}
}
-void DecalObject::PreDrawFrame(float curr_game_time){
+void DecalObject::PreDrawFrame(float curr_game_time) {
if (g_debug_runtime_disable_decal_object_pre_draw_frame) {
return;
}
- if(decal_file_ref->special_type == 6 && (curr_game_time - spawn_time_ > 2.0f)){ // Water drops fade after 2 seconds
+ if (decal_file_ref->special_type == 6 && (curr_game_time - spawn_time_ > 2.0f)) { // Water drops fade after 2 seconds
scenegraph_->map_editor->RemoveObject(this, scenegraph_, true);
}
}
-void DecalObject::GetDesc(EntityDescription &desc) const {
+void DecalObject::GetDesc(EntityDescription& desc) const {
Object::GetDesc(desc);
desc.AddString(EDF_FILE_PATH, obj_file);
color_tint_component_.AddToDescription(desc);
}
-bool DecalObject::SetFromDesc( const EntityDescription& desc ) {
+bool DecalObject::SetFromDesc(const EntityDescription& desc) {
bool ret = Object::SetFromDesc(desc);
- if( ret ) {
- for(const auto & field : desc.fields){
- switch(field.type){
+ if (ret) {
+ for (const auto& field : desc.fields) {
+ switch (field.type) {
case EDF_FILE_PATH: {
std::string type_file;
field.ReadString(&type_file);
- if(type_file != obj_file){
+ if (type_file != obj_file) {
Load(type_file);
}
- break;}
+ break;
+ }
}
- }
+ }
color_tint_component_.SetFromDescription(desc);
}
return ret;
}
-void DecalObject::Load( const std::string& type_file ) {
+void DecalObject::Load(const std::string& type_file) {
obj_file = type_file;
- //decal_file_ref = DecalFiles::Instance()->ReturnRef(type_file);
- decal_file_ref = Engine::Instance()->GetAssetManager()->LoadSync<DecalFile>(type_file);
+ // decal_file_ref = DecalFiles::Instance()->ReturnRef(type_file);
+ decal_file_ref = Engine::Instance()->GetAssetManager()->LoadSync<DecalFile>(type_file);
+
+ std::map<std::string, RC_DecalTexture>::iterator texit = textureCache.find(type_file);
- std::map<std::string,RC_DecalTexture>::iterator texit = textureCache.find(type_file);
-
- if( texit == textureCache.end() )
- {
- texture = DecalTextures::Instance()->allocateTexture( decal_file_ref->color_map, decal_file_ref->normal_map );
+ if (texit == textureCache.end()) {
+ texture = DecalTextures::Instance()->allocateTexture(decal_file_ref->color_map, decal_file_ref->normal_map);
textureCache[type_file] = texture;
- }
- else
- {
- LOGS << "Loading decal from texture cache rather than reallocating space for it" << std::endl;
+ } else {
+ LOGS << "Loading decal from texture cache rather than reallocating space for it" << std::endl;
texture = textureCache[type_file];
}
}