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

dynamiclightcollection.cpp « Graphics « Source - github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2f6e3b186c8f6bfb90f3b6433211cff11d1e2a10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//-----------------------------------------------------------------------------
//           Name: dynamiclightcollection.cpp
//      Developer: Wolfire Games LLC
//    Description: 
//        License: Read below
//-----------------------------------------------------------------------------
//
//
//   Copyright 2022 Wolfire Games LLC
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//
//-----------------------------------------------------------------------------
#include "dynamiclightcollection.hpp"

#include <Graphics/camera.h>
#include <Graphics/pxdebugdraw.h>
#include <Graphics/graphics.h>
#include <Graphics/shaders.h>
#include <Graphics/sky.h>
#include <Graphics/textures.h>

#include <Physics/bulletworld.h>
#include <Internal/profiler.h>
#include <Game/hardcoded_assets.h>
#include <Math/vec3math.h>
#include <Wrappers/glm.h>
#include <Logging/logdata.h>
#include <Utility/assert.h>

#include <cfloat>

DynamicLightCollection::DynamicLightCollection() {
    next_id = 0;
}

DynamicLightCollection::~DynamicLightCollection() {
}

int DynamicLightCollection::AddLight(const vec3& pos, const vec3 &color, float radius) {
	dynamic_lights.resize(dynamic_lights.size() + 1);
    DynamicLight &light = dynamic_lights.back();
    light.pos = pos;
    light.id = next_id++;
    light.color = color;
    light.radius = radius;
    return light.id;
}

bool DynamicLightCollection::MoveLight(int id, const vec3& pos) {
    DynamicLight* light = GetLightFromID(id);
    if(light){
        light->pos = pos;
        return true;
    } else {
        return false;
    }
}

bool DynamicLightCollection::DeleteLight(int id) {
    for(int i=0, len=dynamic_lights.size(); i<len; ++i){
        if(dynamic_lights[i].id == id) {
            dynamic_lights.erase(dynamic_lights.begin() + i);
            return true;
        }
    }
    return false;
}

void DynamicLightCollection::Init() {
}

void DynamicLightCollection::Dispose() {
}

DynamicLight* DynamicLightCollection::GetLightFromID(int id) {
    for(int i=0, len=dynamic_lights.size(); i<len; ++i){
        if(dynamic_lights[i].id == id) {
            return &dynamic_lights[i];
        }
    }
    return NULL;
}

void DynamicLightCollection::Draw(BulletWorld& bw) {
}