The containers no longer force the user to use the ptrdiff_t type for size information. For convenience, size() now always returns an int, and the size_s() method offers a way to handle arrays with more than 2 billion elements. Internally, we still use ptrdiff_t, though. Since so much code had to be changed, I took the opportunity to get rid of capitalised accessors for classes that are lowercase.undefined
@@ -264,7 +264,7 @@ void BtPhysTest::InitApp() | |||||
vec3(2.f , 1.f , 2.f) + | vec3(2.f , 1.f , 2.f) + | ||||
#endif //CAT_MODE | #endif //CAT_MODE | ||||
vec3(8.f * (float)x, 8.f * (float)y, 8.f * (float)z)); | vec3(8.f * (float)x, 8.f * (float)y, 8.f * (float)z)); | ||||
m_physobj_list.Push(new_physobj, ZERO_TIME); | |||||
m_physobj_list.push(new_physobj, ZERO_TIME); | |||||
Ticker::Ref(new_physobj); | Ticker::Ref(new_physobj); | ||||
} | } | ||||
} | } | ||||
@@ -281,9 +281,9 @@ void BtPhysTest::InitApp() | |||||
vec3(0.f, 15.f, -20.f) + | vec3(0.f, 15.f, -20.f) + | ||||
vec3(0.f, 0.f, 2.f * (float)i), 1); | vec3(0.f, 0.f, 2.f * (float)i), 1); | ||||
RopeElements << new_physobj; | RopeElements << new_physobj; | ||||
m_physobj_list.Push(new_physobj, ZERO_TIME); | |||||
m_physobj_list.push(new_physobj, ZERO_TIME); | |||||
Ticker::Ref(new_physobj); | Ticker::Ref(new_physobj); | ||||
if (RopeElements.Count() > 1) | |||||
if (RopeElements.count() > 1) | |||||
{ | { | ||||
EasyConstraint* new_constraint = new EasyConstraint(); | EasyConstraint* new_constraint = new EasyConstraint(); | ||||
@@ -342,12 +342,12 @@ void BtPhysTest::TickGame(float seconds) | |||||
{ | { | ||||
m_target_timer = TARGET_TIMER; | m_target_timer = TARGET_TIMER; | ||||
if (m_cam_target == -1) | if (m_cam_target == -1) | ||||
m_cam_target = rand((int)m_physobj_list.Count()); | |||||
m_cam_target = rand(m_physobj_list.count()); | |||||
else | else | ||||
m_cam_target = -1; | m_cam_target = -1; | ||||
} | } | ||||
for (int i = 0; i < m_physobj_list.Count(); i++) | |||||
for (int i = 0; i < m_physobj_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_physobj_list[i].m1; | PhysicsObject* PhysObj = m_physobj_list[i].m1; | ||||
float &Timer = m_physobj_list[i].m2; | float &Timer = m_physobj_list[i].m2; | ||||
@@ -425,7 +425,7 @@ void BtPhysTest::TickGame(float seconds) | |||||
#if USE_WALL | #if USE_WALL | ||||
{ | { | ||||
for (int i = 0; i < m_ground_list.Count(); i++) | |||||
for (int i = 0; i < m_ground_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_ground_list[i]; | PhysicsObject* PhysObj = m_ground_list[i]; | ||||
mat4 GroundMat = PhysObj->GetTransform(); | mat4 GroundMat = PhysObj->GetTransform(); | ||||
@@ -436,7 +436,7 @@ void BtPhysTest::TickGame(float seconds) | |||||
GroundBarycenter /= factor; | GroundBarycenter /= factor; | ||||
for (int i = 0; i < m_ground_list.Count(); i++) | |||||
for (int i = 0; i < m_ground_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_ground_list[i]; | PhysicsObject* PhysObj = m_ground_list[i]; | ||||
@@ -455,7 +455,7 @@ void BtPhysTest::TickGame(float seconds) | |||||
#if USE_ROTATION | #if USE_ROTATION | ||||
{ | { | ||||
for (int i = 0; i < m_ground_list.Count(); i++) | |||||
for (int i = 0; i < m_ground_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_ground_list[i]; | PhysicsObject* PhysObj = m_ground_list[i]; | ||||
@@ -472,7 +472,7 @@ void BtPhysTest::TickGame(float seconds) | |||||
#if USE_PLATFORM | #if USE_PLATFORM | ||||
{ | { | ||||
for (int i = 0; i < m_platform_list.Count(); i++) | |||||
for (int i = 0; i < m_platform_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_platform_list[i]; | PhysicsObject* PhysObj = m_platform_list[i]; | ||||
@@ -495,7 +495,7 @@ void BtPhysTest::TickGame(float seconds) | |||||
#if USE_CHARACTER | #if USE_CHARACTER | ||||
{ | { | ||||
for (int i = 0; i < m_character_list.Count(); i++) | |||||
for (int i = 0; i < m_character_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_character_list[i]; | PhysicsObject* PhysObj = m_character_list[i]; | ||||
EasyCharacterController* Character = (EasyCharacterController*)PhysObj->GetCharacter(); | EasyCharacterController* Character = (EasyCharacterController*)PhysObj->GetCharacter(); | ||||
@@ -528,7 +528,7 @@ void BtPhysTest::TickGame(float seconds) | |||||
PhysObjBarycenter = vec3(.0f); | PhysObjBarycenter = vec3(.0f); | ||||
factor = .0f; | factor = .0f; | ||||
for (int i = 0; i < m_character_list.Count(); i++) | |||||
for (int i = 0; i < m_character_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_character_list[i]; | PhysicsObject* PhysObj = m_character_list[i]; | ||||
mat4 GroundMat = PhysObj->GetTransform(); | mat4 GroundMat = PhysObj->GetTransform(); | ||||
@@ -548,7 +548,7 @@ void BtPhysTest::TickGame(float seconds) | |||||
#else | #else | ||||
{ | { | ||||
PhysObjBarycenter = vec3(.0f); | PhysObjBarycenter = vec3(.0f); | ||||
for (int i = 0; i < m_physobj_list.Count(); i++) | |||||
for (int i = 0; i < m_physobj_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_physobj_list[i].m1; | PhysicsObject* PhysObj = m_physobj_list[i].m1; | ||||
mat4 GroundMat = PhysObj->GetTransform(); | mat4 GroundMat = PhysObj->GetTransform(); | ||||
@@ -580,7 +580,7 @@ void BtPhysTest::TickDraw(float seconds, Scene &scene) | |||||
/* cat datas setup */ | /* cat datas setup */ | ||||
m_cat_shader = Shader::Create(LOLFX_RESOURCE_NAME(front_camera_sprite)); | m_cat_shader = Shader::Create(LOLFX_RESOURCE_NAME(front_camera_sprite)); | ||||
#if USE_BODIES | #if USE_BODIES | ||||
for (int i = 0; i < m_physobj_list.Count(); i++) | |||||
for (int i = 0; i < m_physobj_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_physobj_list[i].m1; | PhysicsObject* PhysObj = m_physobj_list[i].m1; | ||||
m_cat_sdata = new CatShaderData(((1 << VertexUsage::Position) | | m_cat_sdata = new CatShaderData(((1 << VertexUsage::Position) | | ||||
@@ -602,7 +602,7 @@ void BtPhysTest::TickDraw(float seconds, Scene &scene) | |||||
else | else | ||||
{ | { | ||||
#if CAT_MODE | #if CAT_MODE | ||||
for (int i = 0; i < m_physobj_list.Count(); i++) | |||||
for (int i = 0; i < m_physobj_list.count(); i++) | |||||
{ | { | ||||
PhysicsObject* PhysObj = m_physobj_list[i].m1; | PhysicsObject* PhysObj = m_physobj_list[i].m1; | ||||
CatShaderData* ShaderData = (CatShaderData*)PhysObj->GetCustomShaderData(); | CatShaderData* ShaderData = (CatShaderData*)PhysObj->GetCustomShaderData(); | ||||
@@ -632,45 +632,45 @@ BtPhysTest::~BtPhysTest() | |||||
Tiler::Deregister(m_cat_texture); | Tiler::Deregister(m_cat_texture); | ||||
#endif //CAT_MODE | #endif //CAT_MODE | ||||
while (m_constraint_list.Count()) | |||||
while (m_constraint_list.count()) | |||||
{ | { | ||||
EasyConstraint* CurPop = m_constraint_list.Last(); | |||||
m_constraint_list.Pop(); | |||||
EasyConstraint* CurPop = m_constraint_list.last(); | |||||
m_constraint_list.pop(); | |||||
CurPop->RemoveFromSimulation(m_simulation); | CurPop->RemoveFromSimulation(m_simulation); | ||||
delete CurPop; | delete CurPop; | ||||
} | } | ||||
while (m_ground_list.Count()) | |||||
while (m_ground_list.count()) | |||||
{ | { | ||||
PhysicsObject* CurPop = m_ground_list.Last(); | |||||
m_ground_list.Pop(); | |||||
PhysicsObject* CurPop = m_ground_list.last(); | |||||
m_ground_list.pop(); | |||||
CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | ||||
Ticker::Unref(CurPop); | Ticker::Unref(CurPop); | ||||
} | } | ||||
while (m_stairs_list.Count()) | |||||
while (m_stairs_list.count()) | |||||
{ | { | ||||
PhysicsObject* CurPop = m_stairs_list.Last(); | |||||
m_stairs_list.Pop(); | |||||
PhysicsObject* CurPop = m_stairs_list.last(); | |||||
m_stairs_list.pop(); | |||||
CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | ||||
Ticker::Unref(CurPop); | Ticker::Unref(CurPop); | ||||
} | } | ||||
while (m_character_list.Count()) | |||||
while (m_character_list.count()) | |||||
{ | { | ||||
PhysicsObject* CurPop = m_character_list.Last(); | |||||
m_character_list.Pop(); | |||||
PhysicsObject* CurPop = m_character_list.last(); | |||||
m_character_list.pop(); | |||||
CurPop->GetCharacter()->RemoveFromSimulation(m_simulation); | CurPop->GetCharacter()->RemoveFromSimulation(m_simulation); | ||||
Ticker::Unref(CurPop); | Ticker::Unref(CurPop); | ||||
} | } | ||||
while (m_platform_list.Count()) | |||||
while (m_platform_list.count()) | |||||
{ | { | ||||
PhysicsObject* CurPop = m_platform_list.Last(); | |||||
m_platform_list.Pop(); | |||||
PhysicsObject* CurPop = m_platform_list.last(); | |||||
m_platform_list.pop(); | |||||
CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | ||||
Ticker::Unref(CurPop); | Ticker::Unref(CurPop); | ||||
} | } | ||||
while (m_physobj_list.Count()) | |||||
while (m_physobj_list.count()) | |||||
{ | { | ||||
PhysicsObject* CurPop = m_physobj_list.Last().m1; | |||||
m_physobj_list.Pop(); | |||||
PhysicsObject* CurPop = m_physobj_list.last().m1; | |||||
m_physobj_list.pop(); | |||||
CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); | ||||
Ticker::Unref(CurPop); | Ticker::Unref(CurPop); | ||||
} | } | ||||
@@ -70,7 +70,7 @@ LOLFX_RESOURCE_DECLARE(shinymvtexture); | |||||
class TargetCamera | class TargetCamera | ||||
{ | { | ||||
public: | public: | ||||
void EmptyTargets() { m_targets.Empty(); } | |||||
void EmptyTargets() { m_targets.empty(); } | |||||
void AddTarget(vec3 new_target) { m_targets << new_target; } | void AddTarget(vec3 new_target) { m_targets << new_target; } | ||||
//This considers the box usage A to B as top-left to bottom-right | //This considers the box usage A to B as top-left to bottom-right | ||||
void AddTarget(box3 new_target) | void AddTarget(box3 new_target) | ||||
@@ -132,7 +132,7 @@ void EasyMeshLoadJob::RetrieveResult(class MeshViewer* app) | |||||
{ | { | ||||
for (EasyMeshViewerObject* mesh : m_meshes) | for (EasyMeshViewerObject* mesh : m_meshes) | ||||
app->AddViewerObj(mesh); | app->AddViewerObj(mesh); | ||||
m_meshes.Empty(); | |||||
m_meshes.empty(); | |||||
} | } | ||||
//MeshViewer ------------------------------------------------------------------ | //MeshViewer ------------------------------------------------------------------ | ||||
@@ -223,7 +223,7 @@ void MeshViewer::Stop() | |||||
for (Entity* entity : m_entities) Ticker::Unref(entity); | for (Entity* entity : m_entities) Ticker::Unref(entity); | ||||
//Delete objs | //Delete objs | ||||
while (m_objs.count()) delete m_objs.Pop(); | |||||
while (m_objs.count()) delete m_objs.pop(); | |||||
//Nullify all | //Nullify all | ||||
m_camera = nullptr; | m_camera = nullptr; | ||||
@@ -307,8 +307,8 @@ void MeshViewer::TickGame(float seconds) | |||||
m_menu_mesh_names_str.empty(); | m_menu_mesh_names_str.empty(); | ||||
for (ViewerObject* obj : m_objs) | for (ViewerObject* obj : m_objs) | ||||
m_menu_mesh_names_str << obj->GetName(); | m_menu_mesh_names_str << obj->GetName(); | ||||
for (ptrdiff_t i = 0; i < m_menu_mesh_names_str.count(); ++i) | |||||
m_menu_mesh_names_char << m_menu_mesh_names_str[i].C(); | |||||
for (auto str : m_menu_mesh_names_str) | |||||
m_menu_mesh_names_char << str.C(); | |||||
ImGuiIO& io = ImGui::GetIO(); | ImGuiIO& io = ImGui::GetIO(); | ||||
//CAMERA UI --------------------------------------------------------------- | //CAMERA UI --------------------------------------------------------------- | ||||
@@ -432,11 +432,11 @@ void MeshViewer::Prepare() | |||||
//Compile ref meshes | //Compile ref meshes | ||||
m_gizmos << new EasyMesh(); | m_gizmos << new EasyMesh(); | ||||
m_gizmos.Last()->Compile("[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .075 ty .5 dup[rz 90 ry 90 scv#00f dup[ry 90 scv#f00]]][sc#fff ab .1]"); | |||||
m_gizmos.last()->Compile("[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .075 ty .5 dup[rz 90 ry 90 scv#00f dup[ry 90 scv#f00]]][sc#fff ab .1]"); | |||||
m_gizmos << new EasyMesh(); | m_gizmos << new EasyMesh(); | ||||
m_gizmos.Last()->Compile("[sc#666 acap 1 .5 .5 ty -.5 sc#fff asph 2 1]"); | |||||
m_gizmos.last()->Compile("[sc#666 acap 1 .5 .5 ty -.5 sc#fff asph 2 1]"); | |||||
m_gizmos << new EasyMesh(); | m_gizmos << new EasyMesh(); | ||||
m_gizmos.Last()->Compile("[sc#fff ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 [ad 3 .1 sy -1] ty 1 rz 90 ry 90]"); | |||||
m_gizmos.last()->Compile("[sc#fff ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 [ad 3 .1 sy -1] ty 1 rz 90 ry 90]"); | |||||
// Mesh Setup | // Mesh Setup | ||||
m_render_max = vec2(-.9f, 4.1f); | m_render_max = vec2(-.9f, 4.1f); | ||||
@@ -539,19 +539,19 @@ void MeshViewer::Prepare() | |||||
m_ssetup = new SceneSetup(); | m_ssetup = new SceneSetup(); | ||||
#if NO_SC_SETUP | #if NO_SC_SETUP | ||||
m_ssetup->m_lights << new Light(); | m_ssetup->m_lights << new Light(); | ||||
m_ssetup->m_lights.Last()->SetPosition(vec4(4.f, -1.f, -4.f, 0.f)); | |||||
m_ssetup->m_lights.Last()->SetColor(vec4(.0f, .2f, .5f, 1.f)); | |||||
Ticker::Ref(m_ssetup->m_lights.Last()); | |||||
m_ssetup->m_lights.last()->SetPosition(vec4(4.f, -1.f, -4.f, 0.f)); | |||||
m_ssetup->m_lights.last()->SetColor(vec4(.0f, .2f, .5f, 1.f)); | |||||
Ticker::Ref(m_ssetup->m_lights.last()); | |||||
m_ssetup->m_lights << new Light(); | m_ssetup->m_lights << new Light(); | ||||
m_ssetup->m_lights.Last()->SetPosition(vec4(8.f, 2.f, 6.f, 0.f)); | |||||
m_ssetup->m_lights.Last()->SetColor(vec4(1.f)); | |||||
Ticker::Ref(m_ssetup->m_lights.Last()); | |||||
m_ssetup->m_lights.last()->SetPosition(vec4(8.f, 2.f, 6.f, 0.f)); | |||||
m_ssetup->m_lights.last()->SetColor(vec4(1.f)); | |||||
Ticker::Ref(m_ssetup->m_lights.last()); | |||||
EasyMesh* em = new EasyMesh(); | EasyMesh* em = new EasyMesh(); | ||||
if (em->Compile("sc#fff ab 1")) | if (em->Compile("sc#fff ab 1")) | ||||
{ | { | ||||
if (m_mesh_id == m_meshes.Count() - 1) | |||||
if (m_mesh_id == m_meshes.count() - 1) | |||||
m_mesh_id++; | m_mesh_id++; | ||||
m_meshes.Push(em, nullptr); | |||||
m_meshes.push(em, nullptr); | |||||
} | } | ||||
#else | #else | ||||
//TOUKY CHANGE THAT | //TOUKY CHANGE THAT | ||||
@@ -562,7 +562,7 @@ void MeshViewer::Prepare() | |||||
*/ | */ | ||||
m_ssetup->Startup(); | m_ssetup->Startup(); | ||||
#endif //NO_SC_SETUP | #endif //NO_SC_SETUP | ||||
for (int i = 0; i < m_ssetup->m_lights.Count(); ++i) | |||||
for (int i = 0; i < m_ssetup->m_lights.count(); ++i) | |||||
{ | { | ||||
m_light_datas << LightData(m_ssetup->m_lights[i]->GetPosition().xyz, m_ssetup->m_lights[i]->GetColor()); | m_light_datas << LightData(m_ssetup->m_lights[i]->GetPosition().xyz, m_ssetup->m_lights[i]->GetColor()); | ||||
m_ssetup->m_lights[i]->SetPosition(vec3::zero); | m_ssetup->m_lights[i]->SetPosition(vec3::zero); | ||||
@@ -609,14 +609,14 @@ void MeshViewer::Update(float seconds) | |||||
//Mesh Change | //Mesh Change | ||||
#if HAS_INPUT | #if HAS_INPUT | ||||
m_mesh_id = clamp(m_mesh_id + ((int)KeyPressed(KEY_MESH_PREV) - (int)KeyPressed(KEY_MESH_NEXT)), 0, (int)m_meshes.Count() - 1); | |||||
m_mesh_id = clamp(m_mesh_id + ((int)KeyPressed(KEY_MESH_PREV) - (int)KeyPressed(KEY_MESH_NEXT)), 0, m_meshes.count() - 1); | |||||
#endif //HAS_INPUT | #endif //HAS_INPUT | ||||
m_mesh_id1 = damp(m_mesh_id1, (float)m_mesh_id, .2f, seconds); | m_mesh_id1 = damp(m_mesh_id1, (float)m_mesh_id, .2f, seconds); | ||||
#if ALL_FEATURES | #if ALL_FEATURES | ||||
//Update light position & damping | //Update light position & damping | ||||
for (int i = 0; i < m_ssetup->m_lights.Count(); ++i) | |||||
for (int i = 0; i < m_ssetup->m_lights.count(); ++i) | |||||
{ | { | ||||
vec3 pos = (m_mat * inverse(m_mat_prev) * vec4(m_ssetup->m_lights[i]->GetPosition(), 1.f)).xyz; | vec3 pos = (m_mat * inverse(m_mat_prev) * vec4(m_ssetup->m_lights[i]->GetPosition(), 1.f)).xyz; | ||||
vec3 tgt = (m_mat * vec4(m_light_datas[i].m_pos, 1.f)).xyz; | vec3 tgt = (m_mat * vec4(m_light_datas[i].m_pos, 1.f)).xyz; | ||||
@@ -724,11 +724,11 @@ void MeshViewer::Update(float seconds) | |||||
//Target List Setup | //Target List Setup | ||||
TargetCamera tc; | TargetCamera tc; | ||||
if (m_meshes.Count() && m_mesh_id >= 0) | |||||
if (m_meshes.count() && m_mesh_id >= 0) | |||||
for (int i = 0; i < m_meshes[m_mesh_id].m1->GetVertexCount(); i++) | for (int i = 0; i < m_meshes[m_mesh_id].m1->GetVertexCount(); i++) | ||||
tc.AddTarget((m_mat * mat4::translate(m_meshes[m_mesh_id].m1->GetVertexLocation(i)))[3].xyz); | tc.AddTarget((m_mat * mat4::translate(m_meshes[m_mesh_id].m1->GetVertexLocation(i)))[3].xyz); | ||||
tc.AddTarget(box3(vec3(0.f), vec3(1.f))); | tc.AddTarget(box3(vec3(0.f), vec3(1.f))); | ||||
for (int k = 0; k < m_ssetup->m_lights.Count() && m_ssetup->m_show_lights; ++k) | |||||
for (int k = 0; k < m_ssetup->m_lights.count() && m_ssetup->m_show_lights; ++k) | |||||
{ | { | ||||
vec3 light_pos = m_ssetup->m_lights[k]->GetPosition(); | vec3 light_pos = m_ssetup->m_lights[k]->GetPosition(); | ||||
mat4 world_cam = m_camera->GetView(); | mat4 world_cam = m_camera->GetView(); | ||||
@@ -748,7 +748,7 @@ void MeshViewer::Update(float seconds) | |||||
mat4 cam_screen = m_camera->GetProjection(); | mat4 cam_screen = m_camera->GetProjection(); | ||||
//target on-screen computation | //target on-screen computation | ||||
for (int i = 0; i < tc.m_targets.Count(); i++) | |||||
for (int i = 0; i < tc.m_targets.count(); i++) | |||||
{ | { | ||||
vec3 obj_loc = tc.m_targets[i]; | vec3 obj_loc = tc.m_targets[i]; | ||||
{ | { | ||||
@@ -810,11 +810,11 @@ void MeshViewer::Update(float seconds) | |||||
while (o-- > 0) | while (o-- > 0) | ||||
{ | { | ||||
SceneSetup* new_ssetup = new SceneSetup(); | SceneSetup* new_ssetup = new SceneSetup(); | ||||
if (false) //new_ssetup->Compile(mesh.C()) && new_ssetup->m_lights.Count()) | |||||
if (false) //new_ssetup->Compile(mesh.C()) && new_ssetup->m_lights.count()) | |||||
{ | { | ||||
//Store current light datas, in World | //Store current light datas, in World | ||||
array<LightData> light_datas; | array<LightData> light_datas; | ||||
for (int i = 0; i < m_ssetup->m_lights.Count(); ++i) | |||||
for (int i = 0; i < m_ssetup->m_lights.count(); ++i) | |||||
light_datas << LightData(m_ssetup->m_lights[i]->GetPosition(), m_ssetup->m_lights[i]->GetColor()); | light_datas << LightData(m_ssetup->m_lights[i]->GetPosition(), m_ssetup->m_lights[i]->GetColor()); | ||||
if (m_ssetup) | if (m_ssetup) | ||||
@@ -824,18 +824,18 @@ void MeshViewer::Update(float seconds) | |||||
//Restore all light datas so blend can occur | //Restore all light datas so blend can occur | ||||
mat4 light_mat = m_mat * inverse(mat4(quat::fromeuler_xyz(vec3::zero))); | mat4 light_mat = m_mat * inverse(mat4(quat::fromeuler_xyz(vec3::zero))); | ||||
for (int i = 0; i < m_ssetup->m_lights.Count(); ++i) | |||||
for (int i = 0; i < m_ssetup->m_lights.count(); ++i) | |||||
{ | { | ||||
//Store local dst in current m_ld | //Store local dst in current m_ld | ||||
LightData ltmp = LightData(m_ssetup->m_lights[i]->GetPosition(), m_ssetup->m_lights[i]->GetColor()); | LightData ltmp = LightData(m_ssetup->m_lights[i]->GetPosition(), m_ssetup->m_lights[i]->GetColor()); | ||||
if (i < m_light_datas.Count()) | |||||
if (i < m_light_datas.count()) | |||||
m_light_datas[i] = ltmp; | m_light_datas[i] = ltmp; | ||||
else | else | ||||
m_light_datas << ltmp; | m_light_datas << ltmp; | ||||
vec3 loc = vec3::zero; | vec3 loc = vec3::zero; | ||||
vec4 col = vec4::zero; | vec4 col = vec4::zero; | ||||
if (i < light_datas.Count()) | |||||
if (i < light_datas.count()) | |||||
{ | { | ||||
loc = light_datas[i].m_pos; | loc = light_datas[i].m_pos; | ||||
col = light_datas[i].m_col; | col = light_datas[i].m_col; | ||||
@@ -858,7 +858,7 @@ void MeshViewer::Update(float seconds) | |||||
int o = 1; | int o = 1; | ||||
while (o-- > 0) | while (o-- > 0) | ||||
{ | { | ||||
for (int i = 0; m_ssetup && i < m_ssetup->m_custom_cmd.Count(); ++i) | |||||
for (int i = 0; m_ssetup && i < m_ssetup->m_custom_cmd.count(); ++i) | |||||
{ | { | ||||
if (m_ssetup->m_custom_cmd[i].m1 == "setmesh") | if (m_ssetup->m_custom_cmd[i].m1 == "setmesh") | ||||
{ | { | ||||
@@ -867,16 +867,16 @@ void MeshViewer::Update(float seconds) | |||||
if (em->Compile(m_ssetup->m_custom_cmd[i].m2.C(), false)) | if (em->Compile(m_ssetup->m_custom_cmd[i].m2.C(), false)) | ||||
{ | { | ||||
em->BD()->Cmdi() = 0; | em->BD()->Cmdi() = 0; | ||||
if (m_mesh_id == m_meshes.Count() - 1) | |||||
if (m_mesh_id == m_meshes.count() - 1) | |||||
m_mesh_id++; | m_mesh_id++; | ||||
m_meshes.Push(em, nullptr); | |||||
m_meshes.push(em, nullptr); | |||||
} | } | ||||
else | else | ||||
delete em; | delete em; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
m_ssetup->m_custom_cmd.Empty(); | |||||
m_ssetup->m_custom_cmd.empty(); | |||||
#endif //ALL_FEATURES | #endif //ALL_FEATURES | ||||
#if HAS_WEB | #if HAS_WEB | ||||
@@ -908,8 +908,8 @@ void MeshViewer::Update(float seconds) | |||||
String cmd = f.ReadString(); | String cmd = f.ReadString(); | ||||
f.Close(); | f.Close(); | ||||
if (cmd.Count() | |||||
&& (!m_cmdlist.Count() || cmd != m_cmdlist.Last())) | |||||
if (cmd.count() | |||||
&& (!m_cmdlist.count() || cmd != m_cmdlist.last())) | |||||
{ | { | ||||
m_cmdlist << cmd; | m_cmdlist << cmd; | ||||
MessageService::Send(MessageBucket::AppIn, cmd); | MessageService::Send(MessageBucket::AppIn, cmd); | ||||
@@ -947,7 +947,7 @@ void MeshViewer::Draw(float seconds, Scene &scene) | |||||
Renderer::Get()->SetClearColor(m_ssetup->m_clear_color); | Renderer::Get()->SetClearColor(m_ssetup->m_clear_color); | ||||
for (int i = 0; i < m_gizmos.Count(); ++i) | |||||
for (int i = 0; i < m_gizmos.count(); ++i) | |||||
{ | { | ||||
if (m_gizmos[i]->GetMeshState() == MeshRender::NeedConvert) | if (m_gizmos[i]->GetMeshState() == MeshRender::NeedConvert) | ||||
m_gizmos[i]->MeshConvert(); | m_gizmos[i]->MeshConvert(); | ||||
@@ -960,7 +960,7 @@ void MeshViewer::Draw(float seconds, Scene &scene) | |||||
if (m_build_time < .0f) | if (m_build_time < .0f) | ||||
{ | { | ||||
m_build_time = m_build_timer; | m_build_time = m_build_timer; | ||||
for (int i = 0; i < m_meshes.Count(); ++i) | |||||
for (int i = 0; i < m_meshes.count(); ++i) | |||||
{ | { | ||||
if (m_meshes[i].m1 && m_meshes[i].m1->BD()->Cmdi() < m_meshes[i].m1->BD()->CmdStack().GetCmdNb()) | if (m_meshes[i].m1 && m_meshes[i].m1->BD()->Cmdi() < m_meshes[i].m1->BD()->CmdStack().GetCmdNb()) | ||||
{ | { | ||||
@@ -1024,7 +1024,7 @@ void MeshViewer::Draw(float seconds, Scene &scene) | |||||
//Align right meshes | //Align right meshes | ||||
mat4 mat_align = mat4::translate(x - x * RATIO_HW); | mat4 mat_align = mat4::translate(x - x * RATIO_HW); | ||||
mat4 mat_gizmo = mat_obj_offset * mat_align * save_proj; | mat4 mat_gizmo = mat_obj_offset * mat_align * save_proj; | ||||
for (int i = 0; i < m_meshes.Count(); i++) | |||||
for (int i = 0; i < m_meshes.count(); i++) | |||||
{ | { | ||||
{ | { | ||||
if (m_meshes[i].m1->GetMeshState() == MeshRender::NeedConvert) | if (m_meshes[i].m1->GetMeshState() == MeshRender::NeedConvert) | ||||
@@ -1038,7 +1038,7 @@ void MeshViewer::Draw(float seconds, Scene &scene) | |||||
#endif //WITH_TEXTURE | #endif //WITH_TEXTURE | ||||
} | } | ||||
#if ALL_FEATURES | #if ALL_FEATURES | ||||
float j = -(float)(m_meshes.Count() - (i + 1)) + (-m_mesh_id1 + (float)(m_meshes.Count() - 1)); | |||||
float j = -(float)(m_meshes.count() - (i + 1)) + (-m_mesh_id1 + (float)(m_meshes.count() - 1)); | |||||
if (m_mesh_id1 - m_render_max[0] > (float)i && m_mesh_id1 - m_render_max[1] < (float)i && | if (m_mesh_id1 - m_render_max[0] > (float)i && m_mesh_id1 - m_render_max[1] < (float)i && | ||||
m_meshes[i].m1->GetMeshState() > MeshRender::NeedConvert) | m_meshes[i].m1->GetMeshState() > MeshRender::NeedConvert) | ||||
@@ -1074,7 +1074,7 @@ void MeshViewer::Draw(float seconds, Scene &scene) | |||||
if (m_ssetup->m_show_lights) | if (m_ssetup->m_show_lights) | ||||
{ | { | ||||
for (int k = 0; k < m_ssetup->m_lights.Count(); ++k) | |||||
for (int k = 0; k < m_ssetup->m_lights.count(); ++k) | |||||
{ | { | ||||
Light* ltmp = m_ssetup->m_lights[k]; | Light* ltmp = m_ssetup->m_lights[k]; | ||||
mat4 world = mat4::translate(ltmp->GetPosition()); | mat4 world = mat4::translate(ltmp->GetPosition()); | ||||
@@ -1096,9 +1096,9 @@ void MeshViewer::Draw(float seconds, Scene &scene) | |||||
#endif //NORMAL_USAGE | #endif //NORMAL_USAGE | ||||
#if 0 //Debug normal draw | #if 0 //Debug normal draw | ||||
for (int i = m_meshes.Count() - 1; 0 <= i && i < m_meshes.Count(); i++) | |||||
for (int i = m_meshes.count() - 1; 0 <= i && i < m_meshes.count(); i++) | |||||
{ | { | ||||
for (int j = 0; j < m_meshes[i].m1->m_indices.Count(); j += 3) | |||||
for (int j = 0; j < m_meshes[i].m1->m_indices.count(); j += 3) | |||||
{ | { | ||||
VertexData v[3] = { m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j ]], | VertexData v[3] = { m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j ]], | ||||
m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j+1]], | m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j+1]], | ||||
@@ -1108,7 +1108,7 @@ void MeshViewer::Draw(float seconds, Scene &scene) | |||||
Debug::DrawLine((m_mat * mat4::translate(v[k].m_coord))[3].xyz, | Debug::DrawLine((m_mat * mat4::translate(v[k].m_coord))[3].xyz, | ||||
(m_mat * mat4::translate(v[(k+1)%3].m_coord))[3].xyz, vec4(vec3((v[k].m_coord.z + 1.f)*.5f),1.f)); | (m_mat * mat4::translate(v[(k+1)%3].m_coord))[3].xyz, vec4(vec3((v[k].m_coord.z + 1.f)*.5f),1.f)); | ||||
} | } | ||||
for (int j = 0; j < m_meshes[i].m1->m_vert.Count(); j++) | |||||
for (int j = 0; j < m_meshes[i].m1->m_vert.count(); j++) | |||||
{ | { | ||||
VertexData &v = m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j]]; | VertexData &v = m_meshes[i].m1->m_vert[m_meshes[i].m1->m_indices[j]]; | ||||
Debug::DrawLine((m_mat * mat4::translate(v.m_coord))[3].xyz, | Debug::DrawLine((m_mat * mat4::translate(v.m_coord))[3].xyz, | ||||
@@ -38,7 +38,7 @@ SceneSetup::~SceneSetup() | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
bool SceneSetup::Startup() | bool SceneSetup::Startup() | ||||
{ | { | ||||
for (int i = 0; i < m_lights.Count(); i++) | |||||
for (int i = 0; i < m_lights.count(); i++) | |||||
Ticker::Ref(m_lights[i]); | Ticker::Ref(m_lights[i]); | ||||
return true; | return true; | ||||
} | } | ||||
@@ -46,12 +46,12 @@ bool SceneSetup::Startup() | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
bool SceneSetup::Shutdown(bool destroy) | bool SceneSetup::Shutdown(bool destroy) | ||||
{ | { | ||||
for (int i = 0; i < m_lights.Count(); i++) | |||||
for (int i = 0; i < m_lights.count(); i++) | |||||
if (m_lights[i]->IsTicked()) | if (m_lights[i]->IsTicked()) | ||||
Ticker::Unref(m_lights[i]); | Ticker::Unref(m_lights[i]); | ||||
if (destroy) | if (destroy) | ||||
m_lights.Empty(); | |||||
m_lights.empty(); | |||||
return true; | return true; | ||||
} | } | ||||
@@ -60,7 +60,7 @@ void SceneSetup::AddLight(LightType type) | |||||
{ | { | ||||
m_last_cmd = SceneSetup::Command::AddLight; | m_last_cmd = SceneSetup::Command::AddLight; | ||||
m_lights << new Light(); | m_lights << new Light(); | ||||
m_lights.Last()->SetType(type); | |||||
m_lights.last()->SetType(type); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -75,7 +75,7 @@ void SceneSetup::SetPosition(vec3 const& v) | |||||
switch (m_last_cmd.ToScalar()) | switch (m_last_cmd.ToScalar()) | ||||
{ | { | ||||
case SceneSetup::Command::AddLight: | case SceneSetup::Command::AddLight: | ||||
m_lights.Last()->SetPosition(v); | |||||
m_lights.last()->SetPosition(v); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -87,7 +87,7 @@ void SceneSetup::SetLookAt(vec3 const& v) | |||||
{ | { | ||||
case SceneSetup::Command::AddLight: | case SceneSetup::Command::AddLight: | ||||
//TODO: Do better | //TODO: Do better | ||||
m_lights.Last()->SetPosition(v - m_lights.Last()->GetPosition()); | |||||
m_lights.last()->SetPosition(v - m_lights.last()->GetPosition()); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -98,7 +98,7 @@ void SceneSetup::SetColor(vec4 const& c) | |||||
switch (m_last_cmd.ToScalar()) | switch (m_last_cmd.ToScalar()) | ||||
{ | { | ||||
case SceneSetup::Command::AddLight: | case SceneSetup::Command::AddLight: | ||||
m_lights.Last()->SetColor(c); | |||||
m_lights.last()->SetColor(c); | |||||
break; | break; | ||||
case SceneSetup::Command::SetupScene: | case SceneSetup::Command::SetupScene: | ||||
m_clear_color = c; | m_clear_color = c; | ||||
@@ -185,24 +185,24 @@ custom { return token::T_CUSTOMCMD; } | |||||
light_command: | light_command: | ||||
T_ADDLIGHT { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; } | T_ADDLIGHT { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; } | ||||
| T_ADDLIGHT fv { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; | | T_ADDLIGHT fv { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; | ||||
uc.m_sstp.m_lights.Last()->SetType(LightType($2)); } | |||||
uc.m_sstp.m_lights.last()->SetType(LightType($2)); } | |||||
| T_ADDLIGHT svv { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; | | T_ADDLIGHT svv { uc.m_sstp.m_lights << new Light(); uc.m_last_cmd = "ADDLIGHT"; | ||||
uc.m_sstp.m_lights.Last()->SetType(FindValue<LightType>($2)); } | |||||
uc.m_sstp.m_lights.last()->SetType(FindValue<LightType>($2)); } | |||||
; | ; | ||||
setup_command: | setup_command: | ||||
T_OBJPOSITION v3 { if (uc.m_last_cmd == "ADDLIGHT") | T_OBJPOSITION v3 { if (uc.m_last_cmd == "ADDLIGHT") | ||||
uc.m_sstp.m_lights.Last()->SetPosition(vec3($2[0], $2[1], $2[2])); } | |||||
uc.m_sstp.m_lights.last()->SetPosition(vec3($2[0], $2[1], $2[2])); } | |||||
| T_OBJLOOKAT v3 { if (uc.m_last_cmd == "ADDLIGHT") | | T_OBJLOOKAT v3 { if (uc.m_last_cmd == "ADDLIGHT") | ||||
{ | { | ||||
} } | } } | ||||
| T_OBJCOLOR v4{ if (uc.m_last_cmd == "ADDLIGHT") | | T_OBJCOLOR v4{ if (uc.m_last_cmd == "ADDLIGHT") | ||||
uc.m_sstp.m_lights.Last()->SetColor(vec4($2[0], $2[1], $2[2], $2[3])); } | |||||
uc.m_sstp.m_lights.last()->SetColor(vec4($2[0], $2[1], $2[2], $2[3])); } | |||||
| T_OBJCOLOR COLOR{ uint32_t x = $2; | | T_OBJCOLOR COLOR{ uint32_t x = $2; | ||||
ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); | ivec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); | ||||
vec4 vv = vec4(v) * (1.f / 255.f); | vec4 vv = vec4(v) * (1.f / 255.f); | ||||
if (uc.m_last_cmd == "ADDLIGHT") | if (uc.m_last_cmd == "ADDLIGHT") | ||||
uc.m_sstp.m_lights.Last()->SetColor(vv); } | |||||
uc.m_sstp.m_lights.last()->SetColor(vv); } | |||||
; | ; | ||||
scene_command: | scene_command: | ||||
@@ -215,7 +215,7 @@ uc.m_sstp.m_clear_color = vec4(v) * (1.f / 255.f); } | |||||
; | ; | ||||
custom_command: | custom_command: | ||||
T_CUSTOMCMD svv sv{ uc.m_sstp.m_custom_cmd.Push($2, $3); } | |||||
T_CUSTOMCMD svv sv{ uc.m_sstp.m_custom_cmd.push($2, $3); } | |||||
; | ; | ||||
*/ | */ | ||||
@@ -42,7 +42,7 @@ Nacl_PhysTest::Nacl_PhysTest(bool editor) | |||||
vec3(0.f, 0.f, 0.f), | vec3(0.f, 0.f, 0.f), | ||||
vec3(0, 1, 0)); | vec3(0, 1, 0)); | ||||
m_camera->SetProjection(45.f, .1f, 1000.f, (float)Video::GetSize().x, (float)Video::GetSize().y / (float)Video::GetSize().x); | m_camera->SetProjection(45.f, .1f, 1000.f, (float)Video::GetSize().x, (float)Video::GetSize().y / (float)Video::GetSize().x); | ||||
g_scene->PushCamera(m_camera); | |||||
Scene::GetScene().PushCamera(m_camera); | |||||
m_ready = false; | m_ready = false; | ||||
@@ -96,7 +96,8 @@ void Nacl_PhysTest::TickDraw(float seconds, Scene &scene) | |||||
Nacl_PhysTest::~Nacl_PhysTest() | Nacl_PhysTest::~Nacl_PhysTest() | ||||
{ | { | ||||
g_scene->PopCamera(m_camera); | |||||
Scene::GetScene().PopCamera(m_camera); | |||||
Ticker::Unref(m_light1); | Ticker::Unref(m_light1); | ||||
Ticker::Unref(m_light2); | Ticker::Unref(m_light2); | ||||
@@ -144,7 +144,7 @@ public: | |||||
MeshRand << "[sc#ada afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | MeshRand << "[sc#ada afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | ||||
MeshRand << "[sc#aad afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | MeshRand << "[sc#aad afcb1.7 1.7 1.7 0.4][sc#000 tsw afcb1.9 1.9 1.9 0.4 sx-1 sy-1 sz-1]"; | ||||
MeshLimit << MeshRand.Count(); | |||||
MeshLimit << MeshRand.count(); | |||||
MeshType << 0; | MeshType << 0; | ||||
#endif //USE_BOX | #endif //USE_BOX | ||||
@@ -173,7 +173,7 @@ public: | |||||
MeshRand << "[sc#aad asph1 2]"; | MeshRand << "[sc#aad asph1 2]"; | ||||
#endif | #endif | ||||
MeshLimit << (int)MeshRand.Count(); | |||||
MeshLimit << MeshRand.count(); | |||||
MeshType << 1; | MeshType << 1; | ||||
#endif //USE_SPHERE | #endif //USE_SPHERE | ||||
@@ -185,7 +185,7 @@ public: | |||||
MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | ||||
MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 ac8 2 2 0 0 0]"; | ||||
MeshLimit << MeshRand.Count(); | |||||
MeshLimit << MeshRand.count(); | |||||
MeshType << 2; | MeshType << 2; | ||||
#endif //USE_CONE | #endif //USE_CONE | ||||
@@ -197,7 +197,7 @@ public: | |||||
MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | MeshRand << "[sc#ada scb#ada ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | ||||
MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | MeshRand << "[sc#aad scb#aad ad8 2 0 rx180 ty-1 my ac8 2 2 2 0 0]"; | ||||
MeshLimit << MeshRand.Count(); | |||||
MeshLimit << MeshRand.count(); | |||||
MeshType << 3; | MeshType << 3; | ||||
#endif //USE_CYLINDER | #endif //USE_CYLINDER | ||||
@@ -209,13 +209,13 @@ public: | |||||
MeshRand << "[sc#ada scb#ada acap1 2 1]"; | MeshRand << "[sc#ada scb#ada acap1 2 1]"; | ||||
MeshRand << "[sc#aad scb#aad acap1 2 1]"; | MeshRand << "[sc#aad scb#aad acap1 2 1]"; | ||||
MeshLimit << MeshRand.Count(); | |||||
MeshLimit << MeshRand.count(); | |||||
MeshType << 4; | MeshType << 4; | ||||
#endif //USE_CAPSULE | #endif //USE_CAPSULE | ||||
int RandLimit = RandValue; | int RandLimit = RandValue; | ||||
if (MeshLimit.Count() <= RandValue || RandValue < 0) | |||||
RandLimit = rand((int)MeshLimit.Count() - 1); | |||||
if (MeshLimit.count() <= RandValue || RandValue < 0) | |||||
RandLimit = rand((int)MeshLimit.count() - 1); | |||||
RandValue = rand(MeshLimit[RandLimit], MeshLimit[RandLimit + 1]); | RandValue = rand(MeshLimit[RandLimit], MeshLimit[RandLimit + 1]); | ||||
m_physics = new EasyPhysic(this); | m_physics = new EasyPhysic(this); | ||||
@@ -145,12 +145,12 @@ void EasyPhysic::SetTransform(const lol::vec3& base_location, const lol::quat& b | |||||
m_motion_state = new btDefaultMotionState(btTransform(LOL2BT_QUAT(base_rotation), LOL2BT_VEC3(LOL2BT_UNIT * base_location))); | m_motion_state = new btDefaultMotionState(btTransform(LOL2BT_QUAT(base_rotation), LOL2BT_VEC3(LOL2BT_UNIT * base_location))); | ||||
} | } | ||||
for (int i = 0; i < m_based_physic_list.Count(); i++) | |||||
for (int i = 0; i < m_based_physic_list.count(); i++) | |||||
{ | { | ||||
if (m_based_physic_list[i]) | if (m_based_physic_list[i]) | ||||
m_based_physic_list[i]->BaseTransformChanged(PreviousMatrix, m_local_to_world); | m_based_physic_list[i]->BaseTransformChanged(PreviousMatrix, m_local_to_world); | ||||
else | else | ||||
m_based_physic_list.Remove(i--); | |||||
m_based_physic_list.remove(i--); | |||||
} | } | ||||
} | } | ||||
@@ -114,7 +114,7 @@ public: | |||||
if (NewBase) | if (NewBase) | ||||
{ | { | ||||
bool bAlreadyExists = false; | bool bAlreadyExists = false; | ||||
for (int i = 0; i < NewBase->m_based_physic_list.Count(); ++i) | |||||
for (int i = 0; i < NewBase->m_based_physic_list.count(); ++i) | |||||
if (NewBase->m_based_physic_list[i] == this) | if (NewBase->m_based_physic_list[i] == this) | ||||
bAlreadyExists = true; | bAlreadyExists = true; | ||||
if (!bAlreadyExists) | if (!bAlreadyExists) | ||||
@@ -125,9 +125,9 @@ public: | |||||
} | } | ||||
else if (m_base_physic) | else if (m_base_physic) | ||||
{ | { | ||||
for (int i = 0; i < m_base_physic->m_based_physic_list.Count(); ++i) | |||||
for (int i = 0; i < m_base_physic->m_based_physic_list.count(); ++i) | |||||
if (m_base_physic->m_based_physic_list[i] == this) | if (m_base_physic->m_based_physic_list[i] == this) | ||||
m_base_physic->m_based_physic_list.Remove(i--); | |||||
m_base_physic->m_based_physic_list.remove(i--); | |||||
m_base_physic = NULL; | m_base_physic = NULL; | ||||
} | } | ||||
} | } | ||||
@@ -42,10 +42,10 @@ struct RayCastResult | |||||
} | } | ||||
void Reset() | void Reset() | ||||
{ | { | ||||
m_collider_list.Empty(); | |||||
m_hit_normal_list.Empty(); | |||||
m_hit_point_list.Empty(); | |||||
m_hit_fraction_list.Empty(); | |||||
m_collider_list.empty(); | |||||
m_hit_normal_list.empty(); | |||||
m_hit_point_list.empty(); | |||||
m_hit_fraction_list.empty(); | |||||
} | } | ||||
array<EasyPhysic*> m_collider_list; | array<EasyPhysic*> m_collider_list; | ||||
@@ -376,14 +376,7 @@ private: | |||||
else | else | ||||
{ | { | ||||
NewEP->m_owner_simulation = NULL; | NewEP->m_owner_simulation = NULL; | ||||
for (int i = 0; i < SearchList->Count(); ++i) | |||||
{ | |||||
if ((*SearchList)[i] == NewEP) | |||||
{ | |||||
SearchList->Remove(i--); | |||||
break; | |||||
} | |||||
} | |||||
SearchList->remove_item(NewEP); | |||||
} | } | ||||
} | } | ||||
void ObjectRegistration(bool AddObject, EasyConstraint* NewEC) | void ObjectRegistration(bool AddObject, EasyConstraint* NewEC) | ||||
@@ -399,14 +392,7 @@ private: | |||||
else | else | ||||
{ | { | ||||
NewEC->m_owner_simulation = NULL; | NewEC->m_owner_simulation = NULL; | ||||
for (int i = 0; i < SearchList->Count(); ++i) | |||||
{ | |||||
if ((*SearchList)[i] == NewEC) | |||||
{ | |||||
SearchList->Remove(i--); | |||||
break; | |||||
} | |||||
} | |||||
SearchList->remove_item(NewEC); | |||||
} | } | ||||
} | } | ||||
@@ -41,9 +41,9 @@ public: | |||||
m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | ||||
m_vbo = new VertexBuffer(m_vertices.Bytes()); | |||||
m_vbo = new VertexBuffer(m_vertices.bytes()); | |||||
void *vertices = m_vbo->Lock(0, 0); | void *vertices = m_vbo->Lock(0, 0); | ||||
memcpy(vertices, &m_vertices[0], m_vertices.Bytes()); | |||||
memcpy(vertices, &m_vertices[0], m_vertices.bytes()); | |||||
m_vbo->Unlock(); | m_vbo->Unlock(); | ||||
m_ready = true; | m_ready = true; | ||||
@@ -74,19 +74,19 @@ public: | |||||
new VertexDeclaration(VertexStream<vec3,vec3>(VertexUsage::Position, | new VertexDeclaration(VertexStream<vec3,vec3>(VertexUsage::Position, | ||||
VertexUsage::Color)); | VertexUsage::Color)); | ||||
m_vbo = new VertexBuffer(m_mesh.Bytes()); | |||||
m_vbo = new VertexBuffer(m_mesh.bytes()); | |||||
void *mesh = m_vbo->Lock(0, 0); | void *mesh = m_vbo->Lock(0, 0); | ||||
memcpy(mesh, &m_mesh[0], m_mesh.Bytes()); | |||||
memcpy(mesh, &m_mesh[0], m_mesh.bytes()); | |||||
m_vbo->Unlock(); | m_vbo->Unlock(); | ||||
m_lines_ibo = new IndexBuffer(m_lines_indices.Bytes()); | |||||
m_lines_ibo = new IndexBuffer(m_lines_indices.bytes()); | |||||
void *indices = m_lines_ibo->Lock(0, 0); | void *indices = m_lines_ibo->Lock(0, 0); | ||||
memcpy(indices, &m_lines_indices[0], m_lines_indices.Bytes()); | |||||
memcpy(indices, &m_lines_indices[0], m_lines_indices.bytes()); | |||||
m_lines_ibo->Unlock(); | m_lines_ibo->Unlock(); | ||||
m_faces_ibo = new IndexBuffer(m_faces_indices.Bytes()); | |||||
m_faces_ibo = new IndexBuffer(m_faces_indices.bytes()); | |||||
indices = m_faces_ibo->Lock(0, 0); | indices = m_faces_ibo->Lock(0, 0); | ||||
memcpy(indices, &m_faces_indices[0], m_faces_indices.Bytes()); | |||||
memcpy(indices, &m_faces_indices[0], m_faces_indices.bytes()); | |||||
m_faces_ibo->Unlock(); | m_faces_ibo->Unlock(); | ||||
/* FIXME: this object never cleans up */ | /* FIXME: this object never cleans up */ | ||||
@@ -102,13 +102,13 @@ public: | |||||
m_shader->SetUniform(m_mvp, m_matrix); | m_shader->SetUniform(m_mvp, m_matrix); | ||||
m_lines_ibo->Bind(); | m_lines_ibo->Bind(); | ||||
m_vdecl->DrawIndexedElements(MeshPrimitive::Lines, 0, 0, | m_vdecl->DrawIndexedElements(MeshPrimitive::Lines, 0, 0, | ||||
(int)m_mesh.Count(), 0, (int)m_lines_indices.Count()); | |||||
m_mesh.count(), 0, m_lines_indices.count()); | |||||
m_lines_ibo->Unbind(); | m_lines_ibo->Unbind(); | ||||
m_shader->SetUniform(m_mvp, m_matrix * mat4::scale(0.5f)); | m_shader->SetUniform(m_mvp, m_matrix * mat4::scale(0.5f)); | ||||
m_faces_ibo->Bind(); | m_faces_ibo->Bind(); | ||||
m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, 0, 0, | m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, 0, 0, | ||||
(int)m_mesh.Count(), 0, (int)m_faces_indices.Count()); | |||||
m_mesh.count(), 0, m_faces_indices.count()); | |||||
m_faces_ibo->Unbind(); | m_faces_ibo->Unbind(); | ||||
m_vdecl->Unbind(); | m_vdecl->Unbind(); | ||||
@@ -48,9 +48,9 @@ public: | |||||
m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | ||||
m_vbo = new VertexBuffer(m_vertices.Bytes()); | |||||
m_vbo = new VertexBuffer(m_vertices.bytes()); | |||||
void *vertices = m_vbo->Lock(0, 0); | void *vertices = m_vbo->Lock(0, 0); | ||||
memcpy(vertices, &m_vertices[0], m_vertices.Bytes()); | |||||
memcpy(vertices, &m_vertices[0], m_vertices.bytes()); | |||||
m_vbo->Unlock(); | m_vbo->Unlock(); | ||||
m_ready = true; | m_ready = true; | ||||
@@ -34,7 +34,7 @@ public: | |||||
m_frames(0), | m_frames(0), | ||||
m_ready(false) | m_ready(false) | ||||
{ | { | ||||
m_heightmap.Resize(TEXTURE_WIDTH * 1); | |||||
m_heightmap.resize(TEXTURE_WIDTH * 1); | |||||
} | } | ||||
virtual void TickGame(float seconds) | virtual void TickGame(float seconds) | ||||
@@ -43,16 +43,16 @@ public: | |||||
/* Generate a new heightmap at the beginning */ | /* Generate a new heightmap at the beginning */ | ||||
if (m_frames == 0) | if (m_frames == 0) | ||||
memset(m_heightmap.Data(), 255, m_heightmap.Bytes()); | |||||
memset(m_heightmap.data(), 255, m_heightmap.bytes()); | |||||
/* Scroll left */ | /* Scroll left */ | ||||
for (int i = 0; i < m_heightmap.Count() - 1; i++) | |||||
for (int i = 0; i < m_heightmap.count() - 1; i++) | |||||
m_heightmap[i] = m_heightmap[i + 1]; | m_heightmap[i] = m_heightmap[i + 1]; | ||||
int height = m_heightmap.Last(); | |||||
int height = m_heightmap.last(); | |||||
height = (int)(height + 127 + 40 * lol::sin(m_frames * 0.03) + rand() % 97 - 38) / 2; | height = (int)(height + 127 + 40 * lol::sin(m_frames * 0.03) + rand() % 97 - 38) / 2; | ||||
height = std::max(15, std::min(height, 240)); | height = std::max(15, std::min(height, 240)); | ||||
m_heightmap.Last() = height; | |||||
m_heightmap.last() = height; | |||||
/* Update frame counter */ | /* Update frame counter */ | ||||
++m_frames; | ++m_frames; | ||||
@@ -73,9 +73,9 @@ public: | |||||
m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | ||||
m_vbo = new VertexBuffer(m_vertices.Bytes()); | |||||
m_vbo = new VertexBuffer(m_vertices.bytes()); | |||||
void *vertices = m_vbo->Lock(0, 0); | void *vertices = m_vbo->Lock(0, 0); | ||||
memcpy(vertices, &m_vertices[0], m_vertices.Bytes()); | |||||
memcpy(vertices, &m_vertices[0], m_vertices.bytes()); | |||||
m_vbo->Unlock(); | m_vbo->Unlock(); | ||||
m_ready = true; | m_ready = true; | ||||
@@ -84,7 +84,7 @@ public: | |||||
} | } | ||||
/* Send new heightmap to GPU */ | /* Send new heightmap to GPU */ | ||||
m_texture->SetData(m_heightmap.Data()); | |||||
m_texture->SetData(m_heightmap.data()); | |||||
m_shader->Bind(); | m_shader->Bind(); | ||||
m_shader->SetUniform(m_texture_uni, m_texture->GetTextureUniform(), 0); | m_shader->SetUniform(m_texture_uni, m_texture->GetTextureUniform(), 0); | ||||
@@ -36,11 +36,11 @@ public: | |||||
EasyMeshLuaObject* gears3 = EzMhLoader.GetPtr<EasyMeshLuaObject>("g3"); | EasyMeshLuaObject* gears3 = EzMhLoader.GetPtr<EasyMeshLuaObject>("g3"); | ||||
EasyMeshLuaObject* gears4 = EzMhLoader.GetPtr<EasyMeshLuaObject>("g4"); | EasyMeshLuaObject* gears4 = EzMhLoader.GetPtr<EasyMeshLuaObject>("g4"); | ||||
m_gears.Push(gears0->GetMesh(), mat4(1.0f), 0.0f); | |||||
m_gears.Push(gears1->GetMesh(), mat4(1.0f), 0.0f); | |||||
m_gears.Push(gears2->GetMesh(), mat4(1.0f), 180.0f / 18); | |||||
m_gears.Push(gears3->GetMesh(), mat4(1.0f), 180.0f / 18); | |||||
m_gears.Push(gears4->GetMesh(), mat4(1.0f), 180.0f / 18); | |||||
m_gears.push(gears0->GetMesh(), mat4(1.0f), 0.0f); | |||||
m_gears.push(gears1->GetMesh(), mat4(1.0f), 0.0f); | |||||
m_gears.push(gears2->GetMesh(), mat4(1.0f), 180.0f / 18); | |||||
m_gears.push(gears3->GetMesh(), mat4(1.0f), 180.0f / 18); | |||||
m_gears.push(gears4->GetMesh(), mat4(1.0f), 180.0f / 18); | |||||
/* | /* | ||||
m_gears[0].m1.Compile("[sc#00f ab 8 1 8 ty -.25]" | m_gears[0].m1.Compile("[sc#00f ab 8 1 8 ty -.25]" | ||||
@@ -129,7 +129,7 @@ public: | |||||
Renderer::Get()->SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f)); | Renderer::Get()->SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f)); | ||||
/* Upload vertex data to GPU */ | /* Upload vertex data to GPU */ | ||||
for (int i = 0; i < m_gears.Count(); i++) | |||||
for (int i = 0; i < m_gears.count(); i++) | |||||
m_gears[i].m1.MeshConvert(); | m_gears[i].m1.MeshConvert(); | ||||
#if USE_CUSTOM_SHADER | #if USE_CUSTOM_SHADER | ||||
@@ -137,14 +137,14 @@ public: | |||||
Shader *custom_shader = Shader::Create(LOLFX_RESOURCE_NAME(shiny)); | Shader *custom_shader = Shader::Create(LOLFX_RESOURCE_NAME(shiny)); | ||||
// any other shader stuf here (Get uniform, mostly, and set texture) | // any other shader stuf here (Get uniform, mostly, and set texture) | ||||
for (int i = 0; i < m_gears.Count(); i++) | |||||
for (int i = 0; i < m_gears.count(); i++) | |||||
m_gears[i].m1.SetMaterial(custom_shader); | m_gears[i].m1.SetMaterial(custom_shader); | ||||
#endif | #endif | ||||
m_ready = true; | m_ready = true; | ||||
} | } | ||||
for (int i = 0; i < m_gears.Count(); i++) | |||||
for (int i = 0; i < m_gears.count(); i++) | |||||
{ | { | ||||
m_gears[i].m1.Render(scene, m_mat * m_gears[i].m2); | m_gears[i].m1.Render(scene, m_mat * m_gears[i].m2); | ||||
} | } | ||||
@@ -35,7 +35,7 @@ public: | |||||
for (int i = 0; i < SPRITE_COUNT; ++i) | for (int i = 0; i < SPRITE_COUNT; ++i) | ||||
{ | { | ||||
m_sprites.Push(vec3((float)rand(-96, 640), (float)rand(-96, 480), 0.f), | |||||
m_sprites.push(vec3((float)rand(-96, 640), (float)rand(-96, 480), 0.f), | |||||
rand(0.f, 1.f)); | rand(0.f, 1.f)); | ||||
} | } | ||||
@@ -67,15 +67,15 @@ public: | |||||
m_autorot = true; | m_autorot = true; | ||||
/* Front vertices/colors */ | /* Front vertices/colors */ | ||||
m_mesh.Push(vec3(-1.0, -1.0, 1.0), vec3(1.0, 0.0, 1.0)); | |||||
m_mesh.Push(vec3( 1.0, -1.0, 1.0), vec3(0.0, 1.0, 0.0)); | |||||
m_mesh.Push(vec3( 1.0, 1.0, 1.0), vec3(1.0, 0.5, 0.0)); | |||||
m_mesh.Push(vec3(-1.0, 1.0, 1.0), vec3(1.0, 1.0, 0.0)); | |||||
m_mesh.push(vec3(-1.0, -1.0, 1.0), vec3(1.0, 0.0, 1.0)); | |||||
m_mesh.push(vec3( 1.0, -1.0, 1.0), vec3(0.0, 1.0, 0.0)); | |||||
m_mesh.push(vec3( 1.0, 1.0, 1.0), vec3(1.0, 0.5, 0.0)); | |||||
m_mesh.push(vec3(-1.0, 1.0, 1.0), vec3(1.0, 1.0, 0.0)); | |||||
/* Back */ | /* Back */ | ||||
m_mesh.Push(vec3(-1.0, -1.0, -1.0), vec3(1.0, 0.0, 0.0)); | |||||
m_mesh.Push(vec3( 1.0, -1.0, -1.0), vec3(0.0, 0.5, 0.0)); | |||||
m_mesh.Push(vec3( 1.0, 1.0, -1.0), vec3(0.0, 0.5, 1.0)); | |||||
m_mesh.Push(vec3(-1.0, 1.0, -1.0), vec3(0.0, 0.0, 1.0)); | |||||
m_mesh.push(vec3(-1.0, -1.0, -1.0), vec3(1.0, 0.0, 0.0)); | |||||
m_mesh.push(vec3( 1.0, -1.0, -1.0), vec3(0.0, 0.5, 0.0)); | |||||
m_mesh.push(vec3( 1.0, 1.0, -1.0), vec3(0.0, 0.5, 1.0)); | |||||
m_mesh.push(vec3(-1.0, 1.0, -1.0), vec3(0.0, 0.0, 1.0)); | |||||
m_faces_indices << 0 << 1 << 2 << 2 << 3 << 0; | m_faces_indices << 0 << 1 << 2 << 2 << 3 << 0; | ||||
m_faces_indices << 1 << 5 << 6 << 6 << 2 << 1; | m_faces_indices << 1 << 5 << 6 << 6 << 2 << 1; | ||||
@@ -136,7 +136,7 @@ public: | |||||
m_yaw_angle += seconds * 20; | m_yaw_angle += seconds * 20; | ||||
} | } | ||||
m_text->SetText(String::Printf( | |||||
m_text->SetText(String::format( | |||||
"cursor: (%0.3f, %0.3f) - pixel (%d, %d)", | "cursor: (%0.3f, %0.3f) - pixel (%d, %d)", | ||||
m_mouse->GetCursor(0).x, m_mouse->GetCursor(0).y, | m_mouse->GetCursor(0).x, m_mouse->GetCursor(0).y, | ||||
m_mouse->GetCursorPixel(0).x, m_mouse->GetCursorPixel(0).y)); | m_mouse->GetCursorPixel(0).x, m_mouse->GetCursorPixel(0).y)); | ||||
@@ -170,19 +170,19 @@ public: | |||||
new VertexDeclaration(VertexStream<vec3,vec3>(VertexUsage::Position, | new VertexDeclaration(VertexStream<vec3,vec3>(VertexUsage::Position, | ||||
VertexUsage::Color)); | VertexUsage::Color)); | ||||
m_vbo = new VertexBuffer(m_mesh.Bytes()); | |||||
m_vbo = new VertexBuffer(m_mesh.bytes()); | |||||
void *mesh = m_vbo->Lock(0, 0); | void *mesh = m_vbo->Lock(0, 0); | ||||
memcpy(mesh, &m_mesh[0], m_mesh.Bytes()); | |||||
memcpy(mesh, &m_mesh[0], m_mesh.bytes()); | |||||
m_vbo->Unlock(); | m_vbo->Unlock(); | ||||
m_lines_ibo = new IndexBuffer(m_lines_indices.Bytes()); | |||||
m_lines_ibo = new IndexBuffer(m_lines_indices.bytes()); | |||||
void *indices = m_lines_ibo->Lock(0, 0); | void *indices = m_lines_ibo->Lock(0, 0); | ||||
memcpy(indices, &m_lines_indices[0], m_lines_indices.Bytes()); | |||||
memcpy(indices, &m_lines_indices[0], m_lines_indices.bytes()); | |||||
m_lines_ibo->Unlock(); | m_lines_ibo->Unlock(); | ||||
m_faces_ibo = new IndexBuffer(m_faces_indices.Bytes()); | |||||
m_faces_ibo = new IndexBuffer(m_faces_indices.bytes()); | |||||
indices = m_faces_ibo->Lock(0, 0); | indices = m_faces_ibo->Lock(0, 0); | ||||
memcpy(indices, &m_faces_indices[0], m_faces_indices.Bytes()); | |||||
memcpy(indices, &m_faces_indices[0], m_faces_indices.bytes()); | |||||
m_faces_ibo->Unlock(); | m_faces_ibo->Unlock(); | ||||
/* FIXME: this object never cleans up */ | /* FIXME: this object never cleans up */ | ||||
@@ -198,13 +198,13 @@ public: | |||||
m_shader->SetUniform(m_mvp, m_matrix); | m_shader->SetUniform(m_mvp, m_matrix); | ||||
m_lines_ibo->Bind(); | m_lines_ibo->Bind(); | ||||
m_vdecl->DrawIndexedElements(MeshPrimitive::Lines, 0, 0, | m_vdecl->DrawIndexedElements(MeshPrimitive::Lines, 0, 0, | ||||
(int)m_mesh.Count(), 0, (int)m_lines_indices.Count()); | |||||
m_mesh.count(), 0, m_lines_indices.count()); | |||||
m_lines_ibo->Unbind(); | m_lines_ibo->Unbind(); | ||||
m_shader->SetUniform(m_mvp, m_matrix * mat4::scale(0.5f)); | m_shader->SetUniform(m_mvp, m_matrix * mat4::scale(0.5f)); | ||||
m_faces_ibo->Bind(); | m_faces_ibo->Bind(); | ||||
m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, 0, 0, | m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, 0, 0, | ||||
(int)m_mesh.Count(), 0, (int)m_faces_indices.Count()); | |||||
m_mesh.count(), 0, m_faces_indices.count()); | |||||
m_faces_ibo->Unbind(); | m_faces_ibo->Unbind(); | ||||
m_vdecl->Unbind(); | m_vdecl->Unbind(); | ||||
@@ -66,9 +66,9 @@ public: | |||||
m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | ||||
m_vbo = new VertexBuffer(m_vertices.Bytes()); | |||||
m_vbo = new VertexBuffer(m_vertices.bytes()); | |||||
void *vertices = m_vbo->Lock(0, 0); | void *vertices = m_vbo->Lock(0, 0); | ||||
memcpy(vertices, &m_vertices[0], m_vertices.Bytes()); | |||||
memcpy(vertices, &m_vertices[0], m_vertices.bytes()); | |||||
m_vbo->Unlock(); | m_vbo->Unlock(); | ||||
m_fbo = new Framebuffer(Video::GetSize()); | m_fbo = new Framebuffer(Video::GetSize()); | ||||
@@ -54,7 +54,7 @@ public: | |||||
m_oldmouse = ivec2(0, 0); | m_oldmouse = ivec2(0, 0); | ||||
m_pixels.Resize(m_size.x * m_size.y); | |||||
m_pixels.resize(m_size.x * m_size.y); | |||||
m_frame = -1; | m_frame = -1; | ||||
m_slices = 4; | m_slices = 4; | ||||
for (int i = 0; i < 4; i++) | for (int i = 0; i < 4; i++) | ||||
@@ -97,11 +97,11 @@ public: | |||||
uint8_t green = (uint8_t)g * 256; | uint8_t green = (uint8_t)g * 256; | ||||
uint8_t blue = (uint8_t)b * 256; | uint8_t blue = (uint8_t)b * 256; | ||||
#if defined _XBOX | #if defined _XBOX | ||||
m_palette.Push(u8vec4(255, red, green, blue)); | |||||
m_palette.push(u8vec4(255, red, green, blue)); | |||||
#elif defined __native_client__ | #elif defined __native_client__ | ||||
m_palette.Push(u8vec4(red, green, blue, 255)); | |||||
m_palette.push(u8vec4(red, green, blue, 255)); | |||||
#else | #else | ||||
m_palette.Push(u8vec4(blue, green, red, 255)); | |||||
m_palette.push(u8vec4(blue, green, red, 255)); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -102,9 +102,9 @@ public: | |||||
{ | { | ||||
m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | ||||
m_vbo = new VertexBuffer(m_vertices.Bytes()); | |||||
m_vbo = new VertexBuffer(m_vertices.bytes()); | |||||
void *vertices = m_vbo->Lock(0, 0); | void *vertices = m_vbo->Lock(0, 0); | ||||
memcpy(vertices, &m_vertices[0], m_vertices.Bytes()); | |||||
memcpy(vertices, &m_vertices[0], m_vertices.bytes()); | |||||
m_vbo->Unlock(); | m_vbo->Unlock(); | ||||
m_screen_shader = Shader::Create(LOLFX_RESOURCE_NAME(12_texture_to_screen)); | m_screen_shader = Shader::Create(LOLFX_RESOURCE_NAME(12_texture_to_screen)); | ||||
@@ -113,7 +113,7 @@ public: | |||||
for (int i = 0; i < MaxFboType; ++i) | for (int i = 0; i < MaxFboType; ++i) | ||||
{ | { | ||||
m_fbos.Push(new Framebuffer(Video::GetSize()), 0, array<ShaderUniform>(), array<ShaderAttrib>() ); | |||||
m_fbos.push(new Framebuffer(Video::GetSize()), 0, array<ShaderUniform>(), array<ShaderAttrib>() ); | |||||
if (i == SrcVoronoiFbo) | if (i == SrcVoronoiFbo) | ||||
{ | { | ||||
@@ -140,14 +140,14 @@ public: | |||||
m_fbos[i].m2 = Shader::Create(LOLFX_RESOURCE_NAME(12_distance)); | m_fbos[i].m2 = Shader::Create(LOLFX_RESOURCE_NAME(12_distance)); | ||||
} | } | ||||
m_fbos.Last().m1->Bind(); | |||||
m_fbos.last().m1->Bind(); | |||||
{ | { | ||||
RenderContext rc; | RenderContext rc; | ||||
rc.SetClearColor(vec4(0.f, 0.f, 0.f, 1.f)); | rc.SetClearColor(vec4(0.f, 0.f, 0.f, 1.f)); | ||||
rc.SetClearDepth(1.f); | rc.SetClearDepth(1.f); | ||||
Renderer::Get()->Clear(ClearMask::Color | ClearMask::Depth); | Renderer::Get()->Clear(ClearMask::Color | ClearMask::Depth); | ||||
} | } | ||||
m_fbos.Last().m1->Unbind(); | |||||
m_fbos.last().m1->Unbind(); | |||||
} | } | ||||
temp_buffer = new Framebuffer(Video::GetSize()); | temp_buffer = new Framebuffer(Video::GetSize()); | ||||
@@ -170,9 +170,9 @@ public: | |||||
{ | { | ||||
//Shutdown logic | //Shutdown logic | ||||
if (m_controller->WasKeyReleasedThisFrame(KEY_POP)) | if (m_controller->WasKeyReleasedThisFrame(KEY_POP)) | ||||
voronoi_points.Pop(); | |||||
voronoi_points.pop(); | |||||
else if (m_controller->WasKeyReleasedThisFrame(KEY_PUSH)) | else if (m_controller->WasKeyReleasedThisFrame(KEY_PUSH)) | ||||
voronoi_points.Push(vec3(rand<float>(512.f), rand<float>(512.f), .0f), | |||||
voronoi_points.push(vec3(rand<float>(512.f), rand<float>(512.f), .0f), | |||||
vec2(64.f + rand<float>(64.f), 64.f + rand<float>(64.f))); | vec2(64.f + rand<float>(64.f), 64.f + rand<float>(64.f))); | ||||
else if (m_controller->WasKeyReleasedThisFrame(KEY_F1)) | else if (m_controller->WasKeyReleasedThisFrame(KEY_F1)) | ||||
m_cur_fbo = SrcVoronoiFbo; | m_cur_fbo = SrcVoronoiFbo; | ||||
@@ -180,12 +180,12 @@ public: | |||||
m_cur_fbo = VoronoiFbo; | m_cur_fbo = VoronoiFbo; | ||||
else if (m_controller->WasKeyReleasedThisFrame(KEY_F3)) | else if (m_controller->WasKeyReleasedThisFrame(KEY_F3)) | ||||
{ | { | ||||
voronoi_points.Empty(); | |||||
voronoi_points.empty(); | |||||
if (mode == 0) | if (mode == 0) | ||||
{ | { | ||||
int i = 4; | int i = 4; | ||||
while (i-- > 0) | while (i-- > 0) | ||||
voronoi_points.Push(vec3(rand<float>(512.f), rand<float>(512.f), .0f), | |||||
voronoi_points.push(vec3(rand<float>(512.f), rand<float>(512.f), .0f), | |||||
vec2(64.f + rand<float>(64.f), 64.f + rand<float>(64.f)) | vec2(64.f + rand<float>(64.f), 64.f + rand<float>(64.f)) | ||||
//vec2::zero | //vec2::zero | ||||
); | ); | ||||
@@ -200,19 +200,19 @@ public: | |||||
if (mode == 0) | if (mode == 0) | ||||
{ | { | ||||
voronoi_points.Empty(); | |||||
voronoi_points.empty(); | |||||
int maxi = 6; | int maxi = 6; | ||||
for (int i = 0; i < maxi; ++i) | for (int i = 0; i < maxi; ++i) | ||||
{ | { | ||||
float mi = (float)maxi; | float mi = (float)maxi; | ||||
float j = (float)i; | float j = (float)i; | ||||
float f_time = (float)m_time; | float f_time = (float)m_time; | ||||
voronoi_points.Push(vec3(256.f) + 196.f * vec3(lol::cos( f_time + j * 2.f * F_PI / mi), lol::sin( f_time + j * 2.f * F_PI / mi), .0f), vec2(.0f)); | |||||
voronoi_points.Push(vec3(256.f) + 128.f * vec3(lol::cos(-f_time + j * 2.f * F_PI / mi), lol::sin(-f_time + j * 2.f * F_PI / mi), .0f), vec2(.0f)); | |||||
voronoi_points.Push(vec3(256.f) + 64.f * vec3(lol::cos( f_time + j * 2.f * F_PI / mi), lol::sin( f_time + j * 2.f * F_PI / mi), .0f), vec2(.0f)); | |||||
voronoi_points.Push(vec3(256.f) + 32.f * vec3(lol::cos(-f_time + j * 2.f * F_PI / mi), lol::sin(-f_time + j * 2.f * F_PI / mi), .0f), vec2(.0f)); | |||||
voronoi_points.push(vec3(256.f) + 196.f * vec3(lol::cos( f_time + j * 2.f * F_PI / mi), lol::sin( f_time + j * 2.f * F_PI / mi), .0f), vec2(.0f)); | |||||
voronoi_points.push(vec3(256.f) + 128.f * vec3(lol::cos(-f_time + j * 2.f * F_PI / mi), lol::sin(-f_time + j * 2.f * F_PI / mi), .0f), vec2(.0f)); | |||||
voronoi_points.push(vec3(256.f) + 64.f * vec3(lol::cos( f_time + j * 2.f * F_PI / mi), lol::sin( f_time + j * 2.f * F_PI / mi), .0f), vec2(.0f)); | |||||
voronoi_points.push(vec3(256.f) + 32.f * vec3(lol::cos(-f_time + j * 2.f * F_PI / mi), lol::sin(-f_time + j * 2.f * F_PI / mi), .0f), vec2(.0f)); | |||||
} | } | ||||
voronoi_points.Push(vec3(256.f), vec2(0.f)); | |||||
voronoi_points.push(vec3(256.f), vec2(0.f)); | |||||
} | } | ||||
temp_buffer->Bind(); | temp_buffer->Bind(); | ||||
@@ -227,7 +227,7 @@ public: | |||||
{ | { | ||||
vec2 limit(1.f, 511.f); | vec2 limit(1.f, 511.f); | ||||
//SRC SETUP | //SRC SETUP | ||||
for (int j = 0; j < voronoi_points.Count(); ++j) | |||||
for (int j = 0; j < voronoi_points.count(); ++j) | |||||
{ | { | ||||
voronoi_points[j].m1 = vec3(voronoi_points[j].m1.xy + voronoi_points[j].m2 * seconds, voronoi_points[j].m1.z); | voronoi_points[j].m1 = vec3(voronoi_points[j].m1.xy + voronoi_points[j].m2 * seconds, voronoi_points[j].m1.z); | ||||
if (voronoi_points[j].m1.x >= limit.y || voronoi_points[j].m1.x <= limit.x) | if (voronoi_points[j].m1.x >= limit.y || voronoi_points[j].m1.x <= limit.x) | ||||
@@ -240,7 +240,7 @@ public: | |||||
voronoi_points[j].m2.y *= -1.f; | voronoi_points[j].m2.y *= -1.f; | ||||
voronoi_points[j].m1.y = clamp(voronoi_points[j].m1.y, limit.x, limit.y); | voronoi_points[j].m1.y = clamp(voronoi_points[j].m1.y, limit.x, limit.y); | ||||
} | } | ||||
voronoi_points[j].m1.z = ((float)j + 1) / ((float)voronoi_points.Count()); | |||||
voronoi_points[j].m1.z = ((float)j + 1) / ((float)voronoi_points.count()); | |||||
} | } | ||||
int f = SrcVoronoiFbo; | int f = SrcVoronoiFbo; | ||||
@@ -254,8 +254,8 @@ public: | |||||
} | } | ||||
m_fbos[f].m1->Unbind(); | m_fbos[f].m1->Unbind(); | ||||
int buf = voronoi_points.Count() % 2; | |||||
for (int j = 0; j < voronoi_points.Count(); ++j) | |||||
int buf = voronoi_points.count() % 2; | |||||
for (int j = 0; j < voronoi_points.count(); ++j) | |||||
{ | { | ||||
Framebuffer *dst_buf; | Framebuffer *dst_buf; | ||||
Framebuffer *src_buf; | Framebuffer *src_buf; | ||||
@@ -281,7 +281,7 @@ public: | |||||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], voronoi_points[j].m1); //"in_source_point" | m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], voronoi_points[j].m1); //"in_source_point" | ||||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], vec2(512.f, 512.f)); //"in_screen_res" | m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], vec2(512.f, 512.f)); //"in_screen_res" | ||||
m_vdecl->SetStream(m_vbo, m_fbos[f].m4.Last()); | |||||
m_vdecl->SetStream(m_vbo, m_fbos[f].m4.last()); | |||||
m_vdecl->Bind(); | m_vdecl->Bind(); | ||||
m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | ||||
m_vdecl->Unbind(); | m_vdecl->Unbind(); | ||||
@@ -345,7 +345,7 @@ public: | |||||
* This code snippet should be moved inside the Framebuffer class. */ | * This code snippet should be moved inside the Framebuffer class. */ | ||||
//m_fbos[m_cur_fbo].m2->SetUniform(m_uni_flag, 1.f); | //m_fbos[m_cur_fbo].m2->SetUniform(m_uni_flag, 1.f); | ||||
//m_fbos[m_cur_fbo].m2->SetUniform(m_uni_texture, m_fbo->GetTextureUniform(), 0); | //m_fbos[m_cur_fbo].m2->SetUniform(m_uni_texture, m_fbo->GetTextureUniform(), 0); | ||||
//m_vdecl->SetStream(m_vbo, m_fbos[m_cur_fbo].m4.Last()); | |||||
//m_vdecl->SetStream(m_vbo, m_fbos[m_cur_fbo].m4.last()); | |||||
//m_vdecl->Bind(); | //m_vdecl->Bind(); | ||||
//m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | //m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | ||||
//m_vdecl->Unbind(); | //m_vdecl->Unbind(); | ||||
@@ -361,7 +361,7 @@ public: | |||||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], vec2(512.f, 512.f)); //"in_screen_res" | shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], vec2(512.f, 512.f)); //"in_screen_res" | ||||
} | } | ||||
m_vdecl->SetStream(m_vbo, m_fbos[m_cur_fbo].m4.Last()); | |||||
m_vdecl->SetStream(m_vbo, m_fbos[m_cur_fbo].m4.last()); | |||||
m_vdecl->Bind(); | m_vdecl->Bind(); | ||||
m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | ||||
m_vdecl->Unbind(); | m_vdecl->Unbind(); | ||||
@@ -18,6 +18,8 @@ | |||||
using namespace lol; | using namespace lol; | ||||
#define Line(x) ((x) + "\n") | |||||
class ShaderBuilderDemo : public WorldEntity | class ShaderBuilderDemo : public WorldEntity | ||||
{ | { | ||||
public: | public: | ||||
@@ -78,7 +78,7 @@ void Log::Helper(MessageType type, char const *fmt, va_list ap) | |||||
ANDROID_LOG_ERROR | ANDROID_LOG_ERROR | ||||
}; | }; | ||||
String buf = String::VPrintf(fmt, ap); | |||||
String buf = String::vformat(fmt, ap); | |||||
__android_log_print(prio[type], "LOL", "[%d] %s", (int)gettid(), &buf[0]); | __android_log_print(prio[type], "LOL", "[%d] %s", (int)gettid(), &buf[0]); | ||||
#else | #else | ||||
@@ -91,12 +91,12 @@ void Log::Helper(MessageType type, char const *fmt, va_list ap) | |||||
}; | }; | ||||
# if defined _WIN32 | # if defined _WIN32 | ||||
String buf = String(prefix[type]) + ": " + String::VPrintf(fmt, ap); | |||||
String buf = String(prefix[type]) + ": " + String::vformat(fmt, ap); | |||||
array<WCHAR> widechar; | array<WCHAR> widechar; | ||||
widechar.Resize(buf.Count() + 1); | |||||
MultiByteToWideChar(CP_UTF8, 0, buf.C(), (int)buf.Count() + 1, widechar.Data(), (int)widechar.Count()); | |||||
OutputDebugStringW(widechar.Data()); | |||||
widechar.Resize(buf.count() + 1); | |||||
MultiByteToWideChar(CP_UTF8, 0, buf.C(), buf.count() + 1, widechar.data(), widechar.count()); | |||||
OutputDebugStringW(widechar.data()); | |||||
# else | # else | ||||
fprintf(stderr, "%s: ", prefix[type]); | fprintf(stderr, "%s: ", prefix[type]); | ||||
vfprintf(stderr, fmt, ap); | vfprintf(stderr, fmt, ap); | ||||
@@ -24,19 +24,19 @@ | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
String String::Printf(char const *format, ...) | |||||
String String::format(char const *format, ...) | |||||
{ | { | ||||
String ret; | String ret; | ||||
va_list ap; | va_list ap; | ||||
va_start(ap, format); | va_start(ap, format); | ||||
ret = String::VPrintf(format, ap); | |||||
ret = String::vformat(format, ap); | |||||
va_end(ap); | va_end(ap); | ||||
return ret; | return ret; | ||||
} | } | ||||
String String::VPrintf(char const *format, va_list ap) | |||||
String String::vformat(char const *format, va_list ap) | |||||
{ | { | ||||
String ret; | String ret; | ||||
@@ -31,17 +31,17 @@ private: | |||||
public: | public: | ||||
//GET/SET exec | //GET/SET exec | ||||
ptrdiff_t GetCmdNb() { return m_commands.Count(); } | |||||
ptrdiff_t GetCmd(int i) | |||||
int GetCmdNb() { return m_commands.count(); } | |||||
int GetCmd(int i) | |||||
{ | { | ||||
ASSERT(0 <= i && i < m_commands.Count()); | |||||
ASSERT(0 <= i && i < m_commands.count()); | |||||
m_f_cur = m_commands[i].m2; | m_f_cur = m_commands[i].m2; | ||||
m_i_cur = m_commands[i].m3; | m_i_cur = m_commands[i].m3; | ||||
return m_commands[i].m1; | return m_commands[i].m1; | ||||
} | } | ||||
//cmd storage | //cmd storage | ||||
void AddCmd(int cmd) { m_commands.Push(cmd, (int)m_floats.Count(), (int)m_ints.Count()); } | |||||
void AddCmd(int cmd) { m_commands.push(cmd, m_floats.count(), m_ints.count()); } | |||||
//GETTER | //GETTER | ||||
inline float F() { return m_floats[m_f_cur++]; } | inline float F() { return m_floats[m_f_cur++]; } | ||||
@@ -68,7 +68,7 @@ int Dict::MakeSlot(char const *name) | |||||
/* If the entry is already registered, remember its ID. Look for an | /* If the entry is already registered, remember its ID. Look for an | ||||
* empty slot at the same time. */ | * empty slot at the same time. */ | ||||
for (slotid = 0; slotid < data->m_entities.Count(); slotid++) | |||||
for (slotid = 0; slotid < data->m_entities.count(); slotid++) | |||||
{ | { | ||||
Entity *e = data->m_entities[slotid]; | Entity *e = data->m_entities[slotid]; | ||||
if (!e) | if (!e) | ||||
@@ -95,12 +95,12 @@ int Dict::MakeSlot(char const *name) | |||||
} | } | ||||
/* If this is a new entry, create a new slot for it. */ | /* If this is a new entry, create a new slot for it. */ | ||||
if (slotid == data->m_entities.Count() || !data->m_entities[slotid]) | |||||
if (slotid == data->m_entities.count() || !data->m_entities[slotid]) | |||||
{ | { | ||||
if (slotid == data->m_entities.Count()) | |||||
if (slotid == data->m_entities.count()) | |||||
{ | { | ||||
empty = (int)data->m_entities.Count(); | |||||
data->m_entities.Push(nullptr); | |||||
empty = (int)data->m_entities.count(); | |||||
data->m_entities.push(nullptr); | |||||
} | } | ||||
data->m_entities[empty] = nullptr; | data->m_entities[empty] = nullptr; | ||||
@@ -126,7 +126,7 @@ void Dict::RemoveSlot(int slotid) | |||||
void Dict::RemoveSlot(Entity *entity) | void Dict::RemoveSlot(Entity *entity) | ||||
{ | { | ||||
for (int slotid = 0; slotid < data->m_entities.Count(); slotid++) | |||||
for (int slotid = 0; slotid < data->m_entities.count(); slotid++) | |||||
if (data->m_entities[slotid] == entity) | if (data->m_entities[slotid] == entity) | ||||
{ | { | ||||
RemoveSlot(slotid); | RemoveSlot(slotid); | ||||
@@ -20,17 +20,17 @@ int CsgBsp::AddLeaf(int leaf_type, vec3 origin, vec3 normal, int above_idx) | |||||
if (leaf_type > 2 && leaf_type < -1) | if (leaf_type > 2 && leaf_type < -1) | ||||
return -1; | return -1; | ||||
if ((m_tree.Count() == 0 && above_idx == -1) || | |||||
if ((m_tree.count() == 0 && above_idx == -1) || | |||||
(above_idx >= 0 && | (above_idx >= 0 && | ||||
above_idx < m_tree.Count() && | |||||
above_idx < m_tree.count() && | |||||
leaf_type > LEAF_CURRENT && | leaf_type > LEAF_CURRENT && | ||||
leaf_type < LEAF_ABOVE && | leaf_type < LEAF_ABOVE && | ||||
m_tree[above_idx].m_leaves[leaf_type] == -1)) | m_tree[above_idx].m_leaves[leaf_type] == -1)) | ||||
{ | { | ||||
if (m_tree.Count() != 0) | |||||
m_tree[above_idx].m_leaves[leaf_type] = (int32_t)m_tree.Count(); | |||||
m_tree.Push(CsgBspLeaf(origin, normal, above_idx)); | |||||
return (int)m_tree.Count() - 1; | |||||
if (m_tree.count() != 0) | |||||
m_tree[above_idx].m_leaves[leaf_type] = (int32_t)m_tree.count(); | |||||
m_tree.push(CsgBspLeaf(origin, normal, above_idx)); | |||||
return m_tree.count() - 1; | |||||
} | } | ||||
return -1; | return -1; | ||||
@@ -38,7 +38,7 @@ int CsgBsp::AddLeaf(int leaf_type, vec3 origin, vec3 normal, int above_idx) | |||||
int CsgBsp::TestPoint(int leaf_idx, vec3 point) | int CsgBsp::TestPoint(int leaf_idx, vec3 point) | ||||
{ | { | ||||
if (leaf_idx >= 0 && leaf_idx < m_tree.Count()) | |||||
if (leaf_idx >= 0 && leaf_idx < m_tree.count()) | |||||
{ | { | ||||
vec3 p2o = point - m_tree[leaf_idx].m_origin; | vec3 p2o = point - m_tree[leaf_idx].m_origin; | ||||
@@ -63,20 +63,20 @@ void CsgBsp::AddTriangleToTree(int const &tri_idx, vec3 const &tri_p0, vec3 cons | |||||
array< int, int, vec3, vec3, vec3, int > Leaf_to_add; | array< int, int, vec3, vec3, vec3, int > Leaf_to_add; | ||||
//Tree is empty, so this leaf is the first | //Tree is empty, so this leaf is the first | ||||
if (m_tree.Count() == 0) | |||||
if (m_tree.count() == 0) | |||||
{ | { | ||||
AddLeaf(LEAF_CURRENT, tri_p0, cross(normalize(tri_p1 - tri_p0), normalize(tri_p2 - tri_p1)), LEAF_CURRENT); | AddLeaf(LEAF_CURRENT, tri_p0, cross(normalize(tri_p1 - tri_p0), normalize(tri_p2 - tri_p1)), LEAF_CURRENT); | ||||
m_tree.Last().m_tri_list.Push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
m_tree.last().m_tri_list.push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
return; | return; | ||||
} | } | ||||
tri_to_process.Reserve(20); | |||||
tri_to_process.Push(0, tri_p0, tri_p1, tri_p2); | |||||
tri_to_process.reserve(20); | |||||
tri_to_process.push(0, tri_p0, tri_p1, tri_p2); | |||||
while (tri_to_process.Count()) | |||||
while (tri_to_process.count()) | |||||
{ | { | ||||
int leaf_idx = tri_to_process.Last().m1; | |||||
vec3 v[3] = { tri_to_process.Last().m2, tri_to_process.Last().m3, tri_to_process.Last().m4 }; | |||||
int leaf_idx = tri_to_process.last().m1; | |||||
vec3 v[3] = { tri_to_process.last().m2, tri_to_process.last().m3, tri_to_process.last().m4 }; | |||||
int res_nb[3] = { 0, 0, 0 }; | int res_nb[3] = { 0, 0, 0 }; | ||||
int res_side[3] = { -1, -1, -1 }; | int res_side[3] = { -1, -1, -1 }; | ||||
@@ -117,23 +117,23 @@ void CsgBsp::AddTriangleToTree(int const &tri_idx, vec3 const &tri_p0, vec3 cons | |||||
int v_idx1 = (isec_base == 1)?(0):(1); | int v_idx1 = (isec_base == 1)?(0):(1); | ||||
int leaf_type = res_side[(isec_base + 2) % 3]; | int leaf_type = res_side[(isec_base + 2) % 3]; | ||||
tri_to_process.Pop(); | |||||
tri_to_process.pop(); | |||||
#if 1 | #if 1 | ||||
if (m_tree[leaf_idx].m_leaves[leaf_type] == LEAF_CURRENT) | if (m_tree[leaf_idx].m_leaves[leaf_type] == LEAF_CURRENT) | ||||
Leaf_to_add.Push(leaf_type, leaf_idx, v[((isec_base + 2) % 3)], isec_v[v_idx1], isec_v[v_idx0], -1); | |||||
Leaf_to_add.push(leaf_type, leaf_idx, v[((isec_base + 2) % 3)], isec_v[v_idx1], isec_v[v_idx0], -1); | |||||
else | else | ||||
tri_to_process.Push(leaf_idx, v[((isec_base + 2) % 3)], isec_v[v_idx1], isec_v[v_idx0]); | |||||
tri_to_process.push(leaf_idx, v[((isec_base + 2) % 3)], isec_v[v_idx1], isec_v[v_idx0]); | |||||
if (m_tree[leaf_idx].m_leaves[1 - leaf_type] == LEAF_CURRENT) | if (m_tree[leaf_idx].m_leaves[1 - leaf_type] == LEAF_CURRENT) | ||||
{ | { | ||||
Leaf_to_add.Push(1 - leaf_type, leaf_idx, v[isec_base], v[((isec_base + 1) % 3)], isec_v[v_idx0], -1); | |||||
Leaf_to_add.Push(1 - leaf_type, leaf_idx, v[isec_base], isec_v[v_idx0], isec_v[v_idx1], (int)Leaf_to_add.Count() - 1); | |||||
Leaf_to_add.push(1 - leaf_type, leaf_idx, v[isec_base], v[((isec_base + 1) % 3)], isec_v[v_idx0], -1); | |||||
Leaf_to_add.push(1 - leaf_type, leaf_idx, v[isec_base], isec_v[v_idx0], isec_v[v_idx1], Leaf_to_add.count() - 1); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
tri_to_process.Push(m_tree[leaf_idx].m_leaves[1 - leaf_type], v[isec_base], v[((isec_base + 1) % 3)], isec_v[v_idx0]); | |||||
tri_to_process.Push(m_tree[leaf_idx].m_leaves[1 - leaf_type], v[isec_base], isec_v[v_idx0], isec_v[v_idx1]); | |||||
tri_to_process.push(m_tree[leaf_idx].m_leaves[1 - leaf_type], v[isec_base], v[((isec_base + 1) % 3)], isec_v[v_idx0]); | |||||
tri_to_process.push(m_tree[leaf_idx].m_leaves[1 - leaf_type], v[isec_base], isec_v[v_idx0], isec_v[v_idx1]); | |||||
} | } | ||||
#else | #else | ||||
vec3 new_v[9] = { v[((isec_base + 2) % 3)], isec_v[v_idx1], isec_v[v_idx0], | vec3 new_v[9] = { v[((isec_base + 2) % 3)], isec_v[v_idx1], isec_v[v_idx0], | ||||
@@ -158,7 +158,7 @@ void CsgBsp::AddTriangleToTree(int const &tri_idx, vec3 const &tri_p0, vec3 cons | |||||
if (skip_tri) | if (skip_tri) | ||||
continue; | continue; | ||||
tri_to_process.Push(0, new_v[k], new_v[k + 1], new_v[k + 2]); | |||||
tri_to_process.push(0, new_v[k], new_v[k + 1], new_v[k + 2]); | |||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
@@ -171,43 +171,43 @@ void CsgBsp::AddTriangleToTree(int const &tri_idx, vec3 const &tri_p0, vec3 cons | |||||
//No leaf exist, so add a new one | //No leaf exist, so add a new one | ||||
if (new_leaf == LEAF_CURRENT) | if (new_leaf == LEAF_CURRENT) | ||||
{ | { | ||||
tri_to_process.Pop(); | |||||
Leaf_to_add.Push(new_leaf_type, leaf_idx, v[0], v[1], v[2], -1); | |||||
tri_to_process.pop(); | |||||
Leaf_to_add.push(new_leaf_type, leaf_idx, v[0], v[1], v[2], -1); | |||||
} | } | ||||
else | else | ||||
tri_to_process.Last().m1 = new_leaf; | |||||
tri_to_process.last().m1 = new_leaf; | |||||
} | } | ||||
//All points are on the current leaf, add the tri_idx to the list of this leaf. | //All points are on the current leaf, add the tri_idx to the list of this leaf. | ||||
else | else | ||||
{ | { | ||||
tri_to_process.Pop(); | |||||
tri_to_process.pop(); | |||||
bool already_exist = false; | bool already_exist = false; | ||||
for (int i = 0; !already_exist && i < m_tree[leaf_idx].m_tri_list.Count(); i++) | |||||
for (int i = 0; !already_exist && i < m_tree[leaf_idx].m_tri_list.count(); i++) | |||||
already_exist = (m_tree[leaf_idx].m_tri_list[i].m1 == tri_idx); | already_exist = (m_tree[leaf_idx].m_tri_list[i].m1 == tri_idx); | ||||
if (!already_exist) | if (!already_exist) | ||||
m_tree[leaf_idx].m_tri_list.Push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
m_tree[leaf_idx].m_tri_list.push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
} | } | ||||
} | } | ||||
//Add all leaves to the tree. | //Add all leaves to the tree. | ||||
for (int i = 0; i < Leaf_to_add.Count(); i++) | |||||
for (int i = 0; i < Leaf_to_add.count(); i++) | |||||
{ | { | ||||
//If we had it to an already existing leaf. | //If we had it to an already existing leaf. | ||||
if (Leaf_to_add[i].m2 < m_tree.Count() && m_tree[Leaf_to_add[i].m2].m_leaves[Leaf_to_add[i].m1] == LEAF_CURRENT) | |||||
if (Leaf_to_add[i].m2 < m_tree.count() && m_tree[Leaf_to_add[i].m2].m_leaves[Leaf_to_add[i].m1] == LEAF_CURRENT) | |||||
{ | { | ||||
AddLeaf(Leaf_to_add[i].m1, tri_p0, cross(normalize(tri_p1 - tri_p0), normalize(tri_p2 - tri_p1)), Leaf_to_add[i].m2); | AddLeaf(Leaf_to_add[i].m1, tri_p0, cross(normalize(tri_p1 - tri_p0), normalize(tri_p2 - tri_p1)), Leaf_to_add[i].m2); | ||||
m_tree.Last().m_tri_list.Push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
m_tree.last().m_tri_list.push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
} | } | ||||
/* | /* | ||||
if (Leaf_to_add[i].m6 == -1) | if (Leaf_to_add[i].m6 == -1) | ||||
{ | { | ||||
AddLeaf(Leaf_to_add[i].m1, tri_p0, cross(normalize(tri_p1 - tri_p0), normalize(tri_p2 - tri_p1)), Leaf_to_add[i].m2); | AddLeaf(Leaf_to_add[i].m1, tri_p0, cross(normalize(tri_p1 - tri_p0), normalize(tri_p2 - tri_p1)), Leaf_to_add[i].m2); | ||||
m_tree.Last().m_tri_list.Push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
m_tree.last().m_tri_list.push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
} | } | ||||
else | else | ||||
m_tree[Leaf_to_add[i].m6].m_tri_list.Push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
m_tree[Leaf_to_add[i].m6].m_tri_list.push(tri_idx, tri_p0, tri_p1, tri_p2); | |||||
*/ | */ | ||||
} | } | ||||
} | } | ||||
@@ -228,27 +228,27 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
array< array< int >, int, int, int, int > tri_to_process; | array< array< int >, int, int, int, int > tri_to_process; | ||||
//Tree is empty, ABORT ! | //Tree is empty, ABORT ! | ||||
if (m_tree.Count() == 0) | |||||
if (m_tree.count() == 0) | |||||
return -1; | return -1; | ||||
//Let's push the source vertices in here. | //Let's push the source vertices in here. | ||||
vert_list.Push(tri_p0, -1, -1, .0f); | |||||
vert_list.Push(tri_p1, -1, -1, .0f); | |||||
vert_list.Push(tri_p2, -1, -1, .0f); | |||||
vert_list.push(tri_p0, -1, -1, .0f); | |||||
vert_list.push(tri_p1, -1, -1, .0f); | |||||
vert_list.push(tri_p2, -1, -1, .0f); | |||||
//Let's push the triangle in here. | //Let's push the triangle in here. | ||||
tri_to_process.Reserve(20); | |||||
tri_to_process.Push( array< int >(), 0, 1, 2, 0); | |||||
tri_to_process.Last().m1.Push(0); | |||||
tri_to_process.reserve(20); | |||||
tri_to_process.push( array< int >(), 0, 1, 2, 0); | |||||
tri_to_process.last().m1.push(0); | |||||
while (tri_to_process.Count()) | |||||
while (tri_to_process.count()) | |||||
{ | { | ||||
while (tri_to_process.Count()) | |||||
while (tri_to_process.count()) | |||||
{ | { | ||||
int leaf_idx = tri_to_process.Last().m1.Last(); | |||||
int t[3] = { tri_to_process.Last().m2, | |||||
tri_to_process.Last().m3, | |||||
tri_to_process.Last().m4 }; | |||||
int leaf_idx = tri_to_process.last().m1.last(); | |||||
int t[3] = { tri_to_process.last().m2, | |||||
tri_to_process.last().m3, | |||||
tri_to_process.last().m4 }; | |||||
vec3 v[3] = { vert_list[t[0]].m1, | vec3 v[3] = { vert_list[t[0]].m1, | ||||
vert_list[t[1]].m1, | vert_list[t[1]].m1, | ||||
vert_list[t[2]].m1 }; | vert_list[t[2]].m1 }; | ||||
@@ -277,7 +277,7 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
int isec_idx = 0; | int isec_idx = 0; | ||||
int i = 0; | int i = 0; | ||||
for (; i < m_tree[leaf_idx].m_tri_list.Count(); i++) | |||||
for (; i < m_tree[leaf_idx].m_tri_list.count(); i++) | |||||
{ | { | ||||
if (TestTriangleVsTriangle(v[0], v[1], v[2], | if (TestTriangleVsTriangle(v[0], v[1], v[2], | ||||
m_tree[leaf_idx].m_tri_list[i].m2, m_tree[leaf_idx].m_tri_list[i].m3, m_tree[leaf_idx].m_tri_list[i].m4, | m_tree[leaf_idx].m_tri_list[i].m2, m_tree[leaf_idx].m_tri_list[i].m3, m_tree[leaf_idx].m_tri_list[i].m4, | ||||
@@ -286,27 +286,27 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
} | } | ||||
//There was no triangle intersection, the complex case. | //There was no triangle intersection, the complex case. | ||||
if (i == m_tree[leaf_idx].m_tri_list.Count()) | |||||
if (i == m_tree[leaf_idx].m_tri_list.count()) | |||||
{ | { | ||||
if (m_tree[leaf_idx].m_leaves[LEAF_FRONT] == LEAF_CURRENT && | if (m_tree[leaf_idx].m_leaves[LEAF_FRONT] == LEAF_CURRENT && | ||||
m_tree[leaf_idx].m_leaves[LEAF_BACK] == LEAF_CURRENT && | m_tree[leaf_idx].m_leaves[LEAF_BACK] == LEAF_CURRENT && | ||||
tri_to_process.Last().m1.Count() == 1) | |||||
tri_to_process.last().m1.count() == 1) | |||||
{ | { | ||||
tri_list.Push(LEAF_CURRENT, tri_to_process.Last().m2, tri_to_process.Last().m3, tri_to_process.Last().m4); | |||||
tri_to_process.Pop(); | |||||
tri_list.push(LEAF_CURRENT, tri_to_process.last().m2, tri_to_process.last().m3, tri_to_process.last().m4); | |||||
tri_to_process.pop(); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
tri_to_process.Last().m1.Pop(); | |||||
tri_to_process.last().m1.pop(); | |||||
//Register the triangle as needing to intersect with Front & back leaves. | //Register the triangle as needing to intersect with Front & back leaves. | ||||
if (m_tree[leaf_idx].m_leaves[LEAF_FRONT] != LEAF_CURRENT) | if (m_tree[leaf_idx].m_leaves[LEAF_FRONT] != LEAF_CURRENT) | ||||
tri_to_process.Last().m1.Push(m_tree[leaf_idx].m_leaves[LEAF_FRONT]); | |||||
tri_to_process.last().m1.push(m_tree[leaf_idx].m_leaves[LEAF_FRONT]); | |||||
if (m_tree[leaf_idx].m_leaves[LEAF_BACK] != LEAF_CURRENT) | if (m_tree[leaf_idx].m_leaves[LEAF_BACK] != LEAF_CURRENT) | ||||
tri_to_process.Last().m1.Push(m_tree[leaf_idx].m_leaves[LEAF_BACK]); | |||||
tri_to_process.last().m1.push(m_tree[leaf_idx].m_leaves[LEAF_BACK]); | |||||
//Mark the triangle as needing point by point test | //Mark the triangle as needing point by point test | ||||
tri_to_process.Last().m5 = 1; | |||||
tri_to_process.last().m5 = 1; | |||||
} | } | ||||
} | } | ||||
//there was an intersection, so let's split the triangle. | //there was an intersection, so let's split the triangle. | ||||
@@ -339,11 +339,11 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
if (skip_point) | if (skip_point) | ||||
continue; | continue; | ||||
#endif | #endif | ||||
new_v_idx[k] = (int)vert_list.Count(); | |||||
new_v_idx[k] = vert_list.count(); | |||||
vec3 PmV0 = (isec_v[k] - vert_list[t[isec_i[k]]].m1); | vec3 PmV0 = (isec_v[k] - vert_list[t[isec_i[k]]].m1); | ||||
vec3 V1mV0 = (vert_list[t[(isec_i[k] + 1) % 3]].m1 - vert_list[t[isec_i[k]]].m1); | vec3 V1mV0 = (vert_list[t[(isec_i[k] + 1) % 3]].m1 - vert_list[t[isec_i[k]]].m1); | ||||
float alpha = length(PmV0) / length(V1mV0); | float alpha = length(PmV0) / length(V1mV0); | ||||
vert_list.Push(isec_v[k], | |||||
vert_list.push(isec_v[k], | |||||
t[isec_i[k]], t[(isec_i[k] + 1) % 3], | t[isec_i[k]], t[(isec_i[k] + 1) % 3], | ||||
//Alpha = length((Point_Loc - Src_V0) / (Src_V1 - Src_V0)); | //Alpha = length((Point_Loc - Src_V0) / (Src_V1 - Src_V0)); | ||||
alpha); | alpha); | ||||
@@ -353,31 +353,31 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
int v_idx1 = (isec_base == 1)?(0):(1); | int v_idx1 = (isec_base == 1)?(0):(1); | ||||
//Leaf_type is the type for the triangle that is alone on its side. | //Leaf_type is the type for the triangle that is alone on its side. | ||||
int leaf_type = res_side[(isec_base + 2) % 3]; | int leaf_type = res_side[(isec_base + 2) % 3]; | ||||
int tri_to_remove = (int)tri_to_process.Count() - 1; | |||||
int tri_to_remove = tri_to_process.count() - 1; | |||||
#if 0 | #if 0 | ||||
if (m_tree[leaf_idx].m_leaves[leaf_type] == LEAF_CURRENT && tri_to_process.Last().m1.Last() == 1) | |||||
tri_list.Push(leaf_type, | |||||
if (m_tree[leaf_idx].m_leaves[leaf_type] == LEAF_CURRENT && tri_to_process.last().m1.last() == 1) | |||||
tri_list.push(leaf_type, | |||||
t[(isec_base + 2) % 3], new_v_idx[v_idx1], new_v_idx[v_idx0]); | t[(isec_base + 2) % 3], new_v_idx[v_idx1], new_v_idx[v_idx0]); | ||||
else | else | ||||
{ | { | ||||
tri_to_process.Push(array< int >(), t[(isec_base + 2) % 3], new_v_idx[v_idx1], new_v_idx[v_idx0], 0); | |||||
tri_to_process.Last().m1.Push(0); | |||||
tri_to_process.push(array< int >(), t[(isec_base + 2) % 3], new_v_idx[v_idx1], new_v_idx[v_idx0], 0); | |||||
tri_to_process.last().m1.push(0); | |||||
} | } | ||||
if (m_tree[leaf_idx].m_leaves[1 - leaf_type] == LEAF_CURRENT && tri_to_process.Last().m1.Last() == 1) | |||||
if (m_tree[leaf_idx].m_leaves[1 - leaf_type] == LEAF_CURRENT && tri_to_process.last().m1.last() == 1) | |||||
{ | { | ||||
tri_list.Push((tri_to_process.Last().m5)?(LEAF_CURRENT):(1 - leaf_type), | |||||
tri_list.push((tri_to_process.last().m5)?(LEAF_CURRENT):(1 - leaf_type), | |||||
t[isec_base], new_v_idx[((isec_base + 1) % 3)], new_v_idx[v_idx0]); | t[isec_base], new_v_idx[((isec_base + 1) % 3)], new_v_idx[v_idx0]); | ||||
tri_list.Push((tri_to_process.Last().m5)?(LEAF_CURRENT):(1 - leaf_type), | |||||
tri_list.push((tri_to_process.last().m5)?(LEAF_CURRENT):(1 - leaf_type), | |||||
t[isec_base], new_v_idx[v_idx0], new_v_idx[v_idx1]); | t[isec_base], new_v_idx[v_idx0], new_v_idx[v_idx1]); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
tri_to_process.Push(array< int >(), t[isec_base], t[((isec_base + 1) % 3)], new_v_idx[v_idx0], 0); | |||||
tri_to_process.Last().m1.Push(0); | |||||
tri_to_process.Push(array< int >(), t[isec_base], new_v_idx[v_idx0], new_v_idx[v_idx1], 0); | |||||
tri_to_process.Last().m1.Push(0); | |||||
tri_to_process.push(array< int >(), t[isec_base], t[((isec_base + 1) % 3)], new_v_idx[v_idx0], 0); | |||||
tri_to_process.last().m1.push(0); | |||||
tri_to_process.push(array< int >(), t[isec_base], new_v_idx[v_idx0], new_v_idx[v_idx1], 0); | |||||
tri_to_process.last().m1.push(0); | |||||
} | } | ||||
#else | #else | ||||
int new_t[9] = { t[(isec_base + 2) % 3], new_v_idx[v_idx1], new_v_idx[v_idx0], | int new_t[9] = { t[(isec_base + 2) % 3], new_v_idx[v_idx1], new_v_idx[v_idx0], | ||||
@@ -407,25 +407,25 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
continue; | continue; | ||||
#endif | #endif | ||||
#if 0 //Send the newly created triangle back to the beginning | #if 0 //Send the newly created triangle back to the beginning | ||||
tri_to_process.Push(array< int >(), new_t[k], new_t[k + 1], new_t[k + 2], 0); | |||||
tri_to_process.Last().m1.Push(0); | |||||
tri_to_process.push(array< int >(), new_t[k], new_t[k + 1], new_t[k + 2], 0); | |||||
tri_to_process.last().m1.push(0); | |||||
#else //Inherit parent tree | #else //Inherit parent tree | ||||
if (m_tree[leaf_idx].m_leaves[new_side[k / 3]] == LEAF_CURRENT && tri_to_process[tri_to_remove].m1.Count() == 1) | |||||
tri_list.Push(new_side[k / 3], new_t[k], new_t[k + 1], new_t[k + 2]); | |||||
if (m_tree[leaf_idx].m_leaves[new_side[k / 3]] == LEAF_CURRENT && tri_to_process[tri_to_remove].m1.count() == 1) | |||||
tri_list.push(new_side[k / 3], new_t[k], new_t[k + 1], new_t[k + 2]); | |||||
else | else | ||||
{ | { | ||||
tri_to_process.Push(array< int >(), new_t[k], new_t[k + 1], new_t[k + 2], 0); | |||||
tri_to_process.Last().m1 = tri_to_process[tri_to_remove].m1; | |||||
tri_to_process.push(array< int >(), new_t[k], new_t[k + 1], new_t[k + 2], 0); | |||||
tri_to_process.last().m1 = tri_to_process[tri_to_remove].m1; | |||||
if (m_tree[leaf_idx].m_leaves[new_side[k / 3]] == LEAF_CURRENT) | if (m_tree[leaf_idx].m_leaves[new_side[k / 3]] == LEAF_CURRENT) | ||||
tri_to_process.Last().m1.Pop(); | |||||
tri_to_process.last().m1.pop(); | |||||
else | else | ||||
tri_to_process.Last().m1.Last() = m_tree[leaf_idx].m_leaves[new_side[k / 3]]; | |||||
tri_to_process.last().m1.last() = m_tree[leaf_idx].m_leaves[new_side[k / 3]]; | |||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
#endif | #endif | ||||
tri_to_process.Remove(tri_to_remove); | |||||
tri_to_process.remove(tri_to_remove); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -440,29 +440,29 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
if (new_leaf == LEAF_CURRENT) | if (new_leaf == LEAF_CURRENT) | ||||
{ | { | ||||
//We still need to test other leaves. | //We still need to test other leaves. | ||||
if (tri_to_process.Last().m1.Count() > 1) | |||||
tri_to_process.Last().m1.Pop(); | |||||
if (tri_to_process.last().m1.count() > 1) | |||||
tri_to_process.last().m1.pop(); | |||||
else | else | ||||
{ | { | ||||
tri_list.Push((tri_to_process.Last().m5)?(LEAF_CURRENT):(new_leaf_type), | |||||
tri_to_process.Last().m2, tri_to_process.Last().m3, tri_to_process.Last().m4); | |||||
tri_to_process.Pop(); | |||||
tri_list.push((tri_to_process.last().m5)?(LEAF_CURRENT):(new_leaf_type), | |||||
tri_to_process.last().m2, tri_to_process.last().m3, tri_to_process.last().m4); | |||||
tri_to_process.pop(); | |||||
} | } | ||||
} | } | ||||
else | else | ||||
tri_to_process.Last().m1.Last() = new_leaf; | |||||
tri_to_process.last().m1.last() = new_leaf; | |||||
} | } | ||||
//All points are on the current leaf, add the tri_idx to the list of this leaf. | //All points are on the current leaf, add the tri_idx to the list of this leaf. | ||||
else | else | ||||
{ | { | ||||
//TODO : Special case, handle coplanar cut. | //TODO : Special case, handle coplanar cut. | ||||
tri_list.Push(LEAF_CURRENT, tri_to_process.Last().m2, tri_to_process.Last().m3, tri_to_process.Last().m4); | |||||
tri_to_process.Pop(); | |||||
tri_list.push(LEAF_CURRENT, tri_to_process.last().m2, tri_to_process.last().m3, tri_to_process.last().m4); | |||||
tri_to_process.pop(); | |||||
} | } | ||||
} | } | ||||
//Now that we have all the split points, let's double-check the results | //Now that we have all the split points, let's double-check the results | ||||
for (int i = 0; i < tri_list.Count(); i++) | |||||
for (int i = 0; i < tri_list.count(); i++) | |||||
{ | { | ||||
#define TEST_MAX 4 | #define TEST_MAX 4 | ||||
int t[3] = { tri_list[i].m2, | int t[3] = { tri_list[i].m2, | ||||
@@ -512,9 +512,9 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
res_total = res_total; | res_total = res_total; | ||||
tri_list[i].m1 = LEAF_BACK; | tri_list[i].m1 = LEAF_BACK; | ||||
#if 0 | #if 0 | ||||
tri_to_process.Push( array< int >(), tri_list[i].m2, tri_list[i].m3, tri_list[i].m4, 0); | |||||
tri_to_process.Last().m1.Push(0); | |||||
tri_list.Remove(i--); | |||||
tri_to_process.push( array< int >(), tri_list[i].m2, tri_list[i].m3, tri_list[i].m4, 0); | |||||
tri_to_process.last().m1.push(0); | |||||
tri_list.remove(i--); | |||||
break; | break; | ||||
#endif | #endif | ||||
} | } | ||||
@@ -534,7 +534,7 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
} | } | ||||
} | } | ||||
if (tri_list.Count() == 1) | |||||
if (tri_list.count() == 1) | |||||
return 0; | return 0; | ||||
return 1; | return 1; | ||||
} | } | ||||
@@ -22,7 +22,7 @@ namespace lol | |||||
EasyMesh::EasyMesh() | EasyMesh::EasyMesh() | ||||
: m_build_data(nullptr) | : m_build_data(nullptr) | ||||
{ | { | ||||
m_cursors.Push(0, 0); | |||||
m_cursors.push(0, 0); | |||||
m_state = MeshRender::NeedData; | m_state = MeshRender::NeedData; | ||||
} | } | ||||
@@ -35,7 +35,7 @@ EasyMesh::EasyMesh(const EasyMesh& em) | |||||
m_build_data = nullptr; | m_build_data = nullptr; | ||||
if (em.m_build_data) | if (em.m_build_data) | ||||
m_build_data = new EasyMeshBuildData(*em.m_build_data); | m_build_data = new EasyMeshBuildData(*em.m_build_data); | ||||
if (m_indices.Count() && m_vert.Count() && m_cursors.Count()) | |||||
if (m_indices.count() && m_vert.count() && m_cursors.count()) | |||||
m_state = MeshRender::NeedConvert; | m_state = MeshRender::NeedConvert; | ||||
else | else | ||||
m_state = MeshRender::NeedData; | m_state = MeshRender::NeedData; | ||||
@@ -401,7 +401,7 @@ public: | |||||
//Convenience functions | //Convenience functions | ||||
public: | public: | ||||
ptrdiff_t GetVertexCount() { return m_vert.Count(); } | |||||
int GetVertexCount() { return m_vert.count(); } | |||||
vec3 const &GetVertexLocation(int i) { return m_vert[i].m_coord; } | vec3 const &GetVertexLocation(int i) { return m_vert[i].m_coord; } | ||||
//private: | //private: | ||||
@@ -20,7 +20,7 @@ namespace lol | |||||
int VertexDictionnary::FindVertexMaster(const int search_idx) | int VertexDictionnary::FindVertexMaster(const int search_idx) | ||||
{ | { | ||||
//Resolve current vertex idx in the dictionnary (if exist) | //Resolve current vertex idx in the dictionnary (if exist) | ||||
for (int j = 0; j < vertex_list.Count(); j++) | |||||
for (int j = 0; j < vertex_list.count(); j++) | |||||
if (vertex_list[j].m1 == search_idx) | if (vertex_list[j].m1 == search_idx) | ||||
return vertex_list[j].m3; | return vertex_list[j].m3; | ||||
return VDictType::DoesNotExist; | return VDictType::DoesNotExist; | ||||
@@ -40,11 +40,11 @@ bool VertexDictionnary::FindMatchingVertices(const int search_idx, array<int> &m | |||||
else | else | ||||
matching_ids << vertex_list[cur_mast].m1; | matching_ids << vertex_list[cur_mast].m1; | ||||
for (int j = 0; j < vertex_list.Count(); j++) | |||||
for (int j = 0; j < vertex_list.count(); j++) | |||||
if (vertex_list[j].m3 == cur_mast && vertex_list[j].m1 != search_idx) | if (vertex_list[j].m3 == cur_mast && vertex_list[j].m1 != search_idx) | ||||
matching_ids << vertex_list[j].m1; | matching_ids << vertex_list[j].m1; | ||||
return (matching_ids.Count() > 0); | |||||
return (matching_ids.count() > 0); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -54,7 +54,7 @@ bool VertexDictionnary::FindConnectedVertices(const int search_idx, const array< | |||||
array<int> connected_tri; | array<int> connected_tri; | ||||
FindConnectedTriangles(search_idx, tri_list, tri0, connected_tri, ignored_tri); | FindConnectedTriangles(search_idx, tri_list, tri0, connected_tri, ignored_tri); | ||||
for (int i = 0; i < connected_tri.Count(); i++) | |||||
for (int i = 0; i < connected_tri.count(); i++) | |||||
{ | { | ||||
for (int j = 0; j < 3; j++) | for (int j = 0; j < 3; j++) | ||||
{ | { | ||||
@@ -67,7 +67,7 @@ bool VertexDictionnary::FindConnectedVertices(const int search_idx, const array< | |||||
if (found_master != search_idx) | if (found_master != search_idx) | ||||
{ | { | ||||
bool already_exist = false; | bool already_exist = false; | ||||
for (int k = 0; !already_exist && k < connected_vert.Count(); k++) | |||||
for (int k = 0; !already_exist && k < connected_vert.count(); k++) | |||||
if (connected_vert[k] == found_master) | if (connected_vert[k] == found_master) | ||||
already_exist = true; | already_exist = true; | ||||
if (!already_exist) | if (!already_exist) | ||||
@@ -76,7 +76,7 @@ bool VertexDictionnary::FindConnectedVertices(const int search_idx, const array< | |||||
} | } | ||||
} | } | ||||
} | } | ||||
return (connected_vert.Count() > 0); | |||||
return (connected_vert.count() > 0); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
bool VertexDictionnary::FindConnectedTriangles(const int search_idx, const array<uint16_t> &tri_list, const int tri0, array<int> &connected_tri, array<int> const *ignored_tri) | bool VertexDictionnary::FindConnectedTriangles(const int search_idx, const array<uint16_t> &tri_list, const int tri0, array<int> &connected_tri, array<int> const *ignored_tri) | ||||
@@ -108,12 +108,12 @@ bool VertexDictionnary::FindConnectedTriangles(const ivec3 &search_idx, const ar | |||||
} | } | ||||
} | } | ||||
for (int i = tri0; i < tri_list.Count(); i += 3) | |||||
for (int i = tri0; i < tri_list.count(); i += 3) | |||||
{ | { | ||||
if (ignored_tri) | if (ignored_tri) | ||||
{ | { | ||||
bool should_pass = false; | bool should_pass = false; | ||||
for (int j = 0; !should_pass && j < ignored_tri->Count(); j++) | |||||
for (int j = 0; !should_pass && j < ignored_tri->count(); j++) | |||||
if ((*ignored_tri)[j] == i) | if ((*ignored_tri)[j] == i) | ||||
should_pass = true; | should_pass = true; | ||||
if (should_pass) | if (should_pass) | ||||
@@ -123,7 +123,7 @@ bool VertexDictionnary::FindConnectedTriangles(const ivec3 &search_idx, const ar | |||||
for (int j = 0; j < 3; j++) | for (int j = 0; j < 3; j++) | ||||
{ | { | ||||
bool validated = false; | bool validated = false; | ||||
for (int k = 0; !validated && k < vert_list[j].Count(); k++) | |||||
for (int k = 0; !validated && k < vert_list[j].count(); k++) | |||||
for (int l = 0; !validated && l < 3; l++) | for (int l = 0; !validated && l < 3; l++) | ||||
if (vert_list[j][k] == tri_list[i + l]) | if (vert_list[j][k] == tri_list[i + l]) | ||||
validated = true; | validated = true; | ||||
@@ -134,20 +134,20 @@ bool VertexDictionnary::FindConnectedTriangles(const ivec3 &search_idx, const ar | |||||
connected_tri << i; | connected_tri << i; | ||||
} | } | ||||
return (connected_tri.Count() > 0); | |||||
return (connected_tri.count() > 0); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
//Will update the given list with all the vertices on the same spot. | //Will update the given list with all the vertices on the same spot. | ||||
void VertexDictionnary::RegisterVertex(const int vert_id, const vec3 vert_coord) | void VertexDictionnary::RegisterVertex(const int vert_id, const vec3 vert_coord) | ||||
{ | { | ||||
for (int j = 0; j < vertex_list.Count(); j++) | |||||
for (int j = 0; j < vertex_list.count(); j++) | |||||
if (vertex_list[j].m1 == vert_id) | if (vertex_list[j].m1 == vert_id) | ||||
return; | return; | ||||
//First, build the vertex Dictionnary | //First, build the vertex Dictionnary | ||||
int i = 0; | int i = 0; | ||||
for (; i < master_list.Count(); i++) | |||||
for (; i < master_list.count(); i++) | |||||
{ | { | ||||
int cur_mast = master_list[i]; | int cur_mast = master_list[i]; | ||||
int cur_id = vertex_list[cur_mast].m1; | int cur_id = vertex_list[cur_mast].m1; | ||||
@@ -161,14 +161,14 @@ void VertexDictionnary::RegisterVertex(const int vert_id, const vec3 vert_coord) | |||||
{ | { | ||||
if (cur_type == VDictType::Alone) | if (cur_type == VDictType::Alone) | ||||
cur_type = VDictType::Master; | cur_type = VDictType::Master; | ||||
vertex_list.Push(vert_id, vert_coord, cur_mast); | |||||
vertex_list.push(vert_id, vert_coord, cur_mast); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
//We're here because we couldn't find any matching vertex | //We're here because we couldn't find any matching vertex | ||||
master_list.Push((int)vertex_list.Count()); | |||||
vertex_list.Push(vert_id, vert_coord, VDictType::Alone); | |||||
master_list.push(vertex_list.count()); | |||||
vertex_list.push(vert_id, vert_coord, VDictType::Alone); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -176,7 +176,7 @@ void VertexDictionnary::RegisterVertex(const int vert_id, const vec3 vert_coord) | |||||
void VertexDictionnary::RemoveVertex(const int vert_id) | void VertexDictionnary::RemoveVertex(const int vert_id) | ||||
{ | { | ||||
int j = 0; | int j = 0; | ||||
for (; j < vertex_list.Count(); j++) | |||||
for (; j < vertex_list.count(); j++) | |||||
if (vertex_list[j].m1 == vert_id) | if (vertex_list[j].m1 == vert_id) | ||||
break; | break; | ||||
@@ -184,7 +184,7 @@ void VertexDictionnary::RemoveVertex(const int vert_id) | |||||
{ | { | ||||
int jf = -1; | int jf = -1; | ||||
//change all the master ref in the list | //change all the master ref in the list | ||||
for (int i = 0; i < vertex_list.Count(); i++) | |||||
for (int i = 0; i < vertex_list.count(); i++) | |||||
{ | { | ||||
if (vertex_list[i].m3 == j) | if (vertex_list[i].m3 == j) | ||||
{ | { | ||||
@@ -198,8 +198,8 @@ void VertexDictionnary::RemoveVertex(const int vert_id) | |||||
} | } | ||||
} | } | ||||
} | } | ||||
vertex_list.Remove(j); | |||||
for (int i = 0; i < master_list.Count(); i++) | |||||
vertex_list.remove(j); | |||||
for (int i = 0; i < master_list.count(); i++) | |||||
if (master_list[j] == j) | if (master_list[j] == j) | ||||
break; | break; | ||||
} | } | ||||
@@ -310,8 +310,8 @@ public: | |||||
} | } | ||||
void SetTexCoordCustomBuild(MeshType mt, MeshFaceType face, vec2 BL, vec2 TR) | void SetTexCoordCustomBuild(MeshType mt, MeshFaceType face, vec2 BL, vec2 TR) | ||||
{ | { | ||||
if (face.ToScalar() >= m_texcoord_custom_build[mt.ToScalar()].Count()) | |||||
m_texcoord_custom_build[mt.ToScalar()].Resize(face.ToScalar() + 1); | |||||
if (face.ToScalar() >= m_texcoord_custom_build[mt.ToScalar()].count()) | |||||
m_texcoord_custom_build[mt.ToScalar()].resize(face.ToScalar() + 1); | |||||
m_texcoord_custom_build[mt.ToScalar()][face.ToScalar()].m1 = BL; | m_texcoord_custom_build[mt.ToScalar()][face.ToScalar()].m1 = BL; | ||||
m_texcoord_custom_build[mt.ToScalar()][face.ToScalar()].m2 = TR; | m_texcoord_custom_build[mt.ToScalar()][face.ToScalar()].m2 = TR; | ||||
m_texcoord_build_type[mt.ToScalar()] |= 1; | m_texcoord_build_type[mt.ToScalar()] |= 1; | ||||
@@ -323,7 +323,7 @@ public: | |||||
vec2 BL = vec2(0.f); | vec2 BL = vec2(0.f); | ||||
vec2 TR = vec2(0.f); | vec2 TR = vec2(0.f); | ||||
if (m_texcoord_build_type[mt.ToScalar()] & 1 | if (m_texcoord_build_type[mt.ToScalar()] & 1 | ||||
&& face.ToScalar() < m_texcoord_custom_build[mt.ToScalar()].Count()) | |||||
&& face.ToScalar() < m_texcoord_custom_build[mt.ToScalar()].count()) | |||||
{ | { | ||||
BL = m_texcoord_custom_build[mt.ToScalar()][face.ToScalar()].m1; | BL = m_texcoord_custom_build[mt.ToScalar()][face.ToScalar()].m1; | ||||
TR = m_texcoord_custom_build[mt.ToScalar()][face.ToScalar()].m2; | TR = m_texcoord_custom_build[mt.ToScalar()][face.ToScalar()].m2; | ||||
@@ -398,8 +398,8 @@ public: | |||||
} | } | ||||
void SetTexCoordCustomBuild2(MeshType mt, MeshFaceType face, vec2 BL, vec2 TR) | void SetTexCoordCustomBuild2(MeshType mt, MeshFaceType face, vec2 BL, vec2 TR) | ||||
{ | { | ||||
if (face.ToScalar() >= m_texcoord_custom_build2[mt.ToScalar()].Count()) | |||||
m_texcoord_custom_build2[mt.ToScalar()].Resize(face.ToScalar() + 1); | |||||
if (face.ToScalar() >= m_texcoord_custom_build2[mt.ToScalar()].count()) | |||||
m_texcoord_custom_build2[mt.ToScalar()].resize(face.ToScalar() + 1); | |||||
m_texcoord_custom_build2[mt.ToScalar()][face.ToScalar()].m1 = BL; | m_texcoord_custom_build2[mt.ToScalar()][face.ToScalar()].m1 = BL; | ||||
m_texcoord_custom_build2[mt.ToScalar()][face.ToScalar()].m2 = TR; | m_texcoord_custom_build2[mt.ToScalar()][face.ToScalar()].m2 = TR; | ||||
m_texcoord_build_type2[mt.ToScalar()] |= 1; | m_texcoord_build_type2[mt.ToScalar()] |= 1; | ||||
@@ -410,7 +410,7 @@ public: | |||||
vec2 BL = vec2(0.f); | vec2 BL = vec2(0.f); | ||||
vec2 TR = vec2(0.f); | vec2 TR = vec2(0.f); | ||||
if (m_texcoord_build_type2[mt.ToScalar()] & 1 | if (m_texcoord_build_type2[mt.ToScalar()] & 1 | ||||
&& face.ToScalar() < m_texcoord_custom_build2[mt.ToScalar()].Count()) | |||||
&& face.ToScalar() < m_texcoord_custom_build2[mt.ToScalar()].count()) | |||||
{ | { | ||||
BL = m_texcoord_custom_build2[mt.ToScalar()][face.ToScalar()].m1; | BL = m_texcoord_custom_build2[mt.ToScalar()][face.ToScalar()].m1; | ||||
TR = m_texcoord_custom_build2[mt.ToScalar()][face.ToScalar()].m2; | TR = m_texcoord_custom_build2[mt.ToScalar()][face.ToScalar()].m2; | ||||
@@ -529,8 +529,8 @@ public: | |||||
bool FindConnectedTriangles(const ivec3 &search_idx, const array<uint16_t> &tri_list, const int tri0, array<int> &connected_tri, array<int> const *ignored_tri = nullptr); | bool FindConnectedTriangles(const ivec3 &search_idx, const array<uint16_t> &tri_list, const int tri0, array<int> &connected_tri, array<int> const *ignored_tri = nullptr); | ||||
void RegisterVertex(int vert_id, vec3 vert_coord); | void RegisterVertex(int vert_id, vec3 vert_coord); | ||||
void RemoveVertex(int vert_id); | void RemoveVertex(int vert_id); | ||||
bool GetMasterList(array<int> &ret_master_list) { ret_master_list = master_list; return ret_master_list.Count() > 0; } | |||||
void Clear() { vertex_list.Empty(); } | |||||
bool GetMasterList(array<int> &ret_master_list) { ret_master_list = master_list; return ret_master_list.count() > 0; } | |||||
void Clear() { vertex_list.empty(); } | |||||
private: | private: | ||||
//<VertexId, VertexLocation, VertexMasterId> | //<VertexId, VertexLocation, VertexMasterId> | ||||
array<int, vec3, int> vertex_list; | array<int, vec3, int> vertex_list; | ||||
@@ -41,34 +41,34 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) | |||||
//keep a track of the intersection point on the triangle. <pos, side_id> | //keep a track of the intersection point on the triangle. <pos, side_id> | ||||
array< vec3, int > triangle_vertex; | array< vec3, int > triangle_vertex; | ||||
for (int k = 0; k < 10; k++) | for (int k = 0; k < 10; k++) | ||||
triangle_vertex.Push(vec3(.0f), 0); | |||||
triangle_vertex.push(vec3(.0f), 0); | |||||
//bsp infos | //bsp infos | ||||
CsgBsp mesh_bsp_0; | CsgBsp mesh_bsp_0; | ||||
CsgBsp mesh_bsp_1; | CsgBsp mesh_bsp_1; | ||||
if (m_cursors.Count() == 0) | |||||
if (m_cursors.count() == 0) | |||||
return; | return; | ||||
//BSP BUILD : We use the brace logic, csg should be used as : "[ exp .... [exp .... csg]]" | //BSP BUILD : We use the brace logic, csg should be used as : "[ exp .... [exp .... csg]]" | ||||
int cursor_start = (m_cursors.Count() < 2)?(0):(m_cursors[(m_cursors.Count() - 2)].m2); | |||||
int cursor_start = (m_cursors.count() < 2)?(0):(m_cursors[(m_cursors.count() - 2)].m2); | |||||
for (int mesh_id = 0; mesh_id < 2; mesh_id++) | for (int mesh_id = 0; mesh_id < 2; mesh_id++) | ||||
{ | { | ||||
ptrdiff_t start_point = (mesh_id == 0) ? (cursor_start) : (m_cursors.Last().m2); | |||||
ptrdiff_t end_point = (mesh_id == 0) ? (m_cursors.Last().m2) : (m_indices.Count()); | |||||
int start_point = (mesh_id == 0) ? (cursor_start) : (m_cursors.last().m2); | |||||
int end_point = (mesh_id == 0) ? (m_cursors.last().m2) : (m_indices.count()); | |||||
CsgBsp &mesh_bsp = (mesh_id == 0) ? (mesh_bsp_0) : (mesh_bsp_1); | CsgBsp &mesh_bsp = (mesh_id == 0) ? (mesh_bsp_0) : (mesh_bsp_1); | ||||
for (ptrdiff_t i = start_point; i < end_point; i += 3) | |||||
mesh_bsp.AddTriangleToTree((int)i, m_vert[m_indices[i]].m_coord, | |||||
for (int i = start_point; i < end_point; i += 3) | |||||
mesh_bsp.AddTriangleToTree(i, m_vert[m_indices[i]].m_coord, | |||||
m_vert[m_indices[i + 1]].m_coord, | m_vert[m_indices[i + 1]].m_coord, | ||||
m_vert[m_indices[i + 2]].m_coord); | m_vert[m_indices[i + 2]].m_coord); | ||||
} | } | ||||
//BSP Usage : let's crunch all triangles on the correct BSP | //BSP Usage : let's crunch all triangles on the correct BSP | ||||
ptrdiff_t indices_count = m_indices.Count(); | |||||
for (ptrdiff_t mesh_id = 0; mesh_id < 2; mesh_id++) | |||||
int indices_count = m_indices.count(); | |||||
for (int mesh_id = 0; mesh_id < 2; mesh_id++) | |||||
{ | { | ||||
ptrdiff_t start_point = (mesh_id == 0) ? (cursor_start) : (m_cursors.Last().m2); | |||||
ptrdiff_t end_point = (mesh_id == 0) ? (m_cursors.Last().m2) : (indices_count); | |||||
int start_point = (mesh_id == 0) ? (cursor_start) : (m_cursors.last().m2); | |||||
int end_point = (mesh_id == 0) ? (m_cursors.last().m2) : (indices_count); | |||||
CsgBsp &mesh_bsp = (mesh_id == 0) ? (mesh_bsp_1) : (mesh_bsp_0); | CsgBsp &mesh_bsp = (mesh_id == 0) ? (mesh_bsp_1) : (mesh_bsp_0); | ||||
array< vec3, int, int, float > vert_list; | array< vec3, int, int, float > vert_list; | ||||
array< int, int, int, int > tri_list; | array< int, int, int, int > tri_list; | ||||
@@ -76,26 +76,26 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) | |||||
vec4 c0(.0f); vec4 c1(.0f); | vec4 c0(.0f); vec4 c1(.0f); | ||||
//Reserve some memory | //Reserve some memory | ||||
vert_list.Reserve(3); | |||||
tri_list.Reserve(3); | |||||
vert_list.reserve(3); | |||||
tri_list.reserve(3); | |||||
for (ptrdiff_t i = start_point; i < end_point; i += 3) | |||||
for (int i = start_point; i < end_point; i += 3) | |||||
{ | { | ||||
int Result = mesh_bsp.TestTriangleToTree(m_vert[m_indices[i]].m_coord, | int Result = mesh_bsp.TestTriangleToTree(m_vert[m_indices[i]].m_coord, | ||||
m_vert[m_indices[i + 1]].m_coord, | m_vert[m_indices[i + 1]].m_coord, | ||||
m_vert[m_indices[i + 2]].m_coord, vert_list, tri_list); | m_vert[m_indices[i + 2]].m_coord, vert_list, tri_list); | ||||
ptrdiff_t tri_base_idx = m_indices.Count(); | |||||
int tri_base_idx = m_indices.count(); | |||||
//one split has been done, we need to had the new vertices & the new triangles. | //one split has been done, we need to had the new vertices & the new triangles. | ||||
if (Result == 1) | if (Result == 1) | ||||
{ | { | ||||
triangle_to_kill.Push((int)i); | |||||
triangle_to_kill.push(i); | |||||
#if 1 | #if 1 | ||||
ptrdiff_t base_idx = m_vert.Count(); | |||||
for (ptrdiff_t k = 3; k < vert_list.Count(); k++) | |||||
int base_idx = m_vert.count(); | |||||
for (int k = 3; k < vert_list.count(); k++) | |||||
{ | { | ||||
ptrdiff_t P0 = (vert_list[k].m2 < 3) ? (m_indices[i + vert_list[k].m2]) : (base_idx + vert_list[k].m2 - 3); | |||||
ptrdiff_t P1 = (vert_list[k].m3 < 3) ? (m_indices[i + vert_list[k].m3]) : (base_idx + vert_list[k].m3 - 3); | |||||
int P0 = (vert_list[k].m2 < 3) ? (m_indices[i + vert_list[k].m2]) : (base_idx + vert_list[k].m2 - 3); | |||||
int P1 = (vert_list[k].m3 < 3) ? (m_indices[i + vert_list[k].m3]) : (base_idx + vert_list[k].m3 - 3); | |||||
AddVertex(vert_list[k].m1); | AddVertex(vert_list[k].m1); | ||||
@@ -117,11 +117,11 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) | |||||
SetCurVertColor(vec4(.0f, 1.0f, 1.0f, 1.0f)); | SetCurVertColor(vec4(.0f, 1.0f, 1.0f, 1.0f)); | ||||
#endif | #endif | ||||
} | } | ||||
for (ptrdiff_t k = 0; k < tri_list.Count(); k++) | |||||
for (int k = 0; k < tri_list.count(); k++) | |||||
{ | { | ||||
int P0 = (int)(tri_list[k].m2 < 3) ? (m_indices[i + tri_list[k].m2]) : ((int)base_idx + (tri_list[k].m2 - 3)); | |||||
int P1 = (int)(tri_list[k].m3 < 3) ? (m_indices[i + tri_list[k].m3]) : ((int)base_idx + (tri_list[k].m3 - 3)); | |||||
int P2 = (int)(tri_list[k].m4 < 3) ? (m_indices[i + tri_list[k].m4]) : ((int)base_idx + (tri_list[k].m4 - 3)); | |||||
int P0 = (tri_list[k].m2 < 3) ? (m_indices[i + tri_list[k].m2]) : (base_idx + (tri_list[k].m2 - 3)); | |||||
int P1 = (tri_list[k].m3 < 3) ? (m_indices[i + tri_list[k].m3]) : (base_idx + (tri_list[k].m3 - 3)); | |||||
int P2 = (tri_list[k].m4 < 3) ? (m_indices[i + tri_list[k].m4]) : (base_idx + (tri_list[k].m4 - 3)); | |||||
AddTriangle(P0, P1, P2, 0); | AddTriangle(P0, P1, P2, 0); | ||||
} | } | ||||
#endif | #endif | ||||
@@ -130,9 +130,9 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) | |||||
//Main case | //Main case | ||||
if (Result >= 0) | if (Result >= 0) | ||||
{ | { | ||||
for (int k = 0; k < tri_list.Count(); k++) | |||||
for (int k = 0; k < tri_list.count(); k++) | |||||
{ | { | ||||
ptrdiff_t tri_idx = (ptrdiff_t)((tri_list.Count() == 1) ? (i) : ((int)tri_base_idx + k * 3)); | |||||
int tri_idx = (tri_list.count() == 1) ? (i) : (tri_base_idx + k * 3); | |||||
//Triangle Kill Test | //Triangle Kill Test | ||||
if (//csgu : CSGUnion() -> m0_Outside + m1_Outside | if (//csgu : CSGUnion() -> m0_Outside + m1_Outside | ||||
@@ -147,7 +147,7 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) | |||||
//csga : CSGAnd() -> m0_Inside + m1_Inside | //csga : CSGAnd() -> m0_Inside + m1_Inside | ||||
(csg_operation == CSGUsage::And && tri_list[k].m1 == LEAF_FRONT)) | (csg_operation == CSGUsage::And && tri_list[k].m1 == LEAF_FRONT)) | ||||
{ | { | ||||
triangle_to_kill.Push((int)tri_idx); | |||||
triangle_to_kill.push(tri_idx); | |||||
} | } | ||||
//Triangle Invert Test | //Triangle Invert Test | ||||
@@ -160,37 +160,37 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) | |||||
//TODO : This operation disconnect all triangle, in some cases, not a good thing. | //TODO : This operation disconnect all triangle, in some cases, not a good thing. | ||||
if (csg_operation == CSGUsage::Xor) | if (csg_operation == CSGUsage::Xor) | ||||
{ | { | ||||
for (ptrdiff_t l = 0; l < 3; l++) | |||||
for (int l = 0; l < 3; l++) | |||||
{ | { | ||||
AddDupVertex(m_indices[tri_idx + l]); | AddDupVertex(m_indices[tri_idx + l]); | ||||
m_indices[tri_idx + l] = (uint16_t)m_vert.Count() - 1; | |||||
m_indices[tri_idx + l] = (uint16_t)m_vert.count() - 1; | |||||
} | } | ||||
} | } | ||||
m_indices[tri_idx + 1] += m_indices[tri_idx + 2]; | m_indices[tri_idx + 1] += m_indices[tri_idx + 2]; | ||||
m_indices[tri_idx + 2] = m_indices[tri_idx + 1] - m_indices[tri_idx + 2]; | m_indices[tri_idx + 2] = m_indices[tri_idx + 1] - m_indices[tri_idx + 2]; | ||||
m_indices[tri_idx + 1] = m_indices[tri_idx + 1] - m_indices[tri_idx + 2]; | m_indices[tri_idx + 1] = m_indices[tri_idx + 1] - m_indices[tri_idx + 2]; | ||||
ComputeNormals((int)tri_idx, 3); | |||||
ComputeNormals(tri_idx, 3); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
vert_list.Empty(); | |||||
tri_list.Empty(); | |||||
vert_list.empty(); | |||||
tri_list.empty(); | |||||
} | } | ||||
} | } | ||||
for (int i = 0; i < m_vert.Count(); i++) | |||||
for (int i = 0; i < m_vert.count(); i++) | |||||
if (length(m_vert[i].m_normal) < 1.0f) | if (length(m_vert[i].m_normal) < 1.0f) | ||||
i = i; | i = i; | ||||
int dir = 1; | int dir = 1; | ||||
for (int i = 0; i >= 0 && i < triangle_to_kill.Count() - 1; i += dir) | |||||
for (int i = 0; i >= 0 && i < triangle_to_kill.count() - 1; i += dir) | |||||
{ | { | ||||
if (triangle_to_kill[i] < triangle_to_kill[i + 1] && dir < 0) | if (triangle_to_kill[i] < triangle_to_kill[i + 1] && dir < 0) | ||||
dir = 1; | dir = 1; | ||||
if (triangle_to_kill[i] == triangle_to_kill[i + 1]) | if (triangle_to_kill[i] == triangle_to_kill[i + 1]) | ||||
{ | { | ||||
triangle_to_kill.Remove(i); | |||||
triangle_to_kill.remove(i); | |||||
dir = -1; | dir = -1; | ||||
} | } | ||||
if (triangle_to_kill[i] > triangle_to_kill[i + 1]) | if (triangle_to_kill[i] > triangle_to_kill[i + 1]) | ||||
@@ -203,11 +203,11 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation) | |||||
if (i == 0 && dir == -1) | if (i == 0 && dir == -1) | ||||
dir = 1; | dir = 1; | ||||
} | } | ||||
for (ptrdiff_t i = triangle_to_kill.Count() - 1; i >= 0; i--) | |||||
m_indices.Remove(triangle_to_kill[i], 3); | |||||
for (int i = triangle_to_kill.count() - 1; i >= 0; i--) | |||||
m_indices.remove(triangle_to_kill[i], 3); | |||||
m_cursors.Last().m1 = (int)m_vert.Count(); | |||||
m_cursors.Last().m2 = (int)m_indices.Count(); | |||||
m_cursors.last().m1 = m_vert.count(); | |||||
m_cursors.last().m2 = m_indices.count(); | |||||
VerticesCleanup(); | VerticesCleanup(); | ||||
//DONE for the splitting ! | //DONE for the splitting ! | ||||
@@ -28,8 +28,8 @@ void EasyMesh::LoopStart(int loopnb) | |||||
else if (BD()->IsEnabled(MeshBuildOperation::CommandExecution)) | else if (BD()->IsEnabled(MeshBuildOperation::CommandExecution)) | ||||
{ | { | ||||
//Only register if we're not the current loop command | //Only register if we're not the current loop command | ||||
if (!BD()->LoopStack().Count() || BD()->LoopStack().Last().m1 != BD()->Cmdi()) | |||||
BD()->LoopStack().Push(BD()->Cmdi(), loopnb); | |||||
if (!BD()->LoopStack().count() || BD()->LoopStack().last().m1 != BD()->Cmdi()) | |||||
BD()->LoopStack().push(BD()->Cmdi(), loopnb); | |||||
} | } | ||||
} | } | ||||
@@ -45,13 +45,13 @@ void EasyMesh::LoopEnd() | |||||
else if (BD()->IsEnabled(MeshBuildOperation::CommandExecution)) | else if (BD()->IsEnabled(MeshBuildOperation::CommandExecution)) | ||||
{ | { | ||||
//Only register if we're not the current loop command | //Only register if we're not the current loop command | ||||
if (BD()->LoopStack().Count()) | |||||
if (BD()->LoopStack().count()) | |||||
{ | { | ||||
BD()->LoopStack().Last().m2--; | |||||
if (BD()->LoopStack().Last().m2 > 0) | |||||
BD()->Cmdi() = BD()->LoopStack().Last().m1 - 1; | |||||
BD()->LoopStack().last().m2--; | |||||
if (BD()->LoopStack().last().m2 > 0) | |||||
BD()->Cmdi() = BD()->LoopStack().last().m1 - 1; | |||||
else | else | ||||
BD()->LoopStack().Pop(); | |||||
BD()->LoopStack().pop(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -65,7 +65,7 @@ void EasyMesh::OpenBrace() | |||||
return; | return; | ||||
} | } | ||||
m_cursors.Push((int)m_vert.Count(), (int)m_indices.Count()); | |||||
m_cursors.push(m_vert.count(), m_indices.count()); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -77,7 +77,7 @@ void EasyMesh::CloseBrace() | |||||
return; | return; | ||||
} | } | ||||
m_cursors.Pop(); | |||||
m_cursors.pop(); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -171,7 +171,7 @@ void EasyMesh::SetVertColor(vec4 const &color) | |||||
return; | return; | ||||
} | } | ||||
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) | |||||
for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | |||||
m_vert[i].m_color = color; | m_vert[i].m_color = color; | ||||
} | } | ||||
@@ -18,7 +18,7 @@ namespace lol | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void EasyMesh::AddVertex(vec3 const &coord) | void EasyMesh::AddVertex(vec3 const &coord) | ||||
{ | { | ||||
m_vert.Push(VertexData(coord, vec3(0.f, 1.f, 0.f), BD()->ColorA())); | |||||
m_vert.push(VertexData(coord, vec3(0.f, 1.f, 0.f), BD()->ColorA())); | |||||
m_state = MeshRender::NeedConvert; | m_state = MeshRender::NeedConvert; | ||||
} | } | ||||
@@ -33,7 +33,7 @@ void EasyMesh::AddDupVertex(int i) | |||||
void EasyMesh::AddLerpVertex(int i, int j, float alpha) { AddLerpVertex(m_vert[i], m_vert[j], alpha); } | void EasyMesh::AddLerpVertex(int i, int j, float alpha) { AddLerpVertex(m_vert[i], m_vert[j], alpha); } | ||||
void EasyMesh::AddLerpVertex(VertexData const &vi, VertexData const &vj, float alpha) | void EasyMesh::AddLerpVertex(VertexData const &vi, VertexData const &vj, float alpha) | ||||
{ | { | ||||
m_vert.Push(GetLerpVertex(vi, vj, alpha)); | |||||
m_vert.push(GetLerpVertex(vi, vj, alpha)); | |||||
m_state = MeshRender::NeedConvert; | m_state = MeshRender::NeedConvert; | ||||
} | } | ||||
@@ -55,7 +55,7 @@ void EasyMesh::AddQuad(int i1, int i2, int i3, int i4, int base, bool duplicate) | |||||
{ | { | ||||
if (duplicate) | if (duplicate) | ||||
{ | { | ||||
int vbase = (int)m_vert.Count(); | |||||
int vbase = m_vert.count(); | |||||
AddDupVertex(base + i1); | AddDupVertex(base + i1); | ||||
AddDupVertex(base + i2); | AddDupVertex(base + i2); | ||||
AddDupVertex(base + i3); | AddDupVertex(base + i3); | ||||
@@ -68,7 +68,7 @@ void EasyMesh::AddQuad(int i1, int i2, int i3, int i4, int base, bool duplicate) | |||||
if (BD()->IsEnabled(MeshBuildOperation::QuadWeighting) && | if (BD()->IsEnabled(MeshBuildOperation::QuadWeighting) && | ||||
!BD()->IsEnabled(MeshBuildOperation::IgnoreQuadWeighting)) | !BD()->IsEnabled(MeshBuildOperation::IgnoreQuadWeighting)) | ||||
{ | { | ||||
int i5 = (int)m_vert.Count(); | |||||
int i5 = m_vert.count(); | |||||
AddLerpVertex(GetLerpVertex(base + i1, base + i3, .5f), | AddLerpVertex(GetLerpVertex(base + i1, base + i3, .5f), | ||||
GetLerpVertex(base + i2, base + i4, .5f), .5f); | GetLerpVertex(base + i2, base + i4, .5f), .5f); | ||||
m_indices << i1 + base; | m_indices << i1 + base; | ||||
@@ -105,9 +105,9 @@ void EasyMesh::AddTriangle(int i1, int i2, int i3, int base, bool duplicate) | |||||
{ | { | ||||
if (duplicate) | if (duplicate) | ||||
{ | { | ||||
m_indices << (uint16_t)m_vert.Count(); AddDupVertex(base + i1); | |||||
m_indices << (uint16_t)m_vert.Count(); AddDupVertex(base + i2); | |||||
m_indices << (uint16_t)m_vert.Count(); AddDupVertex(base + i3); | |||||
m_indices << (uint16_t)m_vert.count(); AddDupVertex(base + i1); | |||||
m_indices << (uint16_t)m_vert.count(); AddDupVertex(base + i2); | |||||
m_indices << (uint16_t)m_vert.count(); AddDupVertex(base + i3); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -126,7 +126,7 @@ void EasyMesh::ComputeNormals(int start, int vcount) | |||||
return; | return; | ||||
array< array<vec3> > normals; | array< array<vec3> > normals; | ||||
normals.Resize(m_vert.Count()); | |||||
normals.resize(m_vert.count()); | |||||
for (int i = 0; i < vcount; i += 3) | for (int i = 0; i < vcount; i += 3) | ||||
{ | { | ||||
vec3 v0 = m_vert[m_indices[start + i + 2]].m_coord | vec3 v0 = m_vert[m_indices[start + i + 2]].m_coord | ||||
@@ -139,20 +139,20 @@ void EasyMesh::ComputeNormals(int start, int vcount) | |||||
normals[m_indices[start + i + j]] << n; | normals[m_indices[start + i + j]] << n; | ||||
} | } | ||||
for (int i = 0; i < normals.Count(); i++) | |||||
for (int i = 0; i < normals.count(); i++) | |||||
{ | { | ||||
if (normals[i].Count() > 0) | |||||
if (normals[i].count() > 0) | |||||
{ | { | ||||
//remove doubles | //remove doubles | ||||
for (int j = 0; j < normals[i].Count(); ++j) | |||||
for (int k = j + 1; k < normals[i].Count(); ++k) | |||||
for (int j = 0; j < normals[i].count(); ++j) | |||||
for (int k = j + 1; k < normals[i].count(); ++k) | |||||
if (1.f - dot(normals[i][k], normals[i][j]) < .00001f) | if (1.f - dot(normals[i][k], normals[i][j]) < .00001f) | ||||
normals[i].Remove(k--); | |||||
normals[i].remove(k--); | |||||
vec3 newv = vec3::zero; | vec3 newv = vec3::zero; | ||||
for (int j = 0; j < normals[i].Count(); ++j) | |||||
for (int j = 0; j < normals[i].count(); ++j) | |||||
newv += normals[i][j]; | newv += normals[i][j]; | ||||
m_vert[i].m_normal = normalize(newv / (float)normals[i].Count()); | |||||
m_vert[i].m_normal = normalize(newv / (float)normals[i].count()); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -161,10 +161,10 @@ void EasyMesh::ComputeNormals(int start, int vcount) | |||||
void EasyMesh::VerticesCleanup() | void EasyMesh::VerticesCleanup() | ||||
{ | { | ||||
array<int> vert_ids; | array<int> vert_ids; | ||||
vert_ids.Resize(m_vert.Count(), 0); | |||||
vert_ids.resize(m_vert.count(), 0); | |||||
//1: Remove triangles with two vertices on each other | //1: Remove triangles with two vertices on each other | ||||
for (int i = 0; i < m_indices.Count(); i += 3) | |||||
for (int i = 0; i < m_indices.count(); i += 3) | |||||
{ | { | ||||
bool remove = false; | bool remove = false; | ||||
for (int j = 0; !remove && j < 3; ++j) | for (int j = 0; !remove && j < 3; ++j) | ||||
@@ -172,7 +172,7 @@ void EasyMesh::VerticesCleanup() | |||||
remove = true; | remove = true; | ||||
if (remove) | if (remove) | ||||
{ | { | ||||
m_indices.RemoveSwap(i, 3); | |||||
m_indices.remove_swap(i, 3); | |||||
i -= 3; | i -= 3; | ||||
} | } | ||||
else | else | ||||
@@ -186,8 +186,8 @@ void EasyMesh::VerticesCleanup() | |||||
//2: Remove all unused vertices | //2: Remove all unused vertices | ||||
array<VertexData> old_vert = m_vert; | array<VertexData> old_vert = m_vert; | ||||
int shift = 0; | int shift = 0; | ||||
m_vert.Empty(); | |||||
for (int i = 0; i < vert_ids.Count(); ++i) | |||||
m_vert.empty(); | |||||
for (int i = 0; i < vert_ids.count(); ++i) | |||||
{ | { | ||||
//Unused vertex, update the shift quantity instead of keeping it. | //Unused vertex, update the shift quantity instead of keeping it. | ||||
if (vert_ids[i] == 0) | if (vert_ids[i] == 0) | ||||
@@ -199,7 +199,7 @@ void EasyMesh::VerticesCleanup() | |||||
} | } | ||||
//3: Update the indices | //3: Update the indices | ||||
for (int i = 0; i < m_indices.Count(); ++i) | |||||
for (int i = 0; i < m_indices.count(); ++i) | |||||
m_indices[i] -= vert_ids[m_indices[i]]; | m_indices[i] -= vert_ids[m_indices[i]]; | ||||
} | } | ||||
@@ -214,11 +214,11 @@ void EasyMesh::VerticesMerge() | |||||
//1: Crunch all vertices in the dictionnary | //1: Crunch all vertices in the dictionnary | ||||
VertexDictionnary vert_dict; | VertexDictionnary vert_dict; | ||||
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) | |||||
for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | |||||
vert_dict.RegisterVertex(i, m_vert[i].m_coord); | vert_dict.RegisterVertex(i, m_vert[i].m_coord); | ||||
//2: Update the indices | //2: Update the indices | ||||
for (int i = 0; i < m_indices.Count(); ++i) | |||||
for (int i = 0; i < m_indices.count(); ++i) | |||||
{ | { | ||||
int master = vert_dict.FindVertexMaster(m_indices[i]); | int master = vert_dict.FindVertexMaster(m_indices[i]); | ||||
if (master >= 0) | if (master >= 0) | ||||
@@ -240,33 +240,33 @@ void EasyMesh::VerticesSeparate() | |||||
array< array<int> > new_ids; | array< array<int> > new_ids; | ||||
array<int> vert_ids; | array<int> vert_ids; | ||||
vert_ids.Resize(m_vert.Count(), 0); | |||||
vert_ids.resize(m_vert.count(), 0); | |||||
//1: Mark all used vertices | //1: Mark all used vertices | ||||
for (int i = 0; i < m_indices.Count(); ++i) | |||||
for (int i = 0; i < m_indices.count(); ++i) | |||||
vert_ids[m_indices[i]]++; | vert_ids[m_indices[i]]++; | ||||
//2: Update the vertices | //2: Update the vertices | ||||
int vbase = m_cursors.Last().m1; | |||||
int vcount = (int)m_vert.Count(); | |||||
new_ids.Resize(vcount); | |||||
int vbase = m_cursors.last().m1; | |||||
int vcount = m_vert.count(); | |||||
new_ids.resize(vcount); | |||||
for (int i = vbase; i < vcount; i++) | for (int i = vbase; i < vcount; i++) | ||||
{ | { | ||||
while (vert_ids[i] > 1) | while (vert_ids[i] > 1) | ||||
{ | { | ||||
//Add duplicate | //Add duplicate | ||||
new_ids[i] << (int)m_vert.Count(); | |||||
new_ids[i] << m_vert.count(); | |||||
AddDupVertex(i); | AddDupVertex(i); | ||||
vert_ids[i]--; | vert_ids[i]--; | ||||
} | } | ||||
} | } | ||||
//3: Update the indices | //3: Update the indices | ||||
for (int i = 0; i < m_indices.Count(); ++i) | |||||
for (int i = 0; i < m_indices.count(); ++i) | |||||
{ | { | ||||
if (new_ids[m_indices[i]].Count()) | |||||
if (new_ids[m_indices[i]].count()) | |||||
{ | { | ||||
int j = new_ids[m_indices[i]].Pop(); | |||||
int j = new_ids[m_indices[i]].pop(); | |||||
m_indices[i] = j; | m_indices[i] = j; | ||||
} | } | ||||
} | } | ||||
@@ -283,8 +283,8 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) | |||||
VertexDictionnary vert_dict; | VertexDictionnary vert_dict; | ||||
array<int> tri_list; | array<int> tri_list; | ||||
tri_list.Reserve(m_indices.Count() - m_cursors.Last().m2); | |||||
for (int i = m_cursors.Last().m2; i < m_indices.Count(); i++) | |||||
tri_list.Reserve(m_indices.count() - m_cursors.last().m2); | |||||
for (int i = m_cursors.last().m2; i < m_indices.count(); i++) | |||||
{ | { | ||||
vert_dict.RegisterVertex(m_indices[i], m_vert[m_indices[i]].m_coord); | vert_dict.RegisterVertex(m_indices[i], m_vert[m_indices[i]].m_coord); | ||||
tri_list << m_indices[i]; | tri_list << m_indices[i]; | ||||
@@ -293,11 +293,11 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) | |||||
//full triangle count | //full triangle count | ||||
array<int> tri_done; | array<int> tri_done; | ||||
array<int> tri_check; | array<int> tri_check; | ||||
int tri_count = (m_indices.Count() - m_cursors.Last().m2) / 3; | |||||
int tri_count = (m_indices.count() - m_cursors.last().m2) / 3; | |||||
tri_check << tri_list[0]; | tri_check << tri_list[0]; | ||||
while (tri_check.Count()) | |||||
while (tri_check.count()) | |||||
{ | { | ||||
int cur_tri = tri_check[0]; | int cur_tri = tri_check[0]; | ||||
int v[3] = { tri_list[cur_tri + uv_offset % 3], tri_list[cur_tri + (1 + uv_offset) % 3], tri_list[cur_tri + (2 + uv_offset) % 3] }; | int v[3] = { tri_list[cur_tri + uv_offset % 3], tri_list[cur_tri + (1 + uv_offset) % 3], tri_list[cur_tri + (2 + uv_offset) % 3] }; | ||||
@@ -396,7 +396,7 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) | |||||
//Deactivation is a test. | //Deactivation is a test. | ||||
matching_vert << v[i]; | matching_vert << v[i]; | ||||
vert_dict.FindMatchingVertices(v[i], matching_vert); | vert_dict.FindMatchingVertices(v[i], matching_vert); | ||||
for (int j = 0; j < matching_vert.Count(); j++) | |||||
for (int j = 0; j < matching_vert.count(); j++) | |||||
if (m_vert[matching_vert[j]].m_texcoord.xy == vec2(-1.0f)) | if (m_vert[matching_vert[j]].m_texcoord.xy == vec2(-1.0f)) | ||||
m_vert[matching_vert[j]].m_texcoord = vec4(abs(uv[i]), m_vert[matching_vert[j]].m_texcoord.zw); | m_vert[matching_vert[j]].m_texcoord = vec4(abs(uv[i]), m_vert[matching_vert[j]].m_texcoord.zw); | ||||
#else | #else | ||||
@@ -405,7 +405,7 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) | |||||
} | } | ||||
tri_done << cur_tri; | tri_done << cur_tri; | ||||
tri_check.Remove(0); | |||||
tri_check.remove(0); | |||||
//Get connected triangles and go from there. | //Get connected triangles and go from there. | ||||
for (int j = 0; j < 3; j++) | for (int j = 0; j < 3; j++) | ||||
@@ -433,22 +433,22 @@ void EasyMesh::ComputeTexCoord(float uv_scale, int uv_offset) | |||||
//uv[2] = vec2(-1.0f); | //uv[2] = vec2(-1.0f); | ||||
/* | /* | ||||
bool tri_present = false; | bool tri_present = false; | ||||
for (int j = 0; j < tri_done.Count(); j++) | |||||
for (int j = 0; j < tri_done.count(); j++) | |||||
if (cur_tri == tri_done[j]) | if (cur_tri == tri_done[j]) | ||||
tri_present = true; | tri_present = true; | ||||
if (!tri_present) | if (!tri_present) | ||||
tri_done << cur_tri; | tri_done << cur_tri; | ||||
tri_check.Remove(0); | |||||
tri_check.remove(0); | |||||
*/ | */ | ||||
} | } | ||||
if (tri_check.Count() == 0 && tri_done.Count() != tri_count) | |||||
if (tri_check.count() == 0 && tri_done.count() != tri_count) | |||||
{ | { | ||||
//look for unset triangle | //look for unset triangle | ||||
for (int i = 0; !tri_check.Count() && i < tri_list.Count(); i += 3) | |||||
for (int i = 0; !tri_check.count() && i < tri_list.count(); i += 3) | |||||
{ | { | ||||
bool tri_present = false; | bool tri_present = false; | ||||
for (int j = 0; j < tri_done.Count(); j++) | |||||
for (int j = 0; j < tri_done.count(); j++) | |||||
if (i == tri_done[j]) | if (i == tri_done[j]) | ||||
tri_present = true; | tri_present = true; | ||||
if (!tri_present) | if (!tri_present) | ||||
@@ -476,25 +476,26 @@ void EasyMesh::SetTexCoordData2(vec2 const &new_offset, vec2 const &new_scale) | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void EasyMesh::SetCurVertNormal(vec3 const &normal) | void EasyMesh::SetCurVertNormal(vec3 const &normal) | ||||
{ | { | ||||
m_vert[m_vert.Count() - 1].m_normal = normal; | |||||
m_vert.last().m_normal = normal; | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void EasyMesh::SetCurVertColor(vec4 const &color) | void EasyMesh::SetCurVertColor(vec4 const &color) | ||||
{ | { | ||||
m_vert[m_vert.Count() - 1].m_color = color; | |||||
m_vert.last().m_color = color; | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void EasyMesh::SetCurVertTexCoord(vec2 const &texcoord) | void EasyMesh::SetCurVertTexCoord(vec2 const &texcoord) | ||||
{ | { | ||||
m_vert[m_vert.Count() - 1].m_texcoord = vec4(texcoord, m_vert[m_vert.Count() - 1].m_texcoord.zw); | |||||
m_vert.last().m_texcoord = vec4(texcoord, m_vert.last().m_texcoord.zw); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void EasyMesh::SetCurVertTexCoord2(vec2 const &texcoord) | void EasyMesh::SetCurVertTexCoord2(vec2 const &texcoord) | ||||
{ | { | ||||
m_vert[m_vert.Count() - 1].m_texcoord = vec4(m_vert[m_vert.Count() - 1].m_texcoord.xy, texcoord); | |||||
m_vert.last().m_texcoord = vec4(m_vert.last().m_texcoord.xy, texcoord); | |||||
} | } | ||||
} /* namespace lol */ | } /* namespace lol */ | ||||
@@ -293,7 +293,7 @@ void EasyMesh::ExecuteCmdStack(bool ExecAllStack) | |||||
VerticesCleanup(); | VerticesCleanup(); | ||||
if (BD()->IsEnabled(MeshBuildOperation::PostBuildComputeNormals)) | if (BD()->IsEnabled(MeshBuildOperation::PostBuildComputeNormals)) | ||||
ComputeNormals(0, (int)m_indices.Count()); | |||||
ComputeNormals(0, m_indices.count()); | |||||
BD()->Disable(MeshBuildOperation::PostBuildComputeNormals); | BD()->Disable(MeshBuildOperation::PostBuildComputeNormals); | ||||
BD()->Disable(MeshBuildOperation::PreventVertCleanup); | BD()->Disable(MeshBuildOperation::PreventVertCleanup); | ||||
@@ -36,7 +36,7 @@ void EasyMesh::AppendCylinder(int nsides, float h, float d1, float d2, | |||||
vec2 Save_texcoord_offset = BD()->TexCoordOffset(); | vec2 Save_texcoord_offset = BD()->TexCoordOffset(); | ||||
vec2 Save_texcoord_scale = BD()->TexCoordScale(); | vec2 Save_texcoord_scale = BD()->TexCoordScale(); | ||||
int vbase = (int)m_vert.Count(); | |||||
int vbase = m_vert.count(); | |||||
mat3 rotmat = mat3::rotate(360.0f / (float)nsides, 0.f, 1.f, 0.f); | mat3 rotmat = mat3::rotate(360.0f / (float)nsides, 0.f, 1.f, 0.f); | ||||
vec3 p1(r1, -h * .5f, 0.f), p2(r2, h * .5f, 0.f), n; | vec3 p1(r1, -h * .5f, 0.f), p2(r2, h * .5f, 0.f), n; | ||||
@@ -135,7 +135,7 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float d) | |||||
//XXX : This operation is done to convert radius to diameter without changing all the code. | //XXX : This operation is done to convert radius to diameter without changing all the code. | ||||
float r = d * .5f; | float r = d * .5f; | ||||
int ibase = (int)m_indices.Count(); | |||||
int ibase = m_indices.count(); | |||||
array<vec3> vertices; | array<vec3> vertices; | ||||
float uv_h = 0; | float uv_h = 0; | ||||
@@ -258,7 +258,7 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float d) | |||||
SetCurVertTexCoord(vec2(0.f, 1.f) - new_uv); | SetCurVertTexCoord(vec2(0.f, 1.f) - new_uv); | ||||
SetCurVertTexCoord2(vec2(0.f, 1.f) - new_uv); | SetCurVertTexCoord2(vec2(0.f, 1.f) - new_uv); | ||||
} | } | ||||
AddTriangle(0, 2, 1, (int)m_vert.Count() - 3); | |||||
AddTriangle(0, 2, 1, m_vert.count() - 3); | |||||
} | } | ||||
} | } | ||||
@@ -272,7 +272,7 @@ void EasyMesh::AppendCapsule(int ndivisions, float h, float d) | |||||
} | } | ||||
} | } | ||||
ComputeNormals(ibase, (int)m_indices.Count() - ibase); | |||||
ComputeNormals(ibase, m_indices.count() - ibase); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -289,7 +289,7 @@ void EasyMesh::AppendTorus(int ndivisions, float d1, float d2) | |||||
float r1 = d1 * .5f; | float r1 = d1 * .5f; | ||||
float r2 = d2 * .5f; | float r2 = d2 * .5f; | ||||
int ibase = (int)m_indices.Count(); | |||||
int ibase = m_indices.count(); | |||||
int nidiv = ndivisions; /* Cross-section */ | int nidiv = ndivisions; /* Cross-section */ | ||||
int njdiv = ndivisions; /* Full circumference */ | int njdiv = ndivisions; /* Full circumference */ | ||||
@@ -320,11 +320,11 @@ void EasyMesh::AppendTorus(int ndivisions, float d1, float d2) | |||||
SetCurVertTexCoord2(vec2((float)(i + di) / (float)nidiv, (float)(j + dj) / (float)nidiv)); | SetCurVertTexCoord2(vec2((float)(i + di) / (float)nidiv, (float)(j + dj) / (float)nidiv)); | ||||
} | } | ||||
AddTriangle(0, 2, 3, (int)m_vert.Count() - 4); | |||||
AddTriangle(0, 3, 1, (int)m_vert.Count() - 4); | |||||
AddTriangle(0, 2, 3, m_vert.count() - 4); | |||||
AddTriangle(0, 3, 1, m_vert.count() - 4); | |||||
} | } | ||||
ComputeNormals(ibase, (int)m_indices.Count() - ibase); | |||||
ComputeNormals(ibase, m_indices.count() - ibase); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -361,8 +361,8 @@ void EasyMesh::AppendBox(vec3 const &size, float chamf, bool smooth) | |||||
return; | return; | ||||
} | } | ||||
int vbase = (int)m_vert.Count(); | |||||
int ibase = (int)m_indices.Count(); | |||||
int vbase = m_vert.count(); | |||||
int ibase = m_indices.count(); | |||||
vec3 d = size * 0.5f; | vec3 d = size * 0.5f; | ||||
@@ -486,8 +486,8 @@ void EasyMesh::AppendBox(vec3 const &size, float chamf, bool smooth) | |||||
SetCurVertTexCoord(BD()->TexCoord(mt, tl, mft)); | SetCurVertTexCoord(BD()->TexCoord(mt, tl, mft)); | ||||
SetCurVertTexCoord2(BD()->TexCoord2(mt, tr, mft)); | SetCurVertTexCoord2(BD()->TexCoord2(mt, tr, mft)); | ||||
ComputeNormals(ibase, (int)m_indices.Count() - ibase); | |||||
ibase = (int)m_indices.Count(); | |||||
ComputeNormals(ibase, m_indices.count() - ibase); | |||||
ibase = m_indices.count(); | |||||
//Build the box at the end : The 6 quads on each side of the box. | //Build the box at the end : The 6 quads on each side of the box. | ||||
for (int i = 0; i < 24; i += 4) | for (int i = 0; i < 24; i += 4) | ||||
@@ -521,7 +521,7 @@ void EasyMesh::AppendBox(vec3 const &size, float chamf, bool smooth) | |||||
} | } | ||||
if (!smooth) | if (!smooth) | ||||
ComputeNormals(ibase, (int)m_indices.Count() - ibase); | |||||
ComputeNormals(ibase, m_indices.count() - ibase); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -543,7 +543,7 @@ void EasyMesh::AppendStar(int nbranches, float d1, float d2, | |||||
float r2 = d2 * .5f; | float r2 = d2 * .5f; | ||||
//TODO: It would probably be good to think of another way of UV painting this, like "branch repeating" | //TODO: It would probably be good to think of another way of UV painting this, like "branch repeating" | ||||
int vbase = (int)m_vert.Count(); | |||||
int vbase = m_vert.count(); | |||||
float maxr = max(r1, r2); | float maxr = max(r1, r2); | ||||
AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); SetCurVertTexCoord2(vec2(.5f, .5f)); | AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); SetCurVertTexCoord2(vec2(.5f, .5f)); | ||||
@@ -595,7 +595,7 @@ void EasyMesh::AppendExpandedStar(int nbranches, float d1, float d2, float extra | |||||
float r2 = d2 * .5f; | float r2 = d2 * .5f; | ||||
float extrar = extrad * .5f; | float extrar = extrad * .5f; | ||||
int vbase = (int)m_vert.Count(); | |||||
int vbase = m_vert.count(); | |||||
float maxr = lol::max(lol::max(r1, r2), lol::max(r1 + extrar, r2 + extrar)); | float maxr = lol::max(lol::max(r1, r2), lol::max(r1 + extrar, r2 + extrar)); | ||||
AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); SetCurVertTexCoord2(vec2(.5f, .5f)); | AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); SetCurVertTexCoord2(vec2(.5f, .5f)); | ||||
@@ -648,7 +648,7 @@ void EasyMesh::AppendDisc(int nsides, float d, bool fade) | |||||
//XXX : This operation is done to convert radius to diameter without changing all the code. | //XXX : This operation is done to convert radius to diameter without changing all the code. | ||||
float r = d * .5f; | float r = d * .5f; | ||||
int vbase = (int)m_vert.Count(); | |||||
int vbase = m_vert.count(); | |||||
AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); SetCurVertTexCoord2(vec2(.5f, .5f)); | AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); SetCurVertTexCoord2(vec2(.5f, .5f)); | ||||
@@ -693,7 +693,7 @@ void EasyMesh::AppendSimpleTriangle(float d, bool fade) | |||||
if (fade) | if (fade) | ||||
SetCurVertColor(BD()->ColorB()); | SetCurVertColor(BD()->ColorB()); | ||||
AddTriangle(0, 1, 2, (int)m_vert.Count() - 3); | |||||
AddTriangle(0, 1, 2, m_vert.count() - 3); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -738,8 +738,8 @@ void EasyMesh::AppendSimpleQuad(vec2 p1, vec2 p2, float z, bool fade) | |||||
SetCurVertTexCoord2(BD()->TexCoord2(mt, tr, mft)); | SetCurVertTexCoord2(BD()->TexCoord2(mt, tr, mft)); | ||||
if (fade) SetCurVertColor(BD()->ColorB()); | if (fade) SetCurVertColor(BD()->ColorB()); | ||||
AddQuad(0, 1, 2, 3, (int)m_vert.Count() - 4); | |||||
ComputeNormals((int)m_indices.Count() - 6, 6); | |||||
AddQuad(0, 1, 2, 3, m_vert.count() - 4); | |||||
ComputeNormals(m_indices.count() - 6, 6); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -766,8 +766,8 @@ void EasyMesh::AppendCog(int nbsides, float h, float d10, float d20, | |||||
float r12 = d12 * .5f; | float r12 = d12 * .5f; | ||||
float r22 = d22 * .5f; | float r22 = d22 * .5f; | ||||
int ibase = (int)m_indices.Count(); | |||||
int vbase = (int)m_vert.Count(); | |||||
int ibase = m_indices.count(); | |||||
int vbase = m_vert.count(); | |||||
/* FIXME: enforce this some other way */ | /* FIXME: enforce this some other way */ | ||||
if (r12 < 0) | if (r12 < 0) | ||||
@@ -1011,13 +1011,13 @@ void EasyMesh::AppendCog(int nbsides, float h, float d10, float d20, | |||||
int l = -4; | int l = -4; | ||||
while ((l += 4) < 48) | while ((l += 4) < 48) | ||||
AddQuad(q[l + 0] + m[l + 0] * 3 + a[l + 0], | AddQuad(q[l + 0] + m[l + 0] * 3 + a[l + 0], | ||||
q[l + 1] + m[l + 1] * 3 + a[l + 1], | |||||
q[l + 2] + m[l + 2] * 3 + a[l + 2], | |||||
q[l + 3] + m[l + 3] * 3 + a[l + 3], | |||||
vbase); | |||||
q[l + 1] + m[l + 1] * 3 + a[l + 1], | |||||
q[l + 2] + m[l + 2] * 3 + a[l + 2], | |||||
q[l + 3] + m[l + 3] * 3 + a[l + 3], | |||||
vbase); | |||||
} | } | ||||
ComputeNormals(ibase, (int)m_indices.Count() - ibase); | |||||
ComputeNormals(ibase, m_indices.count() - ibase); | |||||
} | } | ||||
} /* namespace lol */ | } /* namespace lol */ |
@@ -30,9 +30,9 @@ void EasyMesh::MeshConvert() | |||||
Shader *shader = Shader::Create(LOLFX_RESOURCE_NAME(shiny)); | Shader *shader = Shader::Create(LOLFX_RESOURCE_NAME(shiny)); | ||||
/* Push index buffer to GPU */ | /* Push index buffer to GPU */ | ||||
IndexBuffer *ibo = new IndexBuffer(m_indices.Count() * sizeof(uint16_t)); | |||||
IndexBuffer *ibo = new IndexBuffer(m_indices.count() * sizeof(uint16_t)); | |||||
uint16_t *indices = (uint16_t *)ibo->Lock(0, 0); | uint16_t *indices = (uint16_t *)ibo->Lock(0, 0); | ||||
for (int i = 0; i < m_indices.Count(); ++i) | |||||
for (int i = 0; i < m_indices.count(); ++i) | |||||
indices[i] = m_indices[i]; | indices[i] = m_indices[i]; | ||||
ibo->Unlock(); | ibo->Unlock(); | ||||
@@ -50,9 +50,9 @@ void EasyMesh::MeshConvert() | |||||
VertexUsage::Color, | VertexUsage::Color, | ||||
VertexUsage::TexCoord)); | VertexUsage::TexCoord)); | ||||
VertexBuffer *vbo = new VertexBuffer(m_vert.Count() * sizeof(Vertex)); | |||||
VertexBuffer *vbo = new VertexBuffer(m_vert.count() * sizeof(Vertex)); | |||||
Vertex *vert = (Vertex *)vbo->Lock(0, 0); | Vertex *vert = (Vertex *)vbo->Lock(0, 0); | ||||
for (int i = 0; i < m_vert.Count(); ++i) | |||||
for (int i = 0; i < m_vert.count(); ++i) | |||||
{ | { | ||||
vert[i].pos = m_vert[i].m_coord, | vert[i].pos = m_vert[i].m_coord, | ||||
vert[i].normal = m_vert[i].m_normal, | vert[i].normal = m_vert[i].m_normal, | ||||
@@ -62,9 +62,9 @@ void EasyMesh::MeshConvert() | |||||
vbo->Unlock(); | vbo->Unlock(); | ||||
/* Reference our new data in our submesh */ | /* Reference our new data in our submesh */ | ||||
m_submeshes.Push(new SubMesh(shader, vdecl)); | |||||
m_submeshes.Last()->SetIndexBuffer(ibo); | |||||
m_submeshes.Last()->SetVertexBuffer(0, vbo); | |||||
m_submeshes.push(new SubMesh(shader, vdecl)); | |||||
m_submeshes.last()->SetIndexBuffer(ibo); | |||||
m_submeshes.last()->SetVertexBuffer(0, vbo); | |||||
m_state = MeshRender::CanRender; | m_state = MeshRender::CanRender; | ||||
} | } | ||||
@@ -86,26 +86,26 @@ GpuShaderData::GpuShaderData(uint16_t vert_decl_flags, Shader* shader, DebugRend | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
GpuShaderData::~GpuShaderData() | GpuShaderData::~GpuShaderData() | ||||
{ | { | ||||
m_shader_uniform.Empty(); | |||||
m_shader_attrib.Empty(); | |||||
m_shader_uniform.empty(); | |||||
m_shader_attrib.empty(); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void GpuShaderData::AddUniform(const lol::String &new_uniform) | void GpuShaderData::AddUniform(const lol::String &new_uniform) | ||||
{ | { | ||||
m_shader_uniform.Push(new_uniform, m_shader->GetUniformLocation(new_uniform.C())); | |||||
m_shader_uniform.push(new_uniform, m_shader->GetUniformLocation(new_uniform.C())); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void GpuShaderData::AddAttribute(VertexUsage usage, int index) | void GpuShaderData::AddAttribute(VertexUsage usage, int index) | ||||
{ | { | ||||
m_shader_attrib.Push(m_shader->GetAttribLocation(usage, index)); | |||||
m_shader_attrib.push(m_shader->GetAttribLocation(usage, index)); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
ShaderUniform const *GpuShaderData::GetUniform(const lol::String &uniform) | ShaderUniform const *GpuShaderData::GetUniform(const lol::String &uniform) | ||||
{ | { | ||||
for (int i = 0; i < m_shader_uniform.Count(); ++i) | |||||
for (int i = 0; i < m_shader_uniform.count(); ++i) | |||||
if (m_shader_uniform[i].m1 == uniform) | if (m_shader_uniform[i].m1 == uniform) | ||||
return &m_shader_uniform[i].m2; | return &m_shader_uniform[i].m2; | ||||
return nullptr; | return nullptr; | ||||
@@ -114,7 +114,7 @@ ShaderUniform const *GpuShaderData::GetUniform(const lol::String &uniform) | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
ShaderAttrib const *GpuShaderData::GetAttribute(VertexUsage usage, int index) | ShaderAttrib const *GpuShaderData::GetAttribute(VertexUsage usage, int index) | ||||
{ | { | ||||
for (int i = 0; i < m_shader_attrib.Count(); ++i) | |||||
for (int i = 0; i < m_shader_attrib.count(); ++i) | |||||
if (m_shader_attrib[i].GetUsage() == usage && m_shader_attrib[i].GetIndex() == index) | if (m_shader_attrib[i].GetUsage() == usage && m_shader_attrib[i].GetIndex() == index) | ||||
return &m_shader_attrib[i]; | return &m_shader_attrib[i]; | ||||
return nullptr; | return nullptr; | ||||
@@ -197,9 +197,9 @@ void DefaultShaderData::SetupShaderDatas(mat4 const &model) | |||||
/* FIXME: the 4th component of the position can be used for other things */ | /* FIXME: the 4th component of the position can be used for other things */ | ||||
/* FIXME: GetUniform("blabla") is costly */ | /* FIXME: GetUniform("blabla") is costly */ | ||||
for (int i = 0; i < lights.Count(); ++i) | |||||
for (int i = 0; i < lights.count(); ++i) | |||||
light_data << vec4(lights[i]->GetPosition(), (float)lights[i]->GetType()) << lights[i]->GetColor(); | light_data << vec4(lights[i]->GetPosition(), (float)lights[i]->GetType()) << lights[i]->GetColor(); | ||||
while (light_data.Count() < LOL_MAX_LIGHT_COUNT) | |||||
while (light_data.count() < LOL_MAX_LIGHT_COUNT) | |||||
light_data << vec4::zero << vec4::zero; | light_data << vec4::zero << vec4::zero; | ||||
int i = 0; | int i = 0; | ||||
@@ -225,8 +225,8 @@ GpuEasyMeshData::GpuEasyMeshData() | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
GpuEasyMeshData::~GpuEasyMeshData() | GpuEasyMeshData::~GpuEasyMeshData() | ||||
{ | { | ||||
m_gpudatas.Empty(); | |||||
m_vdatas.Empty(); | |||||
m_gpudatas.empty(); | |||||
m_vdatas.empty(); | |||||
if (m_ibo) | if (m_ibo) | ||||
delete m_ibo; | delete m_ibo; | ||||
} | } | ||||
@@ -263,27 +263,27 @@ void GpuEasyMeshData::AddGpuData(GpuShaderData* gpudata, EasyMesh* src_mesh) | |||||
if (!m_ibo) | if (!m_ibo) | ||||
{ | { | ||||
array<uint16_t> indexlist; | array<uint16_t> indexlist; | ||||
for (int i = 0; i < src_mesh->m_indices.Count(); i += 3) | |||||
for (int i = 0; i < src_mesh->m_indices.count(); i += 3) | |||||
{ | { | ||||
indexlist << src_mesh->m_indices[i + 0]; | indexlist << src_mesh->m_indices[i + 0]; | ||||
indexlist << src_mesh->m_indices[i + 1]; | indexlist << src_mesh->m_indices[i + 1]; | ||||
indexlist << src_mesh->m_indices[i + 2]; | indexlist << src_mesh->m_indices[i + 2]; | ||||
} | } | ||||
m_ibo = new IndexBuffer(indexlist.Bytes()); | |||||
m_ibo = new IndexBuffer(indexlist.bytes()); | |||||
void *indices = m_ibo->Lock(0, 0); | void *indices = m_ibo->Lock(0, 0); | ||||
memcpy(indices, &indexlist[0], indexlist.Bytes()); | |||||
memcpy(indices, &indexlist[0], indexlist.bytes()); | |||||
m_ibo->Unlock(); | m_ibo->Unlock(); | ||||
m_indexcount = (int)indexlist.Count(); | |||||
m_indexcount = indexlist.count(); | |||||
} | } | ||||
//init to a minimum of gpudata->m_render_mode size | //init to a minimum of gpudata->m_render_mode size | ||||
if (m_gpudatas.Count() <= gpudata->m_render_mode) | |||||
if (m_gpudatas.count() <= gpudata->m_render_mode) | |||||
{ | { | ||||
int i = (int)m_gpudatas.Count(); | |||||
int i = m_gpudatas.count(); | |||||
int max = gpudata->m_render_mode + 1; | int max = gpudata->m_render_mode + 1; | ||||
m_gpudatas.Reserve(max); | |||||
m_gpudatas.reserve(max); | |||||
for (; i < max; i++) | for (; i < max; i++) | ||||
m_gpudatas << nullptr; | m_gpudatas << nullptr; | ||||
} | } | ||||
@@ -293,7 +293,7 @@ void GpuEasyMeshData::AddGpuData(GpuShaderData* gpudata, EasyMesh* src_mesh) | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | ||||
{ | { | ||||
for (int i = 0; i < m_vdatas.Count(); ++i) | |||||
for (int i = 0; i < m_vdatas.count(); ++i) | |||||
if (m_vdatas[i].m1 == vflags) | if (m_vdatas[i].m1 == vflags) | ||||
return; | return; | ||||
@@ -304,8 +304,8 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | |||||
#define COPY_VBO \ | #define COPY_VBO \ | ||||
vbo_data = &vertexlist[0]; \ | vbo_data = &vertexlist[0]; \ | ||||
vbo_bytes = (int)vertexlist.Bytes(); \ | |||||
m_vertexcount = (int)vertexlist.Count(); \ | |||||
vbo_bytes = vertexlist.bytes(); \ | |||||
m_vertexcount = vertexlist.count(); \ | |||||
new_vbo = new VertexBuffer(vbo_bytes); \ | new_vbo = new VertexBuffer(vbo_bytes); \ | ||||
void *mesh = new_vbo->Lock(0, 0); \ | void *mesh = new_vbo->Lock(0, 0); \ | ||||
memcpy(mesh, vbo_data, vbo_bytes); \ | memcpy(mesh, vbo_data, vbo_bytes); \ | ||||
@@ -331,8 +331,8 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | |||||
VertexUsage::TexCoord)); | VertexUsage::TexCoord)); | ||||
array<vec3, vec3, u8vec4, vec4> vertexlist; | array<vec3, vec3, u8vec4, vec4> vertexlist; | ||||
for (int i = 0; i < src_mesh->m_vert.Count(); i++) | |||||
vertexlist.Push(src_mesh->m_vert[i].m_coord, | |||||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||||
vertexlist.push(src_mesh->m_vert[i].m_coord, | |||||
src_mesh->m_vert[i].m_normal, | src_mesh->m_vert[i].m_normal, | ||||
(u8vec4)(src_mesh->m_vert[i].m_color * 255.f), | (u8vec4)(src_mesh->m_vert[i].m_color * 255.f), | ||||
src_mesh->m_vert[i].m_texcoord); | src_mesh->m_vert[i].m_texcoord); | ||||
@@ -348,8 +348,8 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | |||||
VertexUsage::TexCoord)); | VertexUsage::TexCoord)); | ||||
array<vec3, vec3, u8vec4, vec2> vertexlist; | array<vec3, vec3, u8vec4, vec2> vertexlist; | ||||
for (int i = 0; i < src_mesh->m_vert.Count(); i++) | |||||
vertexlist.Push(src_mesh->m_vert[i].m_coord, | |||||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||||
vertexlist.push(src_mesh->m_vert[i].m_coord, | |||||
src_mesh->m_vert[i].m_normal, | src_mesh->m_vert[i].m_normal, | ||||
(u8vec4)(src_mesh->m_vert[i].m_color * 255.f), | (u8vec4)(src_mesh->m_vert[i].m_color * 255.f), | ||||
src_mesh->m_vert[i].m_texcoord.xy); | src_mesh->m_vert[i].m_texcoord.xy); | ||||
@@ -360,8 +360,8 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | |||||
new_vdecl = new VertexDeclaration(VertexStream<vec3,vec4,vec4>(VertexUsage::Position, VertexUsage::Color, VertexUsage::TexCoord)); | new_vdecl = new VertexDeclaration(VertexStream<vec3,vec4,vec4>(VertexUsage::Position, VertexUsage::Color, VertexUsage::TexCoord)); | ||||
array<vec3, vec4, vec4> vertexlist; | array<vec3, vec4, vec4> vertexlist; | ||||
for (int i = 0; i < src_mesh->m_vert.Count(); i++) | |||||
vertexlist.Push(src_mesh->m_vert[i].m_coord, src_mesh->m_vert[i].m_color, src_mesh->m_vert[i].m_texcoord); | |||||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||||
vertexlist.push(src_mesh->m_vert[i].m_coord, src_mesh->m_vert[i].m_color, src_mesh->m_vert[i].m_texcoord); | |||||
COPY_VBO; | COPY_VBO; | ||||
} | } | ||||
else if (flagnb == 3 && has_position && has_normal && has_color) | else if (flagnb == 3 && has_position && has_normal && has_color) | ||||
@@ -373,8 +373,8 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | |||||
VertexUsage::Color)); | VertexUsage::Color)); | ||||
array<vec3,vec3,u8vec4> vertexlist; | array<vec3,vec3,u8vec4> vertexlist; | ||||
for (int i = 0; i < src_mesh->m_vert.Count(); i++) | |||||
vertexlist.Push(src_mesh->m_vert[i].m_coord, | |||||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||||
vertexlist.push(src_mesh->m_vert[i].m_coord, | |||||
src_mesh->m_vert[i].m_normal, | src_mesh->m_vert[i].m_normal, | ||||
(u8vec4)(src_mesh->m_vert[i].m_color * 255.f)); | (u8vec4)(src_mesh->m_vert[i].m_color * 255.f)); | ||||
COPY_VBO; | COPY_VBO; | ||||
@@ -384,8 +384,8 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | |||||
new_vdecl = new VertexDeclaration(VertexStream<vec3,vec4>(VertexUsage::Position, VertexUsage::TexCoord)); | new_vdecl = new VertexDeclaration(VertexStream<vec3,vec4>(VertexUsage::Position, VertexUsage::TexCoord)); | ||||
array<vec3, vec4> vertexlist; | array<vec3, vec4> vertexlist; | ||||
for (int i = 0; i < src_mesh->m_vert.Count(); i++) | |||||
vertexlist.Push(src_mesh->m_vert[i].m_coord, src_mesh->m_vert[i].m_texcoord); | |||||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||||
vertexlist.push(src_mesh->m_vert[i].m_coord, src_mesh->m_vert[i].m_texcoord); | |||||
COPY_VBO; | COPY_VBO; | ||||
} | } | ||||
else if (flagnb == 2 && has_position && has_texcoord) | else if (flagnb == 2 && has_position && has_texcoord) | ||||
@@ -393,8 +393,8 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | |||||
new_vdecl = new VertexDeclaration(VertexStream<vec3,vec2>(VertexUsage::Position, VertexUsage::TexCoord)); | new_vdecl = new VertexDeclaration(VertexStream<vec3,vec2>(VertexUsage::Position, VertexUsage::TexCoord)); | ||||
array<vec3, vec2> vertexlist; | array<vec3, vec2> vertexlist; | ||||
for (int i = 0; i < src_mesh->m_vert.Count(); i++) | |||||
vertexlist.Push(src_mesh->m_vert[i].m_coord, src_mesh->m_vert[i].m_texcoord.xy); | |||||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||||
vertexlist.push(src_mesh->m_vert[i].m_coord, src_mesh->m_vert[i].m_texcoord.xy); | |||||
COPY_VBO; | COPY_VBO; | ||||
} | } | ||||
else if (flagnb == 2 && has_position && has_color) | else if (flagnb == 2 && has_position && has_color) | ||||
@@ -402,29 +402,29 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vflags, EasyMesh* src_mesh) | |||||
new_vdecl = new VertexDeclaration(VertexStream<vec3,u8vec4>(VertexUsage::Position, VertexUsage::Color)); | new_vdecl = new VertexDeclaration(VertexStream<vec3,u8vec4>(VertexUsage::Position, VertexUsage::Color)); | ||||
array<vec3, u8vec4> vertexlist; | array<vec3, u8vec4> vertexlist; | ||||
for (int i = 0; i < src_mesh->m_vert.Count(); i++) | |||||
vertexlist.Push(src_mesh->m_vert[i].m_coord, (u8vec4)(src_mesh->m_vert[i].m_color * 255.f)); | |||||
for (int i = 0; i < src_mesh->m_vert.count(); i++) | |||||
vertexlist.push(src_mesh->m_vert[i].m_coord, (u8vec4)(src_mesh->m_vert[i].m_color * 255.f)); | |||||
COPY_VBO; | COPY_VBO; | ||||
} | } | ||||
else | else | ||||
ASSERT(0, "no Vertex Declaration combination for 0x%04x", vflags); | ASSERT(0, "no Vertex Declaration combination for 0x%04x", vflags); | ||||
m_vdatas.Push(vflags, new_vdecl, new_vbo); | |||||
m_vdatas.push(vflags, new_vdecl, new_vbo); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void GpuEasyMeshData::RenderMeshData(mat4 const &model, int render_mode) | void GpuEasyMeshData::RenderMeshData(mat4 const &model, int render_mode) | ||||
{ | { | ||||
ASSERT(0 <= render_mode && render_mode < m_gpudatas.Count(), "render mode is not in the defined range"); | |||||
ASSERT(0 <= render_mode && render_mode < m_gpudatas.count(), "render mode is not in the defined range"); | |||||
ASSERT(m_gpudatas[render_mode], "gpu datas for this render mode don't exist"); | ASSERT(m_gpudatas[render_mode], "gpu datas for this render mode don't exist"); | ||||
GpuShaderData& gpu_sd = *(m_gpudatas[render_mode]); | GpuShaderData& gpu_sd = *(m_gpudatas[render_mode]); | ||||
int vdecl_idx = 0; | int vdecl_idx = 0; | ||||
for (; vdecl_idx < m_vdatas.Count(); ++vdecl_idx) | |||||
for (; vdecl_idx < m_vdatas.count(); ++vdecl_idx) | |||||
if (m_vdatas[vdecl_idx].m1 == gpu_sd.m_vert_decl_flags) | if (m_vdatas[vdecl_idx].m1 == gpu_sd.m_vert_decl_flags) | ||||
break; | break; | ||||
if (vdecl_idx >= m_vdatas.Count()) | |||||
if (vdecl_idx >= m_vdatas.count()) | |||||
return; | return; | ||||
uint16_t vflags = m_vdatas[vdecl_idx].m1; | uint16_t vflags = m_vdatas[vdecl_idx].m1; | ||||
@@ -119,7 +119,7 @@ public: | |||||
//--- | //--- | ||||
void AddGpuData(GpuShaderData* gpudata, class EasyMesh* src_mesh); | void AddGpuData(GpuShaderData* gpudata, class EasyMesh* src_mesh); | ||||
void RenderMeshData(mat4 const &model, int render_mode=Video::GetDebugRenderMode()); | void RenderMeshData(mat4 const &model, int render_mode=Video::GetDebugRenderMode()); | ||||
bool HasData(int render_mode) { return (0 <= render_mode && render_mode < m_gpudatas.Count() && !!m_gpudatas[render_mode]); } | |||||
bool HasData(int render_mode) { return (0 <= render_mode && render_mode < m_gpudatas.count() && !!m_gpudatas[render_mode]); } | |||||
private: | private: | ||||
void SetupVertexData(uint16_t vdecl_flags, EasyMesh* src_mesh); | void SetupVertexData(uint16_t vdecl_flags, EasyMesh* src_mesh); | ||||
@@ -30,7 +30,7 @@ void EasyMesh::Translate(vec3 const &v) | |||||
return; | return; | ||||
} | } | ||||
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) | |||||
for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | |||||
m_vert[i].m_coord += v; | m_vert[i].m_coord += v; | ||||
} | } | ||||
@@ -50,7 +50,7 @@ void EasyMesh::Rotate(float angle, vec3 const &axis) | |||||
} | } | ||||
mat3 m = mat3::rotate(angle, axis); | mat3 m = mat3::rotate(angle, axis); | ||||
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) | |||||
for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | |||||
{ | { | ||||
m_vert[i].m_coord = m * m_vert[i].m_coord; | m_vert[i].m_coord = m * m_vert[i].m_coord; | ||||
m_vert[i].m_normal = m * m_vert[i].m_normal; | m_vert[i].m_normal = m * m_vert[i].m_normal; | ||||
@@ -67,14 +67,14 @@ void EasyMesh::RadialJitter(float r) | |||||
return; | return; | ||||
} | } | ||||
array<int> Welded; | |||||
Welded.Push(-1); | |||||
for (int i = m_cursors.Last().m1 + 1; i < m_vert.Count(); i++) | |||||
array<int> welded; | |||||
welded.push(-1); | |||||
for (int i = m_cursors.last().m1 + 1; i < m_vert.count(); i++) | |||||
{ | { | ||||
int j, k; | int j, k; | ||||
for (j = m_cursors.Last().m1, k = 0; j < i; j++, k++) | |||||
for (j = m_cursors.last().m1, k = 0; j < i; j++, k++) | |||||
{ | { | ||||
if(Welded[k] < 0) | |||||
if(welded[k] < 0) | |||||
{ | { | ||||
vec3 diff = m_vert[i].m_coord - m_vert[j].m_coord; | vec3 diff = m_vert[i].m_coord - m_vert[j].m_coord; | ||||
@@ -91,22 +91,19 @@ void EasyMesh::RadialJitter(float r) | |||||
} | } | ||||
} | } | ||||
if(j == i) | |||||
Welded.Push(-1); | |||||
else | |||||
Welded.Push(j); | |||||
welded.push(j != i ? j : -1); | |||||
} | } | ||||
int i, j; | int i, j; | ||||
for (i = m_cursors.Last().m1, j = 0; i < m_vert.Count(); i++, j++) | |||||
for (i = m_cursors.last().m1, j = 0; i < m_vert.count(); i++, j++) | |||||
{ | { | ||||
if(Welded[j] == -1) | |||||
if(welded[j] == -1) | |||||
m_vert[i].m_coord *= 1.0f + rand(r); | m_vert[i].m_coord *= 1.0f + rand(r); | ||||
else | else | ||||
m_vert[i].m_coord = m_vert[Welded[j]].m_coord; | |||||
m_vert[i].m_coord = m_vert[welded[j]].m_coord; | |||||
} | } | ||||
ComputeNormals(m_cursors.Last().m2, (int)m_indices.Count() - m_cursors.Last().m2); | |||||
ComputeNormals(m_cursors.last().m2, m_indices.count() - m_cursors.last().m2); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -147,7 +144,7 @@ void EasyMesh::DoMeshTransform(MeshTransform ct, Axis axis0, Axis axis1, float n | |||||
return; | return; | ||||
} | } | ||||
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) | |||||
for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | |||||
{ | { | ||||
switch (ct.ToScalar()) | switch (ct.ToScalar()) | ||||
{ | { | ||||
@@ -188,7 +185,7 @@ void EasyMesh::DoMeshTransform(MeshTransform ct, Axis axis0, Axis axis1, float n | |||||
} | } | ||||
} | } | ||||
} | } | ||||
ComputeNormals(m_cursors.Last().m2, (int)m_indices.Count() - m_cursors.Last().m2); | |||||
ComputeNormals(m_cursors.last().m2, m_indices.count() - m_cursors.last().m2); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -207,7 +204,7 @@ void EasyMesh::Scale(vec3 const &s) | |||||
vec3 const invs = vec3(1) / s; | vec3 const invs = vec3(1) / s; | ||||
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) | |||||
for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | |||||
{ | { | ||||
m_vert[i].m_coord *= s; | m_vert[i].m_coord *= s; | ||||
m_vert[i].m_normal = normalize(m_vert[i].m_normal * invs); | m_vert[i].m_normal = normalize(m_vert[i].m_normal * invs); | ||||
@@ -216,7 +213,7 @@ void EasyMesh::Scale(vec3 const &s) | |||||
/* Flip winding if the scaling involves mirroring */ | /* Flip winding if the scaling involves mirroring */ | ||||
if (!BD()->IsEnabled(MeshBuildOperation::ScaleWinding) && s.x * s.y * s.z < 0) | if (!BD()->IsEnabled(MeshBuildOperation::ScaleWinding) && s.x * s.y * s.z < 0) | ||||
{ | { | ||||
for (int i = m_cursors.Last().m2; i < m_indices.Count(); i += 3) | |||||
for (int i = m_cursors.last().m2; i < m_indices.count(); i += 3) | |||||
{ | { | ||||
uint16_t tmp = m_indices[i + 0]; | uint16_t tmp = m_indices[i + 0]; | ||||
m_indices[i + 0] = m_indices[i + 1]; | m_indices[i + 0] = m_indices[i + 1]; | ||||
@@ -240,26 +237,26 @@ void EasyMesh::DupAndScale(vec3 const &s, bool open_brace) | |||||
return; | return; | ||||
} | } | ||||
int vlen = (int)m_vert.Count() - m_cursors.Last().m1; | |||||
int tlen = (int)m_indices.Count() - m_cursors.Last().m2; | |||||
int vlen = m_vert.count() - m_cursors.last().m1; | |||||
int tlen = m_indices.count() - m_cursors.last().m2; | |||||
for (int i = 0; i < vlen; i++) | for (int i = 0; i < vlen; i++) | ||||
AddDupVertex(m_cursors.Last().m1++); | |||||
AddDupVertex(m_cursors.last().m1++); | |||||
for (int i = 0; i < tlen; i++) | for (int i = 0; i < tlen; i++) | ||||
m_indices << m_indices[m_cursors.Last().m2++] + vlen; | |||||
m_indices << m_indices[m_cursors.last().m2++] + vlen; | |||||
Scale(s); | Scale(s); | ||||
m_cursors.Last().m1 -= vlen; | |||||
m_cursors.Last().m2 -= tlen; | |||||
m_cursors.last().m1 -= vlen; | |||||
m_cursors.last().m2 -= tlen; | |||||
if (open_brace) | if (open_brace) | ||||
{ | { | ||||
OpenBrace(); | OpenBrace(); | ||||
m_cursors.Last().m1 -= vlen; | |||||
m_cursors.Last().m2 -= tlen; | |||||
m_cursors.last().m1 -= vlen; | |||||
m_cursors.last().m2 -= tlen; | |||||
} | } | ||||
} | } | ||||
@@ -273,8 +270,8 @@ void EasyMesh::Chamfer(float f) | |||||
return; | return; | ||||
} | } | ||||
int vlen = (int)m_vert.Count() - m_cursors.Last().m1; | |||||
int ilen = (int)m_indices.Count() - m_cursors.Last().m2; | |||||
int vlen = m_vert.count() - m_cursors.last().m1; | |||||
int ilen = m_indices.count() - m_cursors.last().m2; | |||||
/* Step 1: enumerate all faces. This is done by merging triangles | /* Step 1: enumerate all faces. This is done by merging triangles | ||||
* that are coplanar and share an edge. */ | * that are coplanar and share an edge. */ | ||||
@@ -334,10 +331,10 @@ void EasyMesh::SplitTriangles(int pass, VertexDictionnary *vert_dict) | |||||
{ | { | ||||
while (pass--) | while (pass--) | ||||
{ | { | ||||
int trimax = (int)m_indices.Count(); | |||||
for (int i = m_cursors.Last().m2; i < trimax; i += 3) | |||||
int trimax = m_indices.count(); | |||||
for (int i = m_cursors.last().m2; i < trimax; i += 3) | |||||
{ | { | ||||
int vbase = (int)m_vert.Count(); | |||||
int vbase = m_vert.count(); | |||||
int j = -1; | int j = -1; | ||||
while (++j < 3) | while (++j < 3) | ||||
{ | { | ||||
@@ -354,7 +351,7 @@ void EasyMesh::SplitTriangles(int pass, VertexDictionnary *vert_dict) | |||||
m_indices[i + 2] = vbase + 2; | m_indices[i + 2] = vbase + 2; | ||||
} | } | ||||
} | } | ||||
ComputeNormals(m_cursors.Last().m2, (int)m_indices.Count() - m_cursors.Last().m2); | |||||
ComputeNormals(m_cursors.last().m2, m_indices.count() - m_cursors.last().m2); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -376,7 +373,7 @@ void EasyMesh::SmoothMesh(int main_pass, int split_per_main_pass, int smooth_per | |||||
array<int> connected_vert; | array<int> connected_vert; | ||||
int smbuf = 0; | int smbuf = 0; | ||||
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) | |||||
for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | |||||
vert_dict.RegisterVertex(i, m_vert[i].m_coord); | vert_dict.RegisterVertex(i, m_vert[i].m_coord); | ||||
while (main_pass--) | while (main_pass--) | ||||
@@ -386,53 +383,53 @@ void EasyMesh::SmoothMesh(int main_pass, int split_per_main_pass, int smooth_per | |||||
SplitTriangles(split_pass, &vert_dict); | SplitTriangles(split_pass, &vert_dict); | ||||
matching_ids.Reserve(m_vert.Count() - m_cursors.Last().m1); | |||||
connected_vert.Reserve(m_vert.Count() - m_cursors.Last().m1); | |||||
smooth_buf[0].Resize(m_vert.Count() - m_cursors.Last().m1); | |||||
smooth_buf[1].Resize(m_vert.Count() - m_cursors.Last().m1); | |||||
matching_ids.reserve(m_vert.count() - m_cursors.last().m1); | |||||
connected_vert.reserve(m_vert.count() - m_cursors.last().m1); | |||||
smooth_buf[0].resize(m_vert.count() - m_cursors.last().m1); | |||||
smooth_buf[1].resize(m_vert.count() - m_cursors.last().m1); | |||||
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) | |||||
smooth_buf[smbuf][i - m_cursors.Last().m1] = m_vert[i].m_coord; | |||||
for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | |||||
smooth_buf[smbuf][i - m_cursors.last().m1] = m_vert[i].m_coord; | |||||
while (smooth_pass--) | while (smooth_pass--) | ||||
{ | { | ||||
master_list.Empty(); | |||||
master_list.empty(); | |||||
if (vert_dict.GetMasterList(master_list)) | if (vert_dict.GetMasterList(master_list)) | ||||
{ | { | ||||
for (int i = 0; i < master_list.Count(); i++) | |||||
for (int i = 0; i < master_list.count(); i++) | |||||
{ | { | ||||
connected_vert.Empty(); | |||||
if (vert_dict.FindConnectedVertices(master_list[i], m_indices, m_cursors.Last().m2, connected_vert)) | |||||
connected_vert.empty(); | |||||
if (vert_dict.FindConnectedVertices(master_list[i], m_indices, m_cursors.last().m2, connected_vert)) | |||||
{ | { | ||||
//Calculate vertices sum | //Calculate vertices sum | ||||
vec3 vert_sum = vec3(.0f); | vec3 vert_sum = vec3(.0f); | ||||
for (int j = 0; j < connected_vert.Count(); j++) | |||||
vert_sum += smooth_buf[smbuf][connected_vert[j] - m_cursors.Last().m1]; | |||||
for (int j = 0; j < connected_vert.count(); j++) | |||||
vert_sum += smooth_buf[smbuf][connected_vert[j] - m_cursors.last().m1]; | |||||
//Calculate new master vertex | //Calculate new master vertex | ||||
float n = (float)connected_vert.Count(); | |||||
float n = (float)connected_vert.count(); | |||||
//b(n) = 5/4 - pow(3 + 2 * cos(2.f * F_PI / n), 2) / 32 | //b(n) = 5/4 - pow(3 + 2 * cos(2.f * F_PI / n), 2) / 32 | ||||
float beta = 3.f + 2.f * cos(2.f * F_PI / n); | float beta = 3.f + 2.f * cos(2.f * F_PI / n); | ||||
beta = 5.f / 4.f - beta * beta / 32.f; | beta = 5.f / 4.f - beta * beta / 32.f; | ||||
//a(n) = n * (1 - b(n)) / b(n) | //a(n) = n * (1 - b(n)) / b(n) | ||||
float alpha = (n * (1 - beta)) / beta; | float alpha = (n * (1 - beta)) / beta; | ||||
//V = (a(n) * v + v1 + ... + vn) / (a(n) + n) | //V = (a(n) * v + v1 + ... + vn) / (a(n) + n) | ||||
vec3 new_vert = (alpha * smooth_buf[smbuf][master_list[i] - m_cursors.Last().m1] + vert_sum) / (alpha + n); | |||||
vec3 new_vert = (alpha * smooth_buf[smbuf][master_list[i] - m_cursors.last().m1] + vert_sum) / (alpha + n); | |||||
//Set all matching vertices to new value | //Set all matching vertices to new value | ||||
matching_ids.Empty(); | |||||
matching_ids.empty(); | |||||
matching_ids << master_list[i]; | matching_ids << master_list[i]; | ||||
vert_dict.FindMatchingVertices(master_list[i], matching_ids); | vert_dict.FindMatchingVertices(master_list[i], matching_ids); | ||||
for (int j = 0; j < matching_ids.Count(); j++) | |||||
smooth_buf[1 - smbuf][matching_ids[j] - m_cursors.Last().m1] = new_vert; | |||||
for (int j = 0; j < matching_ids.count(); j++) | |||||
smooth_buf[1 - smbuf][matching_ids[j] - m_cursors.last().m1] = new_vert; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
smbuf = 1 - smbuf; | smbuf = 1 - smbuf; | ||||
} | } | ||||
for (int i = 0; i < smooth_buf[smbuf].Count(); i++) | |||||
m_vert[i + m_cursors.Last().m1].m_coord = smooth_buf[smbuf][i]; | |||||
for (int i = 0; i < smooth_buf[smbuf].count(); i++) | |||||
m_vert[i + m_cursors.last().m1].m_coord = smooth_buf[smbuf][i]; | |||||
} | } | ||||
} | } | ||||
@@ -234,14 +234,17 @@ void Renderer::AddNew(ivec2 size) | |||||
{ | { | ||||
g_renderers << new Renderer(size); | g_renderers << new Renderer(size); | ||||
} | } | ||||
ptrdiff_t Renderer::GetCount() | |||||
int Renderer::GetCount() | |||||
{ | { | ||||
return g_renderers.count(); | return g_renderers.count(); | ||||
} | } | ||||
Renderer* Renderer::Get(ptrdiff_t index) | |||||
Renderer* Renderer::Get(int index) | |||||
{ | { | ||||
return g_renderers[index]; | return g_renderers[index]; | ||||
} | } | ||||
void Renderer::DestroyAll() | void Renderer::DestroyAll() | ||||
{ | { | ||||
for (Renderer* renderer : g_renderers) | for (Renderer* renderer : g_renderers) | ||||
@@ -404,8 +404,8 @@ Shader::Shader(String const &name, | |||||
VertexUsage usage = VertexUsage::MAX; | VertexUsage usage = VertexUsage::MAX; | ||||
for (int j = 0; j < (int)VertexUsage::MAX; ++j) | for (int j = 0; j < (int)VertexUsage::MAX; ++j) | ||||
{ | { | ||||
if (name.StartsWith(attribute_names[j]) || | |||||
name.StartsWith(String(attribute_names[j]).ToLower())) | |||||
if (name.starts_with(attribute_names[j]) || | |||||
name.starts_with(String(attribute_names[j]).to_lower())) | |||||
{ | { | ||||
usage = VertexUsage(j); | usage = VertexUsage(j); | ||||
char* idx_ptr = name.C() + strlen(attribute_names[j]); | char* idx_ptr = name.C() + strlen(attribute_names[j]); | ||||
@@ -442,7 +442,7 @@ Shader::Shader(String const &name, | |||||
int Shader::GetAttribCount() const | int Shader::GetAttribCount() const | ||||
{ | { | ||||
return (int)data->attrib_locations.count(); | |||||
return data->attrib_locations.count(); | |||||
} | } | ||||
ShaderAttrib Shader::GetAttribLocation(VertexUsage usage, int index) const | ShaderAttrib Shader::GetAttribLocation(VertexUsage usage, int index) const | ||||
@@ -657,12 +657,12 @@ void Shader::SetUniform(ShaderUniform const &uni, array<float> const &v) | |||||
* it's a bunch of floats instead of vec4. */ | * it's a bunch of floats instead of vec4. */ | ||||
if (uni.flags & 1) | if (uni.flags & 1) | ||||
data->m_dev->SetPixelShaderConstantF((UINT)uni.frag, | data->m_dev->SetPixelShaderConstantF((UINT)uni.frag, | ||||
&v[0], v.Count() / 4); | |||||
&v[0], v.count() / 4); | |||||
if (uni.flags & 2) | if (uni.flags & 2) | ||||
data->m_dev->SetVertexShaderConstantF((UINT)uni.vert, | data->m_dev->SetVertexShaderConstantF((UINT)uni.vert, | ||||
&v[0], v.Count() / 4); | |||||
&v[0], v.count() / 4); | |||||
#else | #else | ||||
glUniform1fv((GLint)uni.frag, (GLsizei)v.Count(), &v[0]); | |||||
glUniform1fv((GLint)uni.frag, (GLsizei)v.count(), &v[0]); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -673,12 +673,12 @@ void Shader::SetUniform(ShaderUniform const &uni, array<vec2> const &v) | |||||
* it's a bunch of vec2 instead of vec4. */ | * it's a bunch of vec2 instead of vec4. */ | ||||
if (uni.flags & 1) | if (uni.flags & 1) | ||||
data->m_dev->SetPixelShaderConstantF((UINT)uni.frag, | data->m_dev->SetPixelShaderConstantF((UINT)uni.frag, | ||||
&v[0][0], v.Count() / 2); | |||||
&v[0][0], v.count() / 2); | |||||
if (uni.flags & 2) | if (uni.flags & 2) | ||||
data->m_dev->SetVertexShaderConstantF((UINT)uni.vert, | data->m_dev->SetVertexShaderConstantF((UINT)uni.vert, | ||||
&v[0][0], v.Count() / 2); | |||||
&v[0][0], v.count() / 2); | |||||
#else | #else | ||||
glUniform2fv((GLint)uni.frag, (GLsizei)v.Count(), &v[0][0]); | |||||
glUniform2fv((GLint)uni.frag, (GLsizei)v.count(), &v[0][0]); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -689,12 +689,12 @@ void Shader::SetUniform(ShaderUniform const &uni, array<vec3> const &v) | |||||
* it's a bunch of vec3 instead of vec4. */ | * it's a bunch of vec3 instead of vec4. */ | ||||
if (uni.flags & 1) | if (uni.flags & 1) | ||||
data->m_dev->SetPixelShaderConstantF((UINT)uni.frag, | data->m_dev->SetPixelShaderConstantF((UINT)uni.frag, | ||||
&v[0][0], v.Count()); | |||||
&v[0][0], v.count()); | |||||
if (uni.flags & 2) | if (uni.flags & 2) | ||||
data->m_dev->SetVertexShaderConstantF((UINT)uni.vert, | data->m_dev->SetVertexShaderConstantF((UINT)uni.vert, | ||||
&v[0][0], v.Count()); | |||||
&v[0][0], v.count()); | |||||
#else | #else | ||||
glUniform3fv((GLint)uni.frag, (GLsizei)v.Count(), &v[0][0]); | |||||
glUniform3fv((GLint)uni.frag, (GLsizei)v.count(), &v[0][0]); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -703,12 +703,12 @@ void Shader::SetUniform(ShaderUniform const &uni, array<vec4> const &v) | |||||
#if defined USE_D3D9 || defined _XBOX | #if defined USE_D3D9 || defined _XBOX | ||||
if (uni.flags & 1) | if (uni.flags & 1) | ||||
data->m_dev->SetPixelShaderConstantF((UINT)uni.frag, | data->m_dev->SetPixelShaderConstantF((UINT)uni.frag, | ||||
&v[0][0], v.Count()); | |||||
&v[0][0], v.count()); | |||||
if (uni.flags & 2) | if (uni.flags & 2) | ||||
data->m_dev->SetVertexShaderConstantF((UINT)uni.vert, | data->m_dev->SetVertexShaderConstantF((UINT)uni.vert, | ||||
&v[0][0], v.Count()); | |||||
&v[0][0], v.count()); | |||||
#else | #else | ||||
glUniform4fv((GLint)uni.frag, (GLsizei)v.Count(), &v[0][0]); | |||||
glUniform4fv((GLint)uni.frag, (GLsizei)v.count(), &v[0][0]); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -838,7 +838,7 @@ String ShaderData::Patch(String const &code, ShaderType type) | |||||
if (ver_shader > 120 && ver_driver <= 120) | if (ver_shader > 120 && ver_driver <= 120) | ||||
{ | { | ||||
char const *end = patched_code.C() + patched_code.Count() + 1; | |||||
char const *end = patched_code.C() + patched_code.count() + 1; | |||||
/* Find main() */ | /* Find main() */ | ||||
parser = strstr(patched_code.C(), "main"); | parser = strstr(patched_code.C(), "main"); | ||||
@@ -932,7 +932,7 @@ String ShaderData::Patch(String const &code, ShaderType type) | |||||
} | } | ||||
} | } | ||||
patched_code.Resize(strlen(patched_code.C())); | |||||
patched_code.resize(strlen(patched_code.C())); | |||||
return patched_code; | return patched_code; | ||||
} | } | ||||
@@ -1074,7 +1074,7 @@ void ShaderBlock::AddCallParameters(map<String, String> const& variables, String | |||||
array<String> keys = variables.keys(); | array<String> keys = variables.keys(); | ||||
for (String key : keys) | for (String key : keys) | ||||
{ | { | ||||
if (result.Count() > 0) | |||||
if (result.count() > 0) | |||||
result += ", "; | result += ", "; | ||||
result += key; | result += key; | ||||
} | } | ||||
@@ -1086,7 +1086,7 @@ void ShaderBlock::AddDefinitionParameters(const ShaderVariable type, const Shade | |||||
array<String> keys = variables.keys(); | array<String> keys = variables.keys(); | ||||
for (String key : keys) | for (String key : keys) | ||||
{ | { | ||||
if (result.Count() > 0) | |||||
if (result.count() > 0) | |||||
result += ", "; | result += ", "; | ||||
result += Shader::GetFunctionQualifier(type, program) + " "; | result += Shader::GetFunctionQualifier(type, program) + " "; | ||||
result += variables[key]; | result += variables[key]; | ||||
@@ -1098,7 +1098,7 @@ void ShaderBlock::AddDefinitionParameters(const ShaderVariable type, const Shade | |||||
//---- | //---- | ||||
void ShaderBlock::Build(const ShaderProgram program, String& call, String& function) | void ShaderBlock::Build(const ShaderProgram program, String& call, String& function) | ||||
{ | { | ||||
ASSERT(m_name.Count()); | |||||
ASSERT(m_name.count()); | |||||
ASSERT(m_parameters[ShaderVariable::InOut].count()); | ASSERT(m_parameters[ShaderVariable::InOut].count()); | ||||
//Build call in main | //Build call in main | ||||
@@ -1116,7 +1116,7 @@ void ShaderBlock::Build(const ShaderProgram program, String& call, String& funct | |||||
AddDefinitionParameters((ShaderVariable)i, program, m_parameters[i], def_parameters); | AddDefinitionParameters((ShaderVariable)i, program, m_parameters[i], def_parameters); | ||||
function += def_parameters + ")" + g_ret + | function += def_parameters + ")" + g_ret + | ||||
"{" + g_ret + | "{" + g_ret + | ||||
m_code_main + ((m_code_main.EndsWith(g_ret)) ? (String()) : (g_ret)) + | |||||
m_code_main + ((m_code_main.ends_with(g_ret)) ? (String()) : (g_ret)) + | |||||
"}"; | "}"; | ||||
} | } | ||||
@@ -1124,8 +1124,8 @@ void ShaderBlock::Build(const ShaderProgram program, String& call, String& funct | |||||
ShaderBuilder::ShaderBuilder(String const& name, String const& version) | ShaderBuilder::ShaderBuilder(String const& name, String const& version) | ||||
: m_name(name), m_version(version) | : m_name(name), m_version(version) | ||||
{ | { | ||||
ASSERT(name.Count()); | |||||
ASSERT(version.Count()); | |||||
ASSERT(name.count()); | |||||
ASSERT(version.count()); | |||||
} | } | ||||
//---- | //---- | ||||
@@ -1150,7 +1150,7 @@ ShaderBuilder& ShaderBuilder::operator<<(const ShaderProgram program) | |||||
ShaderBuilder& ShaderBuilder::operator<<(ShaderBlock* block) | ShaderBuilder& ShaderBuilder::operator<<(ShaderBlock* block) | ||||
{ | { | ||||
ASSERT(m_current_program != ShaderProgram::MAX); | ASSERT(m_current_program != ShaderProgram::MAX); | ||||
m_blocks[m_current_program.ToScalar()].PushUnique(block); | |||||
m_blocks[m_current_program.ToScalar()].push_unique(block); | |||||
return *this; | return *this; | ||||
} | } | ||||
@@ -1158,7 +1158,7 @@ ShaderBuilder& ShaderBuilder::operator<<(ShaderBlock* block) | |||||
ShaderBuilder& ShaderBuilder::operator<<(ShaderBlock const& block) | ShaderBuilder& ShaderBuilder::operator<<(ShaderBlock const& block) | ||||
{ | { | ||||
ASSERT(m_current_program != ShaderProgram::MAX); | ASSERT(m_current_program != ShaderProgram::MAX); | ||||
m_blocks[m_current_program.ToScalar()].PushUnique(new ShaderBlock(block)); | |||||
m_blocks[m_current_program.ToScalar()].push_unique(new ShaderBlock(block)); | |||||
return *this; | return *this; | ||||
} | } | ||||
@@ -1225,12 +1225,12 @@ void ShaderBuilder::Build(String& code) | |||||
//Add default local out in merged variables | //Add default local out in merged variables | ||||
String out_local_var = AddSlotOutVariableLocal((ShaderProgram)prog); | String out_local_var = AddSlotOutVariableLocal((ShaderProgram)prog); | ||||
if (!out_local_var.Count()) | |||||
if (!out_local_var.count()) | |||||
continue; | continue; | ||||
//Merge all variables | //Merge all variables | ||||
for (int var = 0; var < ShaderVariable::MAX; var++) | for (int var = 0; var < ShaderVariable::MAX; var++) | ||||
for (int block = 0; block < m_blocks[prog].Count(); block++) | |||||
for (int block = 0; block < m_blocks[prog].count(); block++) | |||||
MergeParameters(m_blocks[prog][block]->m_parameters[var], m_parameters[prog][var]); | MergeParameters(m_blocks[prog][block]->m_parameters[var], m_parameters[prog][var]); | ||||
//Actually write code | //Actually write code | ||||
@@ -1243,7 +1243,7 @@ void ShaderBuilder::Build(String& code) | |||||
for (int var = 0; var < ShaderVariable::InOut; var++) | for (int var = 0; var < ShaderVariable::InOut; var++) | ||||
{ | { | ||||
array<String> keys = m_parameters[prog][var].keys(); | array<String> keys = m_parameters[prog][var].keys(); | ||||
if (keys.Count()) | |||||
if (keys.count()) | |||||
{ | { | ||||
code += String("//- ") + Shader::GetVariableQualifier((ShaderVariable)var) + " ----" + g_ret; | code += String("//- ") + Shader::GetVariableQualifier((ShaderVariable)var) + " ----" + g_ret; | ||||
for (String key : keys) | for (String key : keys) | ||||
@@ -1259,13 +1259,13 @@ void ShaderBuilder::Build(String& code) | |||||
//Build Blocks code and add it | //Build Blocks code and add it | ||||
array<String> calls; | array<String> calls; | ||||
for (int block = 0; block < m_blocks[prog].Count(); block++) | |||||
for (int block = 0; block < m_blocks[prog].count(); block++) | |||||
{ | { | ||||
String call; | String call; | ||||
String function; | String function; | ||||
m_blocks[prog][block]->Build(ShaderProgram(prog), call, function); | m_blocks[prog][block]->Build(ShaderProgram(prog), call, function); | ||||
calls << call; | calls << call; | ||||
if (m_blocks[prog][block]->m_code_custom.Count()) | |||||
if (m_blocks[prog][block]->m_code_custom.count()) | |||||
{ | { | ||||
code += String("//- ") + m_blocks[prog][block]->GetName() + " custom code ----" + g_ret; | code += String("//- ") + m_blocks[prog][block]->GetName() + " custom code ----" + g_ret; | ||||
code += m_blocks[prog][block]->m_code_custom + g_ret + g_ret; | code += m_blocks[prog][block]->m_code_custom + g_ret + g_ret; | ||||
@@ -1283,7 +1283,7 @@ void ShaderBuilder::Build(String& code) | |||||
array<String> keys = m_parameters[prog][var].keys(); | array<String> keys = m_parameters[prog][var].keys(); | ||||
for (String key : keys) | for (String key : keys) | ||||
{ | { | ||||
if (keys.Count()) | |||||
if (keys.count()) | |||||
{ | { | ||||
code += g_tab + m_parameters[prog][var][key] + " " + key + ";" + g_ret; | code += g_tab + m_parameters[prog][var][key] + " " + key + ";" + g_ret; | ||||
} | } | ||||
@@ -43,10 +43,9 @@ bool Imlib2ImageCodec::Load(Image *image, char const *path) | |||||
{ | { | ||||
Imlib_Image im = nullptr; | Imlib_Image im = nullptr; | ||||
array<String> pathlist = System::GetPathList(path); | |||||
for (int i = 0; i < pathlist.Count(); i++) | |||||
for (auto candidate : System::GetPathList(path)) | |||||
{ | { | ||||
im = imlib_load_image(pathlist[i].C()); | |||||
im = imlib_load_image(candidate.C()); | |||||
if (im) | if (im) | ||||
break; | break; | ||||
} | } | ||||
@@ -60,10 +60,10 @@ bool OricImageCodec::Load(Image *image, char const *path) | |||||
}; | }; | ||||
String screen = ReadScreen(path); | String screen = ReadScreen(path); | ||||
if (screen.Count() == 0) | |||||
if (screen.count() == 0) | |||||
return false; | return false; | ||||
image->SetSize(ivec2(WIDTH, screen.Count() * 6 / WIDTH)); | |||||
image->SetSize(ivec2(WIDTH, screen.count() * 6 / WIDTH)); | |||||
u8vec4 *pixels = image->Lock<PixelFormat::RGBA_8>(); | u8vec4 *pixels = image->Lock<PixelFormat::RGBA_8>(); | ||||
@@ -162,17 +162,17 @@ String OricImageCodec::ReadScreen(char const *name) | |||||
++header; | ++header; | ||||
/* Skip the header, ignoring the last byte’s value */ | /* Skip the header, ignoring the last byte’s value */ | ||||
if (data.Sub(header, 8) != String("\x00\xff\x80\x00\xbf\x3f\xa0\x00", 8)) | |||||
if (data.sub(header, 8) != String("\x00\xff\x80\x00\xbf\x3f\xa0\x00", 8)) | |||||
return ""; | return ""; | ||||
/* Skip the file name, including trailing nul char */ | /* Skip the file name, including trailing nul char */ | ||||
data = data.Sub(header + 8); | |||||
int filename_end = data.IndexOf('\0'); | |||||
data = data.sub(header + 8); | |||||
int filename_end = data.index_of('\0'); | |||||
if (filename_end < 0) | if (filename_end < 0) | ||||
return ""; | return ""; | ||||
/* Read screen data */ | /* Read screen data */ | ||||
return data.Sub(filename_end + 1); | |||||
return data.sub(filename_end + 1); | |||||
} | } | ||||
/* Error diffusion table, similar to Floyd-Steinberg. I choose not to | /* Error diffusion table, similar to Floyd-Steinberg. I choose not to | ||||
@@ -471,8 +471,8 @@ void OricImageCodec::WriteScreen(Image &image, array<uint8_t> &result) | |||||
int stride = (size.x + 1); | int stride = (size.x + 1); | ||||
array2d<ivec3> src, dst; | array2d<ivec3> src, dst; | ||||
src.SetSize(size + ivec2(1)); | |||||
dst.SetSize(size + ivec2(1)); | |||||
src.resize(size + ivec2(1)); | |||||
dst.resize(size + ivec2(1)); | |||||
memset(src.data(), 0, src.bytes()); | memset(src.data(), 0, src.bytes()); | ||||
memset(dst.data(), 0, dst.bytes()); | memset(dst.data(), 0, dst.bytes()); | ||||
@@ -48,10 +48,9 @@ bool SdlImageCodec::Load(Image *image, char const *path) | |||||
{ | { | ||||
SDL_Surface *surface = nullptr; | SDL_Surface *surface = nullptr; | ||||
array<String> pathlist = System::GetPathList(path); | |||||
for (int i = 0; i < pathlist.Count(); i++) | |||||
for (auto candidate : System::GetPathList(path)) | |||||
{ | { | ||||
surface = IMG_Load(pathlist[i].C()); | |||||
surface = IMG_Load(candidate.C()); | |||||
if (surface) | if (surface) | ||||
break; | break; | ||||
} | } | ||||
@@ -29,9 +29,9 @@ public: | |||||
virtual bool RetrieveTiles(array<ivec2, ivec2>& tiles) | virtual bool RetrieveTiles(array<ivec2, ivec2>& tiles) | ||||
{ | { | ||||
bool result = m_tiles.Count() > 0; | |||||
bool result = m_tiles.count() > 0; | |||||
tiles += m_tiles; | tiles += m_tiles; | ||||
m_tiles.Empty(); | |||||
m_tiles.empty(); | |||||
return result; | return result; | ||||
} | } | ||||
@@ -48,7 +48,7 @@ DECLARE_IMAGE_CODEC(ZedImageCodec, 10) | |||||
bool ZedImageCodec::Load(Image *image, char const *path) | bool ZedImageCodec::Load(Image *image, char const *path) | ||||
{ | { | ||||
if (!lol::String(path).EndsWith(".RSC")) | |||||
if (!lol::String(path).ends_with(".RSC")) | |||||
return false; | return false; | ||||
// Compacter definition | // Compacter definition | ||||
@@ -73,7 +73,7 @@ bool ZedImageCodec::Load(Image *image, char const *path) | |||||
{ | { | ||||
m_primary << CompactMain(start << i); | m_primary << CompactMain(start << i); | ||||
for (int j = 0; j < count; j++) | for (int j = 0; j < count; j++) | ||||
m_primary.Last().m_secondary << CompactSecondary(start << j); | |||||
m_primary.last().m_secondary << CompactSecondary(start << j); | |||||
} | } | ||||
} | } | ||||
void StepSetup(int32_t start, int32_t interval, int32_t count) | void StepSetup(int32_t start, int32_t interval, int32_t count) | ||||
@@ -82,27 +82,27 @@ bool ZedImageCodec::Load(Image *image, char const *path) | |||||
{ | { | ||||
m_primary << CompactMain(start + interval * i); | m_primary << CompactMain(start + interval * i); | ||||
for (int j = 0; j < count; j++) | for (int j = 0; j < count; j++) | ||||
m_primary.Last().m_secondary << CompactSecondary(start + interval * j); | |||||
m_primary.last().m_secondary << CompactSecondary(start + interval * j); | |||||
} | } | ||||
} | } | ||||
void CustomSetup(array<int32_t> custom_list) | void CustomSetup(array<int32_t> custom_list) | ||||
{ | { | ||||
for (int i = 0; i < custom_list.Count(); i++) | |||||
for (int i = 0; i < custom_list.count(); i++) | |||||
{ | { | ||||
m_primary << CompactMain(custom_list[i]); | m_primary << CompactMain(custom_list[i]); | ||||
for (int j = 0; j < custom_list.Count(); j++) | |||||
m_primary.Last().m_secondary << CompactSecondary(custom_list[j]); | |||||
for (int j = 0; j < custom_list.count(); j++) | |||||
m_primary.last().m_secondary << CompactSecondary(custom_list[j]); | |||||
} | } | ||||
} | } | ||||
void Store(int32_t tile, ivec2 size) | void Store(int32_t tile, ivec2 size) | ||||
{ | { | ||||
for (int i = 0; i < m_primary.Count(); i++) | |||||
for (int i = 0; i < m_primary.count(); i++) | |||||
{ | { | ||||
if (size.y <= m_primary[i].m_size || i == m_primary.Count() - 1) | |||||
if (size.y <= m_primary[i].m_size || i == m_primary.count() - 1) | |||||
{ | { | ||||
for (int j = 0; j < m_primary[i].m_secondary.Count(); j++) | |||||
for (int j = 0; j < m_primary[i].m_secondary.count(); j++) | |||||
{ | { | ||||
if (size.x <= m_primary[i].m_secondary[j].m_size || j == m_primary[i].m_secondary.Count() - 1) | |||||
if (size.x <= m_primary[i].m_secondary[j].m_size || j == m_primary[i].m_secondary.count() - 1) | |||||
{ | { | ||||
m_primary[i].m_secondary[j].m_tiles << tile; | m_primary[i].m_secondary[j].m_tiles << tile; | ||||
m_primary[i].m_count++; | m_primary[i].m_count++; | ||||
@@ -122,7 +122,7 @@ bool ZedImageCodec::Load(Image *image, char const *path) | |||||
//Put file in memory | //Put file in memory | ||||
long file_size = file.GetSize(); | long file_size = file.GetSize(); | ||||
array<uint8_t> file_buffer; | array<uint8_t> file_buffer; | ||||
file_buffer.Resize(file_size); | |||||
file_buffer.resize(file_size); | |||||
file.Read((uint8_t*)&file_buffer[0], file_size); | file.Read((uint8_t*)&file_buffer[0], file_size); | ||||
file.Close(); | file.Close(); | ||||
@@ -132,24 +132,24 @@ bool ZedImageCodec::Load(Image *image, char const *path) | |||||
file_count = *((uint16_t*)(&file_buffer[file_pos])); | file_count = *((uint16_t*)(&file_buffer[file_pos])); | ||||
file_pos += sizeof(uint16_t); | file_pos += sizeof(uint16_t); | ||||
array<long int> file_offset; | |||||
file_offset.Resize(file_count); | |||||
array<uint32_t> file_offset; | |||||
file_offset.resize(file_count); | |||||
//Get all the file offsets | //Get all the file offsets | ||||
for (int i = 0; i < file_count; i++) | for (int i = 0; i < file_count; i++) | ||||
{ | { | ||||
file_offset[i] = *((long int*)(&file_buffer[file_pos])); | |||||
file_pos += sizeof(long int); | |||||
file_offset[i] = *((uint32_t*)(&file_buffer[file_pos])); | |||||
file_pos += sizeof(uint32_t); | |||||
} | } | ||||
file_offset << file_size; | file_offset << file_size; | ||||
m_tiles.Reserve(file_count); | |||||
m_tiles.reserve(file_count); | |||||
Compacter2d compacter; | Compacter2d compacter; | ||||
compacter.StepSetup(8, 8, 10); | compacter.StepSetup(8, 8, 10); | ||||
uint32_t total_size = 0; | uint32_t total_size = 0; | ||||
array<uint8_t> file_convert; | array<uint8_t> file_convert; | ||||
file_convert.Reserve(file_size); | |||||
file_convert.reserve(file_size); | |||||
array<ivec2> available_sizes; | array<ivec2> available_sizes; | ||||
for (int i = 0; i < file_count; i++) | for (int i = 0; i < file_count; i++) | ||||
{ | { | ||||
@@ -173,23 +173,23 @@ bool ZedImageCodec::Load(Image *image, char const *path) | |||||
/* Seems useless in the end | /* Seems useless in the end | ||||
//Retrieve Header & footer | //Retrieve Header & footer | ||||
array<uint8_t> header_data; | array<uint8_t> header_data; | ||||
header_data.Resize(header_length); | |||||
header_data.resize(header_length); | |||||
memcpy(&header_data[0], &file_buffer[file_offset[i]], header_length); | memcpy(&header_data[0], &file_buffer[file_offset[i]], header_length); | ||||
array<uint8_t> footer_data; | array<uint8_t> footer_data; | ||||
uint32_t footer_length = lol::min((uint32_t)file_buffer.Count(), data_pos + data_length + header_length) - (data_pos + data_length); | |||||
uint32_t footer_length = lol::min((uint32_t)file_buffer.count(), data_pos + data_length + header_length) - (data_pos + data_length); | |||||
if (footer_length > 0) | if (footer_length > 0) | ||||
{ | { | ||||
footer_data.Resize(footer_length); | |||||
footer_data.resize(footer_length); | |||||
memcpy(&footer_data[0], &file_buffer[data_pos + data_length], footer_length); | memcpy(&footer_data[0], &file_buffer[data_pos + data_length], footer_length); | ||||
} | } | ||||
*/ | */ | ||||
//Prepare buffer and tiles infos | //Prepare buffer and tiles infos | ||||
int32_t convert_pos = file_convert.Count(); | |||||
int32_t convert_pos = file_convert.count(); | |||||
ivec2 size = ivec2(size_x, size_y); | ivec2 size = ivec2(size_x, size_y); | ||||
compacter.Store(m_tiles.Count(), ivec2(size_x, size_y)); | |||||
m_tiles.Push(ivec2(file_convert.Count(), data_length), ivec2(size_x, size_y)); | |||||
file_convert.Resize(convert_pos + data_length); | |||||
compacter.Store(m_tiles.count(), ivec2(size_x, size_y)); | |||||
m_tiles.push(ivec2(file_convert.count(), data_length), ivec2(size_x, size_y)); | |||||
file_convert.resize(convert_pos + data_length); | |||||
//Retrieve actual datas | //Retrieve actual datas | ||||
file_pos = data_pos; | file_pos = data_pos; | ||||
@@ -220,10 +220,10 @@ bool ZedImageCodec::Load(Image *image, char const *path) | |||||
s_16 <<= 1; | s_16 <<= 1; | ||||
} | } | ||||
int j = 0; | int j = 0; | ||||
for (; j < available_sizes.Count(); j++) | |||||
for (; j < available_sizes.count(); j++) | |||||
if (available_sizes[j] == size_16) | if (available_sizes[j] == size_16) | ||||
break; | break; | ||||
if (j >= available_sizes.Count()) | |||||
if (j >= available_sizes.count()) | |||||
available_sizes << size_16; | available_sizes << size_16; | ||||
} | } | ||||
} | } | ||||
@@ -239,22 +239,22 @@ bool ZedImageCodec::Load(Image *image, char const *path) | |||||
//Data refactor stage | //Data refactor stage | ||||
ivec2 pos = ivec2(0); | ivec2 pos = ivec2(0); | ||||
for (int j = compacter.m_primary.Count() - 1; j >= 0; j--) | |||||
for (int j = compacter.m_primary.count() - 1; j >= 0; j--) | |||||
{ | { | ||||
for (int k = compacter.m_primary[j].m_secondary.Count() - 1; k >= 0; k--) | |||||
for (int k = compacter.m_primary[j].m_secondary.count() - 1; k >= 0; k--) | |||||
{ | { | ||||
//Try something smaller | //Try something smaller | ||||
if (pos.x + compacter.m_primary[j].m_secondary[k].m_size >= tex_size) | if (pos.x + compacter.m_primary[j].m_secondary[k].m_size >= tex_size) | ||||
continue; | continue; | ||||
while (compacter.m_primary[j].m_secondary[k].m_tiles.Count() > 0) | |||||
while (compacter.m_primary[j].m_secondary[k].m_tiles.count() > 0) | |||||
{ | { | ||||
//Try something smaller | //Try something smaller | ||||
if (pos.x + compacter.m_primary[j].m_secondary[k].m_size >= tex_size) | if (pos.x + compacter.m_primary[j].m_secondary[k].m_size >= tex_size) | ||||
break; | break; | ||||
compacter.m_primary[j].m_count--; | compacter.m_primary[j].m_count--; | ||||
int i = compacter.m_primary[j].m_secondary[k].m_tiles.Pop(); | |||||
int i = compacter.m_primary[j].m_secondary[k].m_tiles.pop(); | |||||
int32_t file_off = m_tiles[i].m1[0]; | int32_t file_off = m_tiles[i].m1[0]; | ||||
ivec2 t_size = m_tiles[i].m2; | ivec2 t_size = m_tiles[i].m2; | ||||
@@ -35,7 +35,7 @@ DECLARE_IMAGE_CODEC(ZedPaletteImageCodec, 10) | |||||
bool ZedPaletteImageCodec::Load(Image *image, char const *path) | bool ZedPaletteImageCodec::Load(Image *image, char const *path) | ||||
{ | { | ||||
if (!lol::String(path).EndsWith(".pal")) | |||||
if (!lol::String(path).ends_with(".pal")) | |||||
return false; | return false; | ||||
File file; | File file; | ||||
@@ -44,7 +44,7 @@ bool ZedPaletteImageCodec::Load(Image *image, char const *path) | |||||
//Put file in memory | //Put file in memory | ||||
long file_size = file.GetSize(); | long file_size = file.GetSize(); | ||||
array<uint8_t> file_buffer; | array<uint8_t> file_buffer; | ||||
file_buffer.Resize(file_size); | |||||
file_buffer.resize(file_size); | |||||
file.Read((uint8_t*)&file_buffer[0], file_size); | file.Read((uint8_t*)&file_buffer[0], file_size); | ||||
file.Close(); | file.Close(); | ||||
@@ -63,7 +63,7 @@ bool ZedPaletteImageCodec::Load(Image *image, char const *path) | |||||
#endif | #endif | ||||
u8vec4 *pixels = image->Lock<PixelFormat::RGBA_8>(); | u8vec4 *pixels = image->Lock<PixelFormat::RGBA_8>(); | ||||
for (int i = 0; i < file_buffer.Count();) | |||||
for (int i = 0; i < file_buffer.count();) | |||||
{ | { | ||||
pixels->r = file_buffer[i++]; | pixels->r = file_buffer[i++]; | ||||
pixels->g = file_buffer[i++]; | pixels->g = file_buffer[i++]; | ||||
@@ -34,25 +34,25 @@ vec4 const Color::light_gray = vec4(.75f, .75f, .75f, 1); | |||||
String Color::HexString4Bpp(vec3 c) | String Color::HexString4Bpp(vec3 c) | ||||
{ | { | ||||
uvec3 c2 = (uvec3)(clamp(c, 0.f, 1.f) * 255.999f); | uvec3 c2 = (uvec3)(clamp(c, 0.f, 1.f) * 255.999f); | ||||
return String::Printf("%01x%01x%01x", c2.r, c2.g, c2.b); | |||||
return String::format("%01x%01x%01x", c2.r, c2.g, c2.b); | |||||
} | } | ||||
String Color::HexString4Bpp(vec4 c) | String Color::HexString4Bpp(vec4 c) | ||||
{ | { | ||||
uvec4 c2 = (uvec4)(clamp(c, 0.f, 1.f) * 15.999f); | uvec4 c2 = (uvec4)(clamp(c, 0.f, 1.f) * 15.999f); | ||||
return String::Printf("%01x%1x%01x%01x", c2.r, c2.g, c2.b, c2.a); | |||||
return String::format("%01x%1x%01x%01x", c2.r, c2.g, c2.b, c2.a); | |||||
} | } | ||||
String Color::HexString8Bpp(vec3 c) | String Color::HexString8Bpp(vec3 c) | ||||
{ | { | ||||
uvec3 c2 = (uvec3)(clamp(c, 0.f, 1.f) * 255.999f); | uvec3 c2 = (uvec3)(clamp(c, 0.f, 1.f) * 255.999f); | ||||
return String::Printf("%02x%02x%02x", c2.r, c2.g, c2.b); | |||||
return String::format("%02x%02x%02x", c2.r, c2.g, c2.b); | |||||
} | } | ||||
String Color::HexString8Bpp(vec4 c) | String Color::HexString8Bpp(vec4 c) | ||||
{ | { | ||||
uvec4 c2 = (uvec4)(clamp(c, 0.f, 1.f) * 15.999f); | uvec4 c2 = (uvec4)(clamp(c, 0.f, 1.f) * 15.999f); | ||||
return String::Printf("%02x%2x%02x%02x", c2.r, c2.g, c2.b, c2.a); | |||||
return String::format("%02x%2x%02x%02x", c2.r, c2.g, c2.b, c2.a); | |||||
} | } | ||||
/* | /* | ||||
@@ -111,21 +111,21 @@ vec4 Color::C8BppHexString(String s) | |||||
{ | { | ||||
String c = s[0] == '#' ? &s[1] : s; | String c = s[0] == '#' ? &s[1] : s; | ||||
uint32_t tmp = std::strtol(c.C(), nullptr, 16); | uint32_t tmp = std::strtol(c.C(), nullptr, 16); | ||||
if (c.Count() == 3) | |||||
if (c.count() == 3) | |||||
{ | { | ||||
tmp = 0x11000000u * (tmp >> 8) | tmp = 0x11000000u * (tmp >> 8) | ||||
| 0x00110000u * ((tmp >> 4) & 0xf) | | 0x00110000u * ((tmp >> 4) & 0xf) | ||||
| 0x00001100u * (tmp & 0xf) | | 0x00001100u * (tmp & 0xf) | ||||
| 0x000000ffu; | | 0x000000ffu; | ||||
} | } | ||||
else if (c.Count() == 4) | |||||
else if (c.count() == 4) | |||||
{ | { | ||||
tmp = 0x11000000u * (tmp >> 12) | tmp = 0x11000000u * (tmp >> 12) | ||||
| 0x00110000u * ((tmp >> 8) & 0xf) | | 0x00110000u * ((tmp >> 8) & 0xf) | ||||
| 0x00001100u * ((tmp >> 4) & 0xf) | | 0x00001100u * ((tmp >> 4) & 0xf) | ||||
| 0x00000011u * (tmp & 0xf); | | 0x00000011u * (tmp & 0xf); | ||||
} | } | ||||
else if (c.Count() == 6) | |||||
else if (c.count() == 6) | |||||
{ | { | ||||
tmp = 0xffu | 0x100u * tmp; | tmp = 0xffu | 0x100u * tmp; | ||||
} | } | ||||
@@ -30,7 +30,7 @@ Image Image::DitherDbs() const | |||||
/* Build our human visual system kernel. */ | /* Build our human visual system kernel. */ | ||||
array2d<float> kernel; | array2d<float> kernel; | ||||
kernel.SetSize(ivec2(NN, NN)); | |||||
kernel.resize(ivec2(NN, NN)); | |||||
float t = 0.f; | float t = 0.f; | ||||
for (int j = 0; j < NN; j++) | for (int j = 0; j < NN; j++) | ||||
for (int i = 0; i < NN; i++) | for (int i = 0; i < NN; i++) | ||||
@@ -28,7 +28,7 @@ Image Image::DitherEdiff(array2d<float> const &kernel, ScanMode scan) const | |||||
Image dst = *this; | Image dst = *this; | ||||
ivec2 size = dst.GetSize(); | ivec2 size = dst.GetSize(); | ||||
ivec2 ksize = (ivec2)kernel.GetSize(); | |||||
ivec2 ksize = kernel.size(); | |||||
int kx; | int kx; | ||||
for (kx = 0; kx < ksize.x; kx++) | for (kx = 0; kx < ksize.x; kx++) | ||||
@@ -41,7 +41,7 @@ static Image DitherHelper(Image const &image, array2d<float> const &kernel, | |||||
float scale, float angle) | float scale, float angle) | ||||
{ | { | ||||
ivec2 size = image.GetSize(); | ivec2 size = image.GetSize(); | ||||
ivec2 ksize = (ivec2)kernel.GetSize(); | |||||
ivec2 ksize = kernel.size(); | |||||
float cost = lol::cos(angle); | float cost = lol::cos(angle); | ||||
float sint = lol::sin(angle); | float sint = lol::sin(angle); | ||||
@@ -24,7 +24,7 @@ static Image NonSepConv(Image &src, array2d<float> const &kernel); | |||||
Image Image::Convolution(array2d<float> const &kernel) | Image Image::Convolution(array2d<float> const &kernel) | ||||
{ | { | ||||
/* Find the cell with the largest value */ | /* Find the cell with the largest value */ | ||||
ivec2 ksize = (ivec2)kernel.GetSize(); | |||||
ivec2 ksize = kernel.size(); | |||||
int bestx = -1, besty = -1; | int bestx = -1, besty = -1; | ||||
float tmp = 0.f; | float tmp = 0.f; | ||||
for (int dy = 0; dy < ksize.y; ++dy) | for (int dy = 0; dy < ksize.y; ++dy) | ||||
@@ -81,7 +81,7 @@ Image Image::Convolution(array2d<float> const &kernel) | |||||
Image Image::Sharpen(array2d<float> const &kernel) | Image Image::Sharpen(array2d<float> const &kernel) | ||||
{ | { | ||||
ivec2 ksize = (ivec2)kernel.GetSize(); | |||||
ivec2 ksize = kernel.size(); | |||||
array2d<float> newkernel(ksize); | array2d<float> newkernel(ksize); | ||||
for (int dy = 0; dy < ksize.y; ++dy) | for (int dy = 0; dy < ksize.y; ++dy) | ||||
@@ -101,7 +101,7 @@ static Image NonSepConv(Image &src, array2d<float> const &kernel) | |||||
typedef typename PixelType<FORMAT>::type pixel_t; | typedef typename PixelType<FORMAT>::type pixel_t; | ||||
ivec2 const size = src.GetSize(); | ivec2 const size = src.GetSize(); | ||||
ivec2 const ksize = (ivec2)kernel.GetSize(); | |||||
ivec2 const ksize = kernel.size(); | |||||
Image dst(size); | Image dst(size); | ||||
array2d<pixel_t> const &srcp = src.Lock2D<FORMAT>(); | array2d<pixel_t> const &srcp = src.Lock2D<FORMAT>(); | ||||
@@ -194,7 +194,7 @@ static Image SepConv(Image &src, array<float> const &hvec, | |||||
typedef typename PixelType<FORMAT>::type pixel_t; | typedef typename PixelType<FORMAT>::type pixel_t; | ||||
ivec2 const size = src.GetSize(); | ivec2 const size = src.GetSize(); | ||||
ivec2 const ksize(hvec.Count(), vvec.Count()); | |||||
ivec2 const ksize(hvec.count(), vvec.count()); | |||||
Image dst(size); | Image dst(size); | ||||
array2d<pixel_t> const &srcp = src.Lock2D<FORMAT>(); | array2d<pixel_t> const &srcp = src.Lock2D<FORMAT>(); | ||||
@@ -164,7 +164,7 @@ Image Image::Median(array2d<float> const &kernel) const | |||||
else | else | ||||
#endif | #endif | ||||
{ | { | ||||
ivec2 const ksize = (ivec2)kernel.GetSize(); | |||||
ivec2 const ksize = kernel.size(); | |||||
array2d<vec3> list(ksize); | array2d<vec3> list(ksize); | ||||
vec4 *srcp = tmp.Lock<PixelFormat::RGBA_F32>(); | vec4 *srcp = tmp.Lock<PixelFormat::RGBA_F32>(); | ||||
@@ -33,7 +33,7 @@ template<PixelFormat T> | |||||
class PixelData : public PixelDataBase | class PixelData : public PixelDataBase | ||||
{ | { | ||||
public: | public: | ||||
inline PixelData(ivec2 size) { m_array2d.SetSize(size); } | |||||
inline PixelData(ivec2 size) { m_array2d.resize(size); } | |||||
virtual void *data() { return m_array2d.data(); } | virtual void *data() { return m_array2d.data(); } | ||||
virtual void const *data() const { return m_array2d.data(); } | virtual void const *data() const { return m_array2d.data(); } | ||||
@@ -88,7 +88,7 @@ public: | |||||
if (codeclist[i]->m_priority <= prio) \ | if (codeclist[i]->m_priority <= prio) \ | ||||
break; \ | break; \ | ||||
} \ | } \ | ||||
codeclist.Insert(codec, i); \ | |||||
codeclist.insert(codec, i); \ | |||||
} | } | ||||
#define DECLARE_IMAGE_CODEC(name, priority) \ | #define DECLARE_IMAGE_CODEC(name, priority) \ | ||||
@@ -122,7 +122,7 @@ void Image::DummyFill() | |||||
//TODO: This is not very beautiful | //TODO: This is not very beautiful | ||||
for (auto codec : g_image_loader.m_codecs) | for (auto codec : g_image_loader.m_codecs) | ||||
{ | { | ||||
if (String(codec->GetName()).Contains("Dummy")) | |||||
if (String(codec->GetName()).contains("Dummy")) | |||||
{ | { | ||||
codec->Load(this, nullptr); | codec->Load(this, nullptr); | ||||
return; | return; | ||||
@@ -182,10 +182,10 @@ static int cmpdot(const void *p1, const void *p2) | |||||
array2d<float> Image::NormalizeKernel(array2d<float> const &kernel) | array2d<float> Image::NormalizeKernel(array2d<float> const &kernel) | ||||
{ | { | ||||
ivec2 size = (ivec2)kernel.GetSize(); | |||||
ivec2 size = kernel.size(); | |||||
array<Dot> tmp; | array<Dot> tmp; | ||||
tmp.Resize(size.x * size.y); | |||||
tmp.resize(size.x * size.y); | |||||
for (int y = 0; y < size.y; y++) | for (int y = 0; y < size.y; y++) | ||||
for (int x = 0; x < size.x; x++) | for (int x = 0; x < size.x; x++) | ||||
@@ -294,7 +294,7 @@ array2d<float> Image::GaussianKernel(vec2 radius, float angle, vec2 delta) | |||||
float const Kx = -1.f / (2.f * radius.x * radius.x); | float const Kx = -1.f / (2.f * radius.x * radius.x); | ||||
float const Ky = -1.f / (2.f * radius.y * radius.y); | float const Ky = -1.f / (2.f * radius.y * radius.y); | ||||
kernel.SetSize(size); | |||||
kernel.resize(size); | |||||
float t = 0.f; | float t = 0.f; | ||||
@@ -144,8 +144,8 @@ static Image ResizeBresenham(Image &image, ivec2 size) | |||||
vec4 *dstp = dst.Lock<PixelFormat::RGBA_F32>(); | vec4 *dstp = dst.Lock<PixelFormat::RGBA_F32>(); | ||||
array<vec4> aline, line; | array<vec4> aline, line; | ||||
aline.Resize(size.x); | |||||
line.Resize(size.x); | |||||
aline.resize(size.x); | |||||
line.resize(size.x); | |||||
memset(line.data(), 0, line.bytes()); | memset(line.data(), 0, line.bytes()); | ||||
int remy = 0; | int remy = 0; | ||||
@@ -27,7 +27,7 @@ void KeyBinding::Bind(const String& device_name, const String& key_name) | |||||
return; | return; | ||||
} | } | ||||
ptrdiff_t keyindex = device->GetKeyIndex(key_name); | |||||
int keyindex = device->GetKeyIndex(key_name); | |||||
if (keyindex < 0) | if (keyindex < 0) | ||||
{ | { | ||||
Log::Warn("trying to bind nonexistent key %s.%s\n", | Log::Warn("trying to bind nonexistent key %s.%s\n", | ||||
@@ -35,18 +35,18 @@ void KeyBinding::Bind(const String& device_name, const String& key_name) | |||||
return; | return; | ||||
} | } | ||||
m_keybindings.Push(device, (int)keyindex); | |||||
m_keybindings.push(device, keyindex); | |||||
} | } | ||||
bool KeyBinding::Unbind(const String& device_name, const String& key_name) | bool KeyBinding::Unbind(const String& device_name, const String& key_name) | ||||
{ | { | ||||
for (int i = 0; i < m_keybindings.Count(); ++i) | |||||
for (int i = 0; i < m_keybindings.count(); ++i) | |||||
{ | { | ||||
if (m_keybindings[i].m1->GetName() == device_name) | if (m_keybindings[i].m1->GetName() == device_name) | ||||
{ | { | ||||
if (m_keybindings[i].m2 == m_keybindings[i].m1->GetKeyIndex(key_name)) | if (m_keybindings[i].m2 == m_keybindings[i].m1->GetKeyIndex(key_name)) | ||||
{ | { | ||||
m_keybindings.Remove(i); | |||||
m_keybindings.remove(i); | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -56,7 +56,7 @@ bool KeyBinding::Unbind(const String& device_name, const String& key_name) | |||||
void KeyBinding::ClearBindings() | void KeyBinding::ClearBindings() | ||||
{ | { | ||||
m_keybindings.Empty(); | |||||
m_keybindings.empty(); | |||||
} | } | ||||
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// | ||||
@@ -72,7 +72,7 @@ void AxisBinding::Bind(const String& device_name, const String& axis_name) | |||||
return; | return; | ||||
} | } | ||||
ptrdiff_t axisindex = device->GetAxisIndex(axis_name); | |||||
int axisindex = device->GetAxisIndex(axis_name); | |||||
if (axisindex < 0) | if (axisindex < 0) | ||||
{ | { | ||||
Log::Warn("trying to bind nonexistent axis %s.%s\n", | Log::Warn("trying to bind nonexistent axis %s.%s\n", | ||||
@@ -80,7 +80,7 @@ void AxisBinding::Bind(const String& device_name, const String& axis_name) | |||||
return; | return; | ||||
} | } | ||||
m_axisbindings.Push(device, (int)axisindex); | |||||
m_axisbindings.push(device, axisindex); | |||||
} | } | ||||
void AxisBinding::BindKey(const String& device_name, const String& key_name) | void AxisBinding::BindKey(const String& device_name, const String& key_name) | ||||
@@ -93,7 +93,7 @@ void AxisBinding::BindKey(const String& device_name, const String& key_name) | |||||
return; | return; | ||||
} | } | ||||
ptrdiff_t keyindex = device->GetKeyIndex(key_name); | |||||
int keyindex = device->GetKeyIndex(key_name); | |||||
if (keyindex < 0) | if (keyindex < 0) | ||||
{ | { | ||||
Log::Warn("trying to bind nonexistent axis key %s.%s\n", | Log::Warn("trying to bind nonexistent axis key %s.%s\n", | ||||
@@ -101,7 +101,7 @@ void AxisBinding::BindKey(const String& device_name, const String& key_name) | |||||
return; | return; | ||||
} | } | ||||
m_keybindings.Push(device, -1, (int)keyindex); | |||||
m_keybindings.push(device, -1, keyindex); | |||||
} | } | ||||
void AxisBinding::BindKeys(const String& device_name, const String& min_key_name, const String& max_key_name) | void AxisBinding::BindKeys(const String& device_name, const String& min_key_name, const String& max_key_name) | ||||
@@ -114,7 +114,7 @@ void AxisBinding::BindKeys(const String& device_name, const String& min_key_name | |||||
return; | return; | ||||
} | } | ||||
ptrdiff_t minkeyindex = device->GetKeyIndex(min_key_name); | |||||
int minkeyindex = device->GetKeyIndex(min_key_name); | |||||
if (minkeyindex < 0) | if (minkeyindex < 0) | ||||
{ | { | ||||
Log::Warn("trying to bind nonexistent axis key %s.%s\n", | Log::Warn("trying to bind nonexistent axis key %s.%s\n", | ||||
@@ -122,7 +122,7 @@ void AxisBinding::BindKeys(const String& device_name, const String& min_key_name | |||||
return; | return; | ||||
} | } | ||||
ptrdiff_t maxkeyindex = device->GetKeyIndex(max_key_name); | |||||
int maxkeyindex = device->GetKeyIndex(max_key_name); | |||||
if (maxkeyindex < 0) | if (maxkeyindex < 0) | ||||
{ | { | ||||
Log::Warn("trying to bind nonexistent axis key %s.%s\n", | Log::Warn("trying to bind nonexistent axis key %s.%s\n", | ||||
@@ -130,18 +130,18 @@ void AxisBinding::BindKeys(const String& device_name, const String& min_key_name | |||||
return; | return; | ||||
} | } | ||||
m_keybindings.Push(device, (int)minkeyindex, (int)maxkeyindex); | |||||
m_keybindings.push(device, minkeyindex, maxkeyindex); | |||||
} | } | ||||
bool AxisBinding::Unbind(const String& device_name, const String& axis_name) | bool AxisBinding::Unbind(const String& device_name, const String& axis_name) | ||||
{ | { | ||||
for (int i = 0; i < m_keybindings.Count(); ++i) | |||||
for (int i = 0; i < m_keybindings.count(); ++i) | |||||
{ | { | ||||
if (m_axisbindings[i].m1->GetName() == device_name) | if (m_axisbindings[i].m1->GetName() == device_name) | ||||
{ | { | ||||
if (m_axisbindings[i].m2 == m_axisbindings[i].m1->GetAxisIndex(axis_name)) | if (m_axisbindings[i].m2 == m_axisbindings[i].m1->GetAxisIndex(axis_name)) | ||||
{ | { | ||||
m_axisbindings.Remove(i); | |||||
m_axisbindings.remove(i); | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -151,13 +151,13 @@ bool AxisBinding::Unbind(const String& device_name, const String& axis_name) | |||||
bool AxisBinding::UnbindKey(const String& device_name, const String& key_name) | bool AxisBinding::UnbindKey(const String& device_name, const String& key_name) | ||||
{ | { | ||||
for (int i = 0; i < m_keybindings.Count(); ++i) | |||||
for (int i = 0; i < m_keybindings.count(); ++i) | |||||
{ | { | ||||
if (m_keybindings[i].m1->GetName() == device_name) | if (m_keybindings[i].m1->GetName() == device_name) | ||||
{ | { | ||||
if (m_keybindings[i].m2 == -1 && m_keybindings[i].m3 == m_keybindings[i].m1->GetKeyIndex(key_name)) | if (m_keybindings[i].m2 == -1 && m_keybindings[i].m3 == m_keybindings[i].m1->GetKeyIndex(key_name)) | ||||
{ | { | ||||
m_keybindings.Remove(i); | |||||
m_keybindings.remove(i); | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -167,14 +167,14 @@ bool AxisBinding::UnbindKey(const String& device_name, const String& key_name) | |||||
bool AxisBinding::UnbindKeys(const String& device_name, const String& min_key_name, const String& max_key_name) | bool AxisBinding::UnbindKeys(const String& device_name, const String& min_key_name, const String& max_key_name) | ||||
{ | { | ||||
for (int i = 0; i < m_keybindings.Count(); ++i) | |||||
for (int i = 0; i < m_keybindings.count(); ++i) | |||||
{ | { | ||||
if (m_keybindings[i].m1->GetName() == device_name) | if (m_keybindings[i].m1->GetName() == device_name) | ||||
{ | { | ||||
if (m_keybindings[i].m2 == m_keybindings[i].m1->GetKeyIndex(min_key_name) | if (m_keybindings[i].m2 == m_keybindings[i].m1->GetKeyIndex(min_key_name) | ||||
&& m_keybindings[i].m3 == m_keybindings[i].m1->GetKeyIndex(max_key_name)) | && m_keybindings[i].m3 == m_keybindings[i].m1->GetKeyIndex(max_key_name)) | ||||
{ | { | ||||
m_keybindings.Remove(i); | |||||
m_keybindings.remove(i); | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -185,8 +185,8 @@ bool AxisBinding::UnbindKeys(const String& device_name, const String& min_key_na | |||||
void AxisBinding::ClearBindings() | void AxisBinding::ClearBindings() | ||||
{ | { | ||||
m_axisbindings.Empty(); | |||||
m_keybindings.Empty(); | |||||
m_axisbindings.empty(); | |||||
m_keybindings.empty(); | |||||
} | } | ||||
float AxisBinding::RetrieveCurrentValue() | float AxisBinding::RetrieveCurrentValue() | ||||
@@ -194,7 +194,7 @@ float AxisBinding::RetrieveCurrentValue() | |||||
float max_positive = 0.0f; | float max_positive = 0.0f; | ||||
float max_negative = 0.0f; | float max_negative = 0.0f; | ||||
for (int i = 0; i < m_axisbindings.Count(); ++i) | |||||
for (int i = 0; i < m_axisbindings.count(); ++i) | |||||
{ | { | ||||
float value = m_axisbindings[i].m1->GetAxis(m_axisbindings[i].m2); | float value = m_axisbindings[i].m1->GetAxis(m_axisbindings[i].m2); | ||||
if (value > max_positive) | if (value > max_positive) | ||||
@@ -203,7 +203,7 @@ float AxisBinding::RetrieveCurrentValue() | |||||
max_negative = value; | max_negative = value; | ||||
} | } | ||||
for (int i = 0; i < m_keybindings.Count(); ++i) | |||||
for (int i = 0; i < m_keybindings.count(); ++i) | |||||
{ | { | ||||
float value = 0.0f; | float value = 0.0f; | ||||
m_keybindings[i].m1->GetKey(m_keybindings[i].m2); | m_keybindings[i].m1->GetKey(m_keybindings[i].m2); | ||||
@@ -238,7 +238,7 @@ Controller::Controller(String const &name) | |||||
{ | { | ||||
Log::Warn("controller “%s” has already been registered\n", name.C()); | Log::Warn("controller “%s” has already been registered\n", name.C()); | ||||
} | } | ||||
controllers.Push(this); | |||||
controllers.push(this); | |||||
} | } | ||||
Controller::Controller(String const &name, InputProfile const& profile) | Controller::Controller(String const &name, InputProfile const& profile) | ||||
@@ -250,11 +250,11 @@ Controller::Controller(String const &name, InputProfile const& profile) | |||||
Controller::~Controller() | Controller::~Controller() | ||||
{ | { | ||||
ClearProfile(); | ClearProfile(); | ||||
for (int i = 0; i < controllers.Count(); ++i) | |||||
for (int i = 0; i < controllers.count(); ++i) | |||||
{ | { | ||||
if (controllers[i] == this) | if (controllers[i] == this) | ||||
{ | { | ||||
controllers.Remove(i); | |||||
controllers.remove(i); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -274,8 +274,8 @@ void Controller::ClearProfile() | |||||
//Init mode 2: By hand, key/axis by key/axis ---------------------------------- | //Init mode 2: By hand, key/axis by key/axis ---------------------------------- | ||||
void Controller::SetInputCount(int nb_keys, int nb_axis) | void Controller::SetInputCount(int nb_keys, int nb_axis) | ||||
{ | { | ||||
m_keys.Resize(nb_keys); | |||||
m_axis.Resize(nb_axis); | |||||
m_keys.resize(nb_keys); | |||||
m_axis.resize(nb_axis); | |||||
} | } | ||||
//Layer mask stuff ------------------------------------------------------------ | //Layer mask stuff ------------------------------------------------------------ | ||||
@@ -342,7 +342,7 @@ float Controller::GetAxisDelta(int index) const | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
Controller* Controller::Get(String const &name) | Controller* Controller::Get(String const &name) | ||||
{ | { | ||||
for (int i = 0; i < controllers.Count(); ++i) | |||||
for (int i = 0; i < controllers.count(); ++i) | |||||
{ | { | ||||
if (controllers[i]->m_name == name) | if (controllers[i]->m_name == name) | ||||
return controllers[i]; | return controllers[i]; | ||||
@@ -379,16 +379,16 @@ void Controller::UnbindProfile() | |||||
//Joystick | //Joystick | ||||
for (InputProfile::JoystickKey& key : m_profile.m_joystick_keys) | for (InputProfile::JoystickKey& key : m_profile.m_joystick_keys) | ||||
{ | { | ||||
if (m_joystick_idx.Find(key.m_joy) != INDEX_NONE) | |||||
if (m_joystick_idx.find(key.m_joy) != INDEX_NONE) | |||||
GetKey(key.m_idx).UnbindJoystick(key.m_joy, key.m_name); | GetKey(key.m_idx).UnbindJoystick(key.m_joy, key.m_name); | ||||
} | } | ||||
for (InputProfile::JoystickAxis& axis : m_profile.m_joystick_axis) | for (InputProfile::JoystickAxis& axis : m_profile.m_joystick_axis) | ||||
{ | { | ||||
if (m_joystick_idx.Find(axis.m_joy) != INDEX_NONE) | |||||
if (m_joystick_idx.find(axis.m_joy) != INDEX_NONE) | |||||
GetAxis(axis.m_idx).UnbindJoystick(axis.m_joy, axis.m_name); | GetAxis(axis.m_idx).UnbindJoystick(axis.m_joy, axis.m_name); | ||||
} | } | ||||
m_joystick.Empty(); | |||||
m_joystick_idx.Empty(); | |||||
m_joystick.empty(); | |||||
m_joystick_idx.empty(); | |||||
m_mutex.unlock(); | m_mutex.unlock(); | ||||
} | } | ||||
@@ -400,8 +400,8 @@ void Controller::BindProfile(InputProfile const& setup) | |||||
m_mutex.lock(); | m_mutex.lock(); | ||||
m_profile = setup; | m_profile = setup; | ||||
m_keys.Resize(m_profile.GetKeyCount()); | |||||
m_axis.Resize(m_profile.GetAxisCount()); | |||||
m_keys.resize(m_profile.GetKeyCount()); | |||||
m_axis.resize(m_profile.GetAxisCount()); | |||||
//Keyboard | //Keyboard | ||||
m_keyboard = InputDevice::GetKeyboard(); | m_keyboard = InputDevice::GetKeyboard(); | ||||
@@ -433,12 +433,12 @@ void Controller::BindProfile(InputProfile const& setup) | |||||
} | } | ||||
for (InputProfile::JoystickKey& key : m_profile.m_joystick_keys) | for (InputProfile::JoystickKey& key : m_profile.m_joystick_keys) | ||||
{ | { | ||||
if (m_joystick_idx.Find(key.m_joy) != INDEX_NONE) | |||||
if (m_joystick_idx.find(key.m_joy) != INDEX_NONE) | |||||
GetKey(key.m_idx).BindJoystick(key.m_joy, key.m_name); | GetKey(key.m_idx).BindJoystick(key.m_joy, key.m_name); | ||||
} | } | ||||
for (InputProfile::JoystickAxis& axis : m_profile.m_joystick_axis) | for (InputProfile::JoystickAxis& axis : m_profile.m_joystick_axis) | ||||
{ | { | ||||
if (m_joystick_idx.Find(axis.m_joy) != INDEX_NONE) | |||||
if (m_joystick_idx.find(axis.m_joy) != INDEX_NONE) | |||||
GetAxis(axis.m_idx).BindJoystick(axis.m_joy, axis.m_name); | GetAxis(axis.m_idx).BindJoystick(axis.m_joy, axis.m_name); | ||||
} | } | ||||
@@ -452,10 +452,10 @@ void Controller::TickGame(float seconds) | |||||
if (m_active) | if (m_active) | ||||
{ | { | ||||
for (int i = 0; i < m_keys.Count(); ++i) | |||||
for (int i = 0; i < m_keys.count(); ++i) | |||||
m_keys[i].Update(); | m_keys[i].Update(); | ||||
for (int i = 0; i < m_axis.Count(); ++i) | |||||
for (int i = 0; i < m_axis.count(); ++i) | |||||
m_axis[i].Update(); | m_axis[i].Update(); | ||||
} | } | ||||
@@ -487,11 +487,11 @@ array<Controller*> Controller::DeactivateAll() | |||||
{ | { | ||||
array<Controller*> result; | array<Controller*> result; | ||||
for (int i = 0; i < controllers.Count(); ++i) | |||||
for (int i = 0; i < controllers.count(); ++i) | |||||
{ | { | ||||
if (controllers[i]->m_active || controllers[i]->m_activate_nextframe) | if (controllers[i]->m_active || controllers[i]->m_activate_nextframe) | ||||
{ | { | ||||
result.Push(controllers[i]); | |||||
result.push(controllers[i]); | |||||
controllers[i]->Deactivate(); | controllers[i]->Deactivate(); | ||||
} | } | ||||
} | } | ||||
@@ -50,7 +50,7 @@ public: | |||||
/** Clear current binding */ | /** Clear current binding */ | ||||
void ClearBindings(); | void ClearBindings(); | ||||
/** Indicate wheither a physical device and key has been bound. Returns the number of bindings set. */ | /** Indicate wheither a physical device and key has been bound. Returns the number of bindings set. */ | ||||
ptrdiff_t IsBound() const { return m_keybindings.Count(); } | |||||
int IsBound() const { return m_keybindings.count(); } | |||||
protected: | protected: | ||||
/** Update the binding value. Called internally by the controller, once per frame */ | /** Update the binding value. Called internally by the controller, once per frame */ | ||||
@@ -58,7 +58,7 @@ protected: | |||||
{ | { | ||||
m_previous = m_current; | m_previous = m_current; | ||||
m_current = false; | m_current = false; | ||||
for (int i = 0; i < m_keybindings.Count(); ++i) | |||||
for (int i = 0; i < m_keybindings.count(); ++i) | |||||
{ | { | ||||
m_current = m_current || m_keybindings[i].m1->GetKey(m_keybindings[i].m2); | m_current = m_current || m_keybindings[i].m1->GetKey(m_keybindings[i].m2); | ||||
} | } | ||||
@@ -120,7 +120,7 @@ public: | |||||
/** Clear current binding */ | /** Clear current binding */ | ||||
void ClearBindings(); | void ClearBindings(); | ||||
/** Indicate wheither a physical device and axis has been bound. Returns the number of bindings set. */ | /** Indicate wheither a physical device and axis has been bound. Returns the number of bindings set. */ | ||||
ptrdiff_t IsBound() const { return m_axisbindings.Count() + m_keybindings.Count(); } | |||||
int IsBound() const { return m_axisbindings.count() + m_keybindings.count(); } | |||||
protected: | protected: | ||||
void Update() | void Update() | ||||
@@ -244,16 +244,16 @@ public: | |||||
} | } | ||||
int GetKeyCount() const | int GetKeyCount() const | ||||
{ | { | ||||
return (int)(m_keys.Count() + m_mouse_keys.Count() + m_joystick_keys.Count()); | |||||
return m_keys.count() + m_mouse_keys.count() + m_joystick_keys.count(); | |||||
} | } | ||||
int GetAxisCount() const | int GetAxisCount() const | ||||
{ | { | ||||
return (int)(m_mouse_axis.Count() + m_joystick_axis.Count()); | |||||
return m_mouse_axis.count() + m_joystick_axis.count(); | |||||
} | } | ||||
//Keys -------------------------------------------------------------------- | //Keys -------------------------------------------------------------------- | ||||
InputProfile& operator<<(InputProfile::Keyboard const& binding) | InputProfile& operator<<(InputProfile::Keyboard const& binding) | ||||
{ | { | ||||
m_keys.PushUnique(binding); | |||||
m_keys.push_unique(binding); | |||||
return *this; | return *this; | ||||
} | } | ||||
InputProfile& operator<<(array<InputProfile::Keyboard> const& bindings) | InputProfile& operator<<(array<InputProfile::Keyboard> const& bindings) | ||||
@@ -264,7 +264,7 @@ public: | |||||
//------ | //------ | ||||
InputProfile& operator<<(InputProfile::MouseKey const& binding) | InputProfile& operator<<(InputProfile::MouseKey const& binding) | ||||
{ | { | ||||
m_mouse_keys.PushUnique(binding); | |||||
m_mouse_keys.push_unique(binding); | |||||
return *this; | return *this; | ||||
} | } | ||||
InputProfile& operator<<(array<InputProfile::MouseKey> const& bindings) | InputProfile& operator<<(array<InputProfile::MouseKey> const& bindings) | ||||
@@ -275,21 +275,21 @@ public: | |||||
//------ | //------ | ||||
InputProfile& operator<<(InputProfile::JoystickKey const& binding) | InputProfile& operator<<(InputProfile::JoystickKey const& binding) | ||||
{ | { | ||||
m_joystick.PushUnique(binding.m_joy); | |||||
m_joystick_keys.PushUnique(binding); | |||||
m_joystick.push_unique(binding.m_joy); | |||||
m_joystick_keys.push_unique(binding); | |||||
return *this; | return *this; | ||||
} | } | ||||
InputProfile& operator<<(array<InputProfile::JoystickKey> const& bindings) | InputProfile& operator<<(array<InputProfile::JoystickKey> const& bindings) | ||||
{ | { | ||||
for (InputProfile::JoystickKey const& binding : bindings) | for (InputProfile::JoystickKey const& binding : bindings) | ||||
m_joystick.PushUnique(binding.m_joy); | |||||
m_joystick.push_unique(binding.m_joy); | |||||
m_joystick_keys += bindings; | m_joystick_keys += bindings; | ||||
return *this; | return *this; | ||||
} | } | ||||
//Axis -------------------------------------------------------------------- | //Axis -------------------------------------------------------------------- | ||||
InputProfile& operator<<(InputProfile::MouseAxis const& binding) | InputProfile& operator<<(InputProfile::MouseAxis const& binding) | ||||
{ | { | ||||
m_mouse_axis.PushUnique(binding); | |||||
m_mouse_axis.push_unique(binding); | |||||
return *this; | return *this; | ||||
} | } | ||||
InputProfile& operator<<(array<InputProfile::MouseAxis> const& bindings) | InputProfile& operator<<(array<InputProfile::MouseAxis> const& bindings) | ||||
@@ -300,14 +300,14 @@ public: | |||||
//------ | //------ | ||||
InputProfile& operator<<(InputProfile::JoystickAxis const& binding) | InputProfile& operator<<(InputProfile::JoystickAxis const& binding) | ||||
{ | { | ||||
m_joystick.PushUnique(binding.m_joy); | |||||
m_joystick_axis.PushUnique(binding); | |||||
m_joystick.push_unique(binding.m_joy); | |||||
m_joystick_axis.push_unique(binding); | |||||
return *this; | return *this; | ||||
} | } | ||||
InputProfile& operator<<(array<InputProfile::JoystickAxis> const& bindings) | InputProfile& operator<<(array<InputProfile::JoystickAxis> const& bindings) | ||||
{ | { | ||||
for (InputProfile::JoystickAxis const& binding : bindings) | for (InputProfile::JoystickAxis const& binding : bindings) | ||||
m_joystick.PushUnique(binding.m_joy); | |||||
m_joystick.push_unique(binding.m_joy); | |||||
m_joystick_axis += bindings; | m_joystick_axis += bindings; | ||||
return *this; | return *this; | ||||
} | } | ||||
@@ -331,18 +331,18 @@ public: | |||||
typedef SafeEnum<InputTypeBase> InputType; | typedef SafeEnum<InputTypeBase> InputType; | ||||
//Template helper --------------------------------------------------------- | //Template helper --------------------------------------------------------- | ||||
template <typename T, ptrdiff_t BEGIN, ptrdiff_t END> | |||||
template <typename T, int N_BEGIN, int N_END> | |||||
void AddBindings(InputType const& type, uint64_t joy = 0) | void AddBindings(InputType const& type, uint64_t joy = 0) | ||||
{ | { | ||||
for (ptrdiff_t i = BEGIN; i < END; ++i) | |||||
for (int i = N_BEGIN; i < N_END; ++i) | |||||
{ | { | ||||
switch (type.ToScalar()) | switch (type.ToScalar()) | ||||
{ | { | ||||
case InputType::Keyboard:/******/*this << InputProfile::Keyboard/******/(/***/(int)i, T((int)i).ToString()); break; | |||||
case InputType::MouseKey:/******/*this << InputProfile::MouseKey/******/(/***/(int)i, T((int)i).ToString()); break; | |||||
case InputType::JoystickKey:/***/*this << InputProfile::JoystickKey/***/(joy, (int)i, T((int)i).ToString()); break; | |||||
case InputType::MouseAxis:/*****/*this << InputProfile::MouseAxis/*****/(/***/(int)i, T((int)i).ToString()); break; | |||||
case InputType::JoystickAxis:/**/*this << InputProfile::JoystickAxis/**/(joy, (int)i, T((int)i).ToString()); break; | |||||
case InputType::Keyboard:/******/*this << InputProfile::Keyboard/******/(/***/i, T(i).ToString()); break; | |||||
case InputType::MouseKey:/******/*this << InputProfile::MouseKey/******/(/***/i, T(i).ToString()); break; | |||||
case InputType::JoystickKey:/***/*this << InputProfile::JoystickKey/***/(joy, i, T(i).ToString()); break; | |||||
case InputType::MouseAxis:/*****/*this << InputProfile::MouseAxis/*****/(/***/i, T(i).ToString()); break; | |||||
case InputType::JoystickAxis:/**/*this << InputProfile::JoystickAxis/**/(joy, i, T(i).ToString()); break; | |||||
default: break; | default: break; | ||||
} | } | ||||
} | } | ||||
@@ -21,9 +21,9 @@ bool InputDevice::m_capturemouse; | |||||
array<String> InputDevice::GetAvailableDevices() | array<String> InputDevice::GetAvailableDevices() | ||||
{ | { | ||||
array<String> result; | array<String> result; | ||||
for (int i = 0; i < devices.Count(); ++i) | |||||
for (int i = 0; i < devices.count(); ++i) | |||||
{ | { | ||||
result.Push(devices[i]->m_name); | |||||
result.push(devices[i]->m_name); | |||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
@@ -38,45 +38,45 @@ String InputDevice::GetText() | |||||
void InputDeviceInternal::AddKey(int index, const char* name) | void InputDeviceInternal::AddKey(int index, const char* name) | ||||
{ | { | ||||
if (index == -1) | if (index == -1) | ||||
index = (int)m_keynames.Count(); | |||||
index = m_keynames.count(); | |||||
while (index >= m_keynames.Count()) | |||||
while (index >= m_keynames.count()) | |||||
{ | { | ||||
m_keynames.Push(name); | |||||
m_keys.Push(false); | |||||
m_keynames.push(name); | |||||
m_keys.push(false); | |||||
} | } | ||||
m_keynames.Last() = name; | |||||
m_keynames.last() = name; | |||||
} | } | ||||
void InputDeviceInternal::AddAxis(int index, const char* name, float sensitivity) | void InputDeviceInternal::AddAxis(int index, const char* name, float sensitivity) | ||||
{ | { | ||||
if (index == -1) | if (index == -1) | ||||
index = (int)m_axisnames.Count(); | |||||
index = m_axisnames.count(); | |||||
while (index >= m_axisnames.Count()) | |||||
while (index >= m_axisnames.count()) | |||||
{ | { | ||||
m_axisnames.Push(name); | |||||
m_axis.Push(0.0f, 1.0f); | |||||
m_axisnames.push(name); | |||||
m_axis.push(0.0f, 1.0f); | |||||
} | } | ||||
m_axisnames.Last() = name; | |||||
m_axis.Last().m1 = 0.0f; | |||||
m_axis.Last().m2 = sensitivity; | |||||
m_axisnames.last() = name; | |||||
m_axis.last().m1 = 0.0f; | |||||
m_axis.last().m2 = sensitivity; | |||||
} | } | ||||
void InputDeviceInternal::AddCursor(int index, const char* name) | void InputDeviceInternal::AddCursor(int index, const char* name) | ||||
{ | { | ||||
if (index == -1) | if (index == -1) | ||||
index = (int)m_cursornames.Count(); | |||||
index = m_cursornames.count(); | |||||
while (index >= m_cursornames.Count()) | |||||
while (index >= m_cursornames.count()) | |||||
{ | { | ||||
m_cursornames.Push(name); | |||||
m_cursors.Push(vec2::zero, ivec2::zero); | |||||
m_cursornames.push(name); | |||||
m_cursors.push(vec2::zero, ivec2::zero); | |||||
} | } | ||||
m_cursornames.Last() = name; | |||||
m_cursornames.last() = name; | |||||
} | } | ||||
InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard() | InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard() | ||||
@@ -18,7 +18,7 @@ const String g_name_mouse("Mouse"); | |||||
const String g_name_keyboard("Keyboard"); | const String g_name_keyboard("Keyboard"); | ||||
static String g_name_joystick(const uint64_t num) | static String g_name_joystick(const uint64_t num) | ||||
{ | { | ||||
return String::Printf("Joystick%d", (int)num); | |||||
return String::format("Joystick%d", (int)num); | |||||
} | } | ||||
# define _SC(id, str, name) const String g_name_key_##name(#name); | # define _SC(id, str, name) const String g_name_key_##name(#name); | ||||
@@ -202,16 +202,16 @@ protected: | |||||
InputDevice(String const &name) : m_name(name) | InputDevice(String const &name) : m_name(name) | ||||
{ | { | ||||
devices.PushUnique(this); | |||||
devices.push_unique(this); | |||||
} | } | ||||
~InputDevice() | ~InputDevice() | ||||
{ | { | ||||
for (ptrdiff_t i = 0; i < devices.Count(); ++i) | |||||
for (int i = 0; i < devices.count(); ++i) | |||||
{ | { | ||||
if (devices[i] == this) | if (devices[i] == this) | ||||
{ | { | ||||
devices.Remove(i); | |||||
devices.remove(i); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
@@ -223,7 +223,7 @@ private: | |||||
template <typename... T> | template <typename... T> | ||||
ptrdiff_t GetItemIndex(String const &name, const array<String, T...>& a) const | ptrdiff_t GetItemIndex(String const &name, const array<String, T...>& a) const | ||||
{ | { | ||||
for (ptrdiff_t i = 0; i < a.Count(); ++i) | |||||
for (int i = 0; i < a.count(); ++i) | |||||
{ | { | ||||
if (a[i] == name) | if (a[i] == name) | ||||
return i; | return i; | ||||
@@ -233,7 +233,7 @@ private: | |||||
static InputDevice* GetDevice(String const &name) | static InputDevice* GetDevice(String const &name) | ||||
{ | { | ||||
for (ptrdiff_t i = 0; i < devices.Count(); ++i) | |||||
for (int i = 0; i < devices.count(); ++i) | |||||
{ | { | ||||
if (devices[i]->m_name == name) | if (devices[i]->m_name == name) | ||||
return devices[i]; | return devices[i]; | ||||
@@ -34,14 +34,14 @@ void DrawInner(TREE *tree, array<TBB, vec4> &boxes, | |||||
array<TE *, int, vec4> &elements, | array<TE *, int, vec4> &elements, | ||||
array<int, TBB> &leaves, int children, vec4 color) | array<int, TBB> &leaves, int children, vec4 color) | ||||
{ | { | ||||
boxes.Push(tree->GetAABB(), Color::white); | |||||
leaves.Push(0, boxes.Last().m1); | |||||
while (leaves.Count() > 0) | |||||
boxes.push(tree->GetAABB(), Color::white); | |||||
leaves.push(0, boxes.last().m1); | |||||
while (leaves.count() > 0) | |||||
{ | { | ||||
for (int j = 0; j < tree->GetTree()[leaves[0].m1].m_elements.Count(); j++) | |||||
for (int j = 0; j < tree->GetTree()[leaves[0].m1].m_elements.count(); j++) | |||||
{ | { | ||||
bool done = false; | bool done = false; | ||||
for (int k = 0; k < elements.Count(); k++) | |||||
for (int k = 0; k < elements.count(); k++) | |||||
{ | { | ||||
if (elements[k].m1 == tree->GetElements()[tree->GetTree()[leaves[0].m1].m_elements[j]].m_element) | if (elements[k].m1 == tree->GetElements()[tree->GetTree()[leaves[0].m1].m_elements[j]].m_element) | ||||
{ | { | ||||
@@ -51,7 +51,7 @@ void DrawInner(TREE *tree, array<TBB, vec4> &boxes, | |||||
} | } | ||||
} | } | ||||
if (!done) | if (!done) | ||||
elements.Push(tree->GetElements()[tree->GetTree()[leaves[0].m1].m_elements[j]].m_element, 1, Color::red); | |||||
elements.push(tree->GetElements()[tree->GetTree()[leaves[0].m1].m_elements[j]].m_element, 1, Color::red); | |||||
} | } | ||||
for (int i = 0; i < children; i++) | for (int i = 0; i < children; i++) | ||||
@@ -59,11 +59,11 @@ void DrawInner(TREE *tree, array<TBB, vec4> &boxes, | |||||
if (tree->GetTree()[leaves[0].m1].m_children[i] != 0) | if (tree->GetTree()[leaves[0].m1].m_children[i] != 0) | ||||
{ | { | ||||
TBB bbox = tree->GetSubAABB(leaves[0].m2, i); | TBB bbox = tree->GetSubAABB(leaves[0].m2, i); | ||||
leaves.Push(tree->GetTree()[leaves[0].m1].m_children[i], bbox); | |||||
boxes.Push(bbox, color); | |||||
leaves.push(tree->GetTree()[leaves[0].m1].m_children[i], bbox); | |||||
boxes.push(bbox, color); | |||||
} | } | ||||
} | } | ||||
leaves.Remove(0); | |||||
leaves.remove(0); | |||||
} | } | ||||
} | } | ||||
@@ -79,14 +79,14 @@ void Draw(Quadtree<TE>* tree, vec4 color) | |||||
vec3 off = vec3(0.0f, 0.1f, 0.0f); | vec3 off = vec3(0.0f, 0.1f, 0.0f); | ||||
//vec3 add = vec3(0.0f, 0.1f, 0.0f); | //vec3 add = vec3(0.0f, 0.1f, 0.0f); | ||||
while (boxes.Count() > 0) | |||||
while (boxes.count() > 0) | |||||
{ | { | ||||
Debug::DrawBox(vec3(boxes[0].m1.aa.x, tree->m_debug_y_offset, boxes[0].m1.aa.y), | Debug::DrawBox(vec3(boxes[0].m1.aa.x, tree->m_debug_y_offset, boxes[0].m1.aa.y), | ||||
vec3(boxes[0].m1.bb.x, tree->m_debug_y_offset, boxes[0].m1.bb.y), | vec3(boxes[0].m1.bb.x, tree->m_debug_y_offset, boxes[0].m1.bb.y), | ||||
boxes[0].m2); | boxes[0].m2); | ||||
boxes.Remove(0); | |||||
boxes.remove(0); | |||||
} | } | ||||
while (elements.Count() > 0) | |||||
while (elements.count() > 0) | |||||
{ | { | ||||
while (elements[0].m2 > 0) | while (elements[0].m2 > 0) | ||||
{ | { | ||||
@@ -95,7 +95,7 @@ void Draw(Quadtree<TE>* tree, vec4 color) | |||||
elements[0].m3); | elements[0].m3); | ||||
elements[0].m2--; | elements[0].m2--; | ||||
} | } | ||||
elements.Remove(0); | |||||
elements.remove(0); | |||||
} | } | ||||
} | } | ||||
//-- | //-- | ||||
@@ -110,16 +110,16 @@ void Draw(Octree<TE>* tree, vec4 color) | |||||
vec3 off = vec3(0.0f, 0.1f, 0.0f); | vec3 off = vec3(0.0f, 0.1f, 0.0f); | ||||
//vec3 add = vec3(0.0f, 0.1f, 0.0f); | //vec3 add = vec3(0.0f, 0.1f, 0.0f); | ||||
while (boxes.Count() > 0) | |||||
while (boxes.count() > 0) | |||||
{ | { | ||||
//float size = boxes[0].m1.bb.x - boxes[0].m1.aa.x; | //float size = boxes[0].m1.bb.x - boxes[0].m1.aa.x; | ||||
Debug::DrawBox(vec3(boxes[0].m1.aa.x, boxes[0].m1.aa.y, boxes[0].m1.aa.z) /* + off * (m_size.x / size) */, | Debug::DrawBox(vec3(boxes[0].m1.aa.x, boxes[0].m1.aa.y, boxes[0].m1.aa.z) /* + off * (m_size.x / size) */, | ||||
vec3(boxes[0].m1.bb.x, boxes[0].m1.bb.y, boxes[0].m1.bb.z) /* + off * (m_size.x / size) */, | vec3(boxes[0].m1.bb.x, boxes[0].m1.bb.y, boxes[0].m1.bb.z) /* + off * (m_size.x / size) */, | ||||
boxes[0].m2); | boxes[0].m2); | ||||
//off += add; | //off += add; | ||||
boxes.Remove(0); | |||||
boxes.remove(0); | |||||
} | } | ||||
while (elements.Count() > 0) | |||||
while (elements.count() > 0) | |||||
{ | { | ||||
while (elements[0].m2 > 0) | while (elements[0].m2 > 0) | ||||
{ | { | ||||
@@ -128,7 +128,7 @@ void Draw(Octree<TE>* tree, vec4 color) | |||||
elements[0].m3); | elements[0].m3); | ||||
elements[0].m2--; | elements[0].m2--; | ||||
} | } | ||||
elements.Remove(0); | |||||
elements.remove(0); | |||||
} | } | ||||
} | } | ||||
//-- | //-- | ||||
@@ -213,7 +213,7 @@ private: | |||||
void RemoveElement(TE* element) | void RemoveElement(TE* element) | ||||
{ | { | ||||
int idx = INDEX_NONE; | int idx = INDEX_NONE; | ||||
for (int i = 0; i < m_elements.Count(); ++i) | |||||
for (int i = 0; i < m_elements.count(); ++i) | |||||
if (m_elements[i].m_element == element) | if (m_elements[i].m_element == element) | ||||
idx = i; | idx = i; | ||||
@@ -221,8 +221,8 @@ private: | |||||
return; | return; | ||||
//Remove item from tree leaves | //Remove item from tree leaves | ||||
for (int i = 0; i < m_elements[idx].m_leaves.Count(); i++) | |||||
m_tree[m_elements[idx].m_leaves[i]].m_elements.RemoveItem(idx); | |||||
for (int i = 0; i < m_elements[idx].m_leaves.count(); i++) | |||||
m_tree[m_elements[idx].m_leaves[i]].m_elements.removeItem(idx); | |||||
//Try leaves cleanup | //Try leaves cleanup | ||||
CleanupEmptyLeaves(); | CleanupEmptyLeaves(); | ||||
@@ -230,7 +230,7 @@ private: | |||||
//-- | //-- | ||||
int AddElement(TE* element) | int AddElement(TE* element) | ||||
{ | { | ||||
for (int i = 0; i < m_elements.Count(); ++i) | |||||
for (int i = 0; i < m_elements.count(); ++i) | |||||
if (m_elements[i].m_element == element) | if (m_elements[i].m_element == element) | ||||
return i; | return i; | ||||
@@ -238,15 +238,15 @@ private: | |||||
new_element.m_element = element; | new_element.m_element = element; | ||||
new_element.m_leaves = array<int>(); | new_element.m_leaves = array<int>(); | ||||
m_elements << new_element; | m_elements << new_element; | ||||
return (int)m_elements.Count() - 1; | |||||
return m_elements.count() - 1; | |||||
} | } | ||||
//-- | //-- | ||||
int AddLeaf(int parent) | int AddLeaf(int parent) | ||||
{ | { | ||||
int idx = (int)m_tree.Count(); | |||||
if (m_free_leaves.Count()) | |||||
int idx = m_tree.count(); | |||||
if (m_free_leaves.count()) | |||||
{ | { | ||||
idx = m_free_leaves.Pop(); | |||||
idx = m_free_leaves.pop(); | |||||
m_tree[idx] = NodeLeaf(parent); | m_tree[idx] = NodeLeaf(parent); | ||||
} | } | ||||
else | else | ||||
@@ -270,8 +270,8 @@ private: | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
for (int j = 0; j < node.m_elements.Count(); j++) | |||||
elements.PushUnique(m_elements[node.m_elements[j]].m_element); | |||||
for (int j = 0; j < node.m_elements.count(); j++) | |||||
elements.push_unique(m_elements[node.m_elements[j]].m_element); | |||||
result = true; | result = true; | ||||
} | } | ||||
} | } | ||||
@@ -296,29 +296,29 @@ private: | |||||
return true; | return true; | ||||
//Too much elements, we need to re-dispatch the elements | //Too much elements, we need to re-dispatch the elements | ||||
if (m_tree[leaf].m_elements.Count() + 1 > m_max_element && | |||||
if (m_tree[leaf].m_elements.count() + 1 > m_max_element && | |||||
depth < m_max_depth) | depth < m_max_depth) | ||||
{ | { | ||||
//Extract elements | //Extract elements | ||||
array<int> elements = m_tree[leaf].m_elements; | array<int> elements = m_tree[leaf].m_elements; | ||||
elements.PushUnique(AddElement(element)); | |||||
m_tree[leaf].m_elements.Empty(); | |||||
elements.push_unique(AddElement(element)); | |||||
m_tree[leaf].m_elements.empty(); | |||||
//Add children | //Add children | ||||
for (size_t j = 0; j < child_nb; ++j) | for (size_t j = 0; j < child_nb; ++j) | ||||
m_tree[leaf].m_children[j] = AddLeaf(leaf); | m_tree[leaf].m_children[j] = AddLeaf(leaf); | ||||
//Re-run extracted elements | //Re-run extracted elements | ||||
while (elements.Count()) | |||||
while (elements.count()) | |||||
{ | { | ||||
RegisterElement(m_elements[elements[0]].m_element, leaf, leaf_bb, depth); | RegisterElement(m_elements[elements[0]].m_element, leaf, leaf_bb, depth); | ||||
elements.Remove(0); | |||||
elements.remove(0); | |||||
} | } | ||||
} | } | ||||
//else add to list. | //else add to list. | ||||
else | else | ||||
{ | { | ||||
int idx = AddElement(element); | int idx = AddElement(element); | ||||
m_elements[idx].m_leaves.PushUnique(leaf); | |||||
m_tree[leaf].m_elements.PushUnique(idx); | |||||
m_elements[idx].m_leaves.push_unique(leaf); | |||||
m_tree[leaf].m_elements.push_unique(idx); | |||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
@@ -331,8 +331,8 @@ public: | |||||
bool FindElements(const TB& bbox, array<TE*>& elements) { return TestLeaf(0, GetAABB(), bbox, elements); } | bool FindElements(const TB& bbox, array<TE*>& elements) { return TestLeaf(0, GetAABB(), bbox, elements); } | ||||
void Clear() | void Clear() | ||||
{ | { | ||||
m_tree.Empty(); | |||||
m_elements.Empty(); | |||||
m_tree.empty(); | |||||
m_elements.empty(); | |||||
} | } | ||||
//-- | //-- | ||||
@@ -260,21 +260,21 @@ public: | |||||
{ | { | ||||
for (auto door : m_doors) | for (auto door : m_doors) | ||||
door->DisconnectRoom(this); | door->DisconnectRoom(this); | ||||
m_doors.Empty(); | |||||
m_doors.empty(); | |||||
} | } | ||||
PortalRoom& operator<<(class PortalDoor<TE>* door) | PortalRoom& operator<<(class PortalDoor<TE>* door) | ||||
{ | { | ||||
m_doors.PushUnique(door); | |||||
m_doors.push_unique(door); | |||||
return *this; | return *this; | ||||
} | } | ||||
PortalRoom& operator>>(class PortalDoor<TE>* door) | PortalRoom& operator>>(class PortalDoor<TE>* door) | ||||
{ | { | ||||
m_doors.RemoveSwapItem(door); | |||||
m_doors.remove_swap_item(door); | |||||
return *this; | return *this; | ||||
} | } | ||||
int GetDoorCount() { return m_doors.Count(); } | |||||
int GetDoorCount() { return m_doors.count(); } | |||||
PortalDoor<TE>* GetDoor(int i) { return m_doors[i]; } | PortalDoor<TE>* GetDoor(int i) { return m_doors[i]; } | ||||
private: | private: | ||||
@@ -294,8 +294,8 @@ public: | |||||
delete door; | delete door; | ||||
for (auto room : m_rooms) | for (auto room : m_rooms) | ||||
delete room; | delete room; | ||||
m_doors.Empty(); | |||||
m_rooms.Empty(); | |||||
m_doors.empty(); | |||||
m_rooms.empty(); | |||||
} | } | ||||
//Visible room getter | //Visible room getter | ||||
@@ -336,8 +336,8 @@ private: | |||||
if (visible_rooms.Find(other_room) != INDEX_NONE) | if (visible_rooms.Find(other_room) != INDEX_NONE) | ||||
continue; | continue; | ||||
ignore_doors.PushUnique(door); | |||||
visible_rooms.PushUnique(other_room); | |||||
ignore_doors.push_unique(door); | |||||
visible_rooms.push_unique(other_room); | |||||
door->BuildViewProj(see_through->m_view, see_through->m_proj); | door->BuildViewProj(see_through->m_view, see_through->m_proj); | ||||
GetVisibleRooms(door, other_room, visible_rooms, ignore_doors); | GetVisibleRooms(door, other_room, visible_rooms, ignore_doors); | ||||
} | } | ||||
@@ -348,9 +348,9 @@ public: | |||||
//Operator | //Operator | ||||
PortalSet<TE>& operator<<(class PortalRoom<TE>* room) | PortalSet<TE>& operator<<(class PortalRoom<TE>* room) | ||||
{ | { | ||||
m_rooms.PushUnique(room); | |||||
m_rooms.push_unique(room); | |||||
for (auto door : room->m_doors) | for (auto door : room->m_doors) | ||||
m_doors.PushUnique(door); | |||||
m_doors.push_unique(door); | |||||
return *this; | return *this; | ||||
} | } | ||||
//-- | //-- | ||||
@@ -358,26 +358,26 @@ public: | |||||
{ | { | ||||
for (auto door : room->m_doors) | for (auto door : room->m_doors) | ||||
*this >> door; | *this >> door; | ||||
m_rooms.RemoveItem(room); | |||||
m_rooms.remove_item(room); | |||||
return *this; | return *this; | ||||
} | } | ||||
//-- | //-- | ||||
PortalSet<TE>& operator<<(class PortalDoor<TE>* door) | PortalSet<TE>& operator<<(class PortalDoor<TE>* door) | ||||
{ | { | ||||
m_doors.PushUnique(door); | |||||
m_doors.push_unique(door); | |||||
return *this; | return *this; | ||||
} | } | ||||
//-- | //-- | ||||
PortalSet<TE>& operator>>(class PortalDoor<TE>* door) | PortalSet<TE>& operator>>(class PortalDoor<TE>* door) | ||||
{ | { | ||||
m_doors.RemoveItem(door); | |||||
m_doors.remove_item(door); | |||||
return *this; | return *this; | ||||
} | } | ||||
//-- | //-- | ||||
int GetDoorCount() { return m_doors.Count(); } | |||||
int GetDoorCount() { return m_doors.count(); } | |||||
PortalDoor<TE>* GetDoor(int i) { return m_doors[i]; } | PortalDoor<TE>* GetDoor(int i) { return m_doors[i]; } | ||||
int GetRoomCount() { return m_rooms.Count(); } | |||||
int GetRoomCount() { return m_rooms.count(); } | |||||
PortalRoom<TE>* GetRoom(int i) { return m_rooms[i]; } | PortalRoom<TE>* GetRoom(int i) { return m_rooms[i]; } | ||||
private: | private: | ||||
@@ -21,12 +21,12 @@ namespace lol | |||||
template<typename T, typename ARRAY> | template<typename T, typename ARRAY> | ||||
void array_base<T, ARRAY>::Shuffle() | void array_base<T, ARRAY>::Shuffle() | ||||
{ | { | ||||
auto n = Count(); | |||||
auto n = count(); | |||||
auto ni = n; | auto ni = n; | ||||
while (n > 0) | while (n > 0) | ||||
{ | { | ||||
ni = lol::rand(n--) | 0; | ni = lol::rand(n--) | 0; | ||||
Swap(ni, n); | |||||
std::swap(m_data[ni], m_data[n]); | |||||
} | } | ||||
} | } | ||||
@@ -41,13 +41,13 @@ void array_base<T, ARRAY>::Sort(SortAlgorithm algorithm) | |||||
if (algorithm == SortAlgorithm::Bubble) | if (algorithm == SortAlgorithm::Bubble) | ||||
{ | { | ||||
int d = 1; | int d = 1; | ||||
for (ptrdiff_t i = 0; i < Count() - 1; i = lol::max(i + d, (ptrdiff_t)0)) | |||||
for (ptrdiff_t i = 0; i < count_s() - 1; i = lol::max(i + d, (ptrdiff_t)0)) | |||||
{ | { | ||||
if (i <= 0 || m_data[i] < m_data[i + 1]) | if (i <= 0 || m_data[i] < m_data[i + 1]) | ||||
d = 1; | d = 1; | ||||
if (m_data[i + 1] < m_data[i]) | if (m_data[i + 1] < m_data[i]) | ||||
{ | { | ||||
Swap(i, i + 1); | |||||
std::swap(m_data[i], m_data[i + 1]); | |||||
d = -1; | d = -1; | ||||
} | } | ||||
} | } | ||||
@@ -55,7 +55,7 @@ void array_base<T, ARRAY>::Sort(SortAlgorithm algorithm) | |||||
// Quick sort with swap | // Quick sort with swap | ||||
else if (algorithm == SortAlgorithm::QuickSwap) | else if (algorithm == SortAlgorithm::QuickSwap) | ||||
{ | { | ||||
SortQuickSwap(0, Count()); | |||||
SortQuickSwap(0, count_s()); | |||||
} | } | ||||
} | } | ||||
@@ -90,7 +90,7 @@ void array_base<T, ARRAY>::SortQuickSwap(ptrdiff_t start, ptrdiff_t stop) | |||||
{ | { | ||||
if (!(m_data[i0] < median) && m_data[i1] < median) | if (!(m_data[i0] < median) && m_data[i1] < median) | ||||
{ | { | ||||
Swap(i0, i1); | |||||
std::swap(m_data[i0], m_data[i1]); | |||||
i0++; | i0++; | ||||
i1--; | i1--; | ||||
b_swap = true; | b_swap = true; | ||||
@@ -278,18 +278,6 @@ public: | |||||
return false; | return false; | ||||
} | } | ||||
bool SwapItem(T const &x1, T const &x2) | |||||
{ | |||||
ptrdiff_t idx1 = find(x1); | |||||
ptrdiff_t idx2 = find(x2); | |||||
if (idx1 != INDEX_NONE && idx2 != INDEX_NONE) | |||||
{ | |||||
swap(idx1, idx2); | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
inline T pop() | inline T pop() | ||||
{ | { | ||||
ASSERT(m_count > 0); | ASSERT(m_count > 0); | ||||
@@ -298,19 +286,6 @@ public: | |||||
return tmp; | return tmp; | ||||
} | } | ||||
void swap(ptrdiff_t pos1, ptrdiff_t pos2) | |||||
{ | |||||
ASSERT(pos1 >= 0 && pos1 <= m_count, | |||||
"cannot swap index %lld in array of size %lld", | |||||
(long long int)pos1, (long long int)m_count); | |||||
ASSERT(pos2 >= 0 && pos2 <= m_count, | |||||
"cannot swap index %lld in array of size %lld", | |||||
(long long int)pos2, (long long int)m_count); | |||||
if (pos1 != pos2) | |||||
std::swap((*this)[pos1], (*this)[pos2]); | |||||
} | |||||
void remove(ptrdiff_t pos, ptrdiff_t todelete = 1) | void remove(ptrdiff_t pos, ptrdiff_t todelete = 1) | ||||
{ | { | ||||
ASSERT(todelete >= 0); | ASSERT(todelete >= 0); | ||||
@@ -396,28 +371,6 @@ public: | |||||
void Sort(SortAlgorithm algorithm); | void Sort(SortAlgorithm algorithm); | ||||
void SortQuickSwap(ptrdiff_t start, ptrdiff_t stop); | void SortQuickSwap(ptrdiff_t start, ptrdiff_t stop); | ||||
/* TODO: remove these legacy functions one day */ | |||||
inline void Push(T const &x) { push(x); } | |||||
inline bool PushUnique(T const &x) { return push_unique(x); } | |||||
inline T Pop() { return pop(); } | |||||
inline void Swap(ptrdiff_t pos1, ptrdiff_t pos2) { swap(pos1, pos2); } | |||||
inline void Remove(ptrdiff_t pos, ptrdiff_t todelete = 1) { remove(pos, todelete); } | |||||
inline void RemoveSwap(ptrdiff_t pos, ptrdiff_t todelete = 1) { remove_swap(pos, todelete); } | |||||
inline void Empty() { empty(); } | |||||
inline element_t& Last() { return last(); } | |||||
inline element_t *Data() { return data(); } | |||||
inline element_t const *Data() const { return data(); } | |||||
inline element_t const& Last() const { return last(); } | |||||
inline void Insert(T const &x, ptrdiff_t pos) { return insert(x, pos); } | |||||
inline bool InsertUnique(T const &x, ptrdiff_t pos) { return insert_unique(x, pos); } | |||||
inline ptrdiff_t Find(T const &x) { return find(x); } | |||||
inline bool RemoveItem(T const &x) { return remove_item(x); } | |||||
inline bool RemoveSwapItem(T const &x) { return remove_swap_item(x); } | |||||
inline void Resize(ptrdiff_t item_count, element_t e = element_t()) { return resize(item_count, e); } | |||||
inline void Reserve(ptrdiff_t toreserve) { return reserve(toreserve); } | |||||
inline ptrdiff_t Count() const { return count(); } | |||||
inline ptrdiff_t Bytes() const { return bytes(); } | |||||
/* Support C++11 range-based for loops */ | /* Support C++11 range-based for loops */ | ||||
class ConstIterator | class ConstIterator | ||||
{ | { | ||||
@@ -478,8 +431,11 @@ public: | |||||
}; | }; | ||||
public: | public: | ||||
inline ptrdiff_t count() const { return m_count; } | |||||
inline ptrdiff_t bytes() const { return m_count * sizeof(element_t); } | |||||
inline int count() const { return (int)m_count; } | |||||
inline int bytes() const { return (int)(m_count * sizeof(element_t)); } | |||||
inline ptrdiff_t count_s() const { return m_count; } | |||||
inline ptrdiff_t bytes_s() const { return m_count * sizeof(element_t); } | |||||
protected: | protected: | ||||
void grow() | void grow() | ||||
@@ -549,10 +505,6 @@ public: | |||||
new (&this->m_data[pos]) tuple<T...>({ args... }); | new (&this->m_data[pos]) tuple<T...>({ args... }); | ||||
++this->m_count; | ++this->m_count; | ||||
} | } | ||||
/* TODO: remove these legacy functions one day */ | |||||
inline void Push(T... args) { push(args...); } | |||||
inline void Insert(ptrdiff_t pos, T... args) { insert(pos, args...); } | |||||
}; | }; | ||||
template<typename T> | template<typename T> | ||||
@@ -101,16 +101,21 @@ public: | |||||
array<K> ret; | array<K> ret; | ||||
for (auto iterator : m_tree) | for (auto iterator : m_tree) | ||||
ret.Push(iterator.key); | |||||
ret.push(iterator.key); | |||||
return ret; | return ret; | ||||
} | } | ||||
inline ptrdiff_t count() const | |||||
inline int count() const | |||||
{ | { | ||||
return m_tree.count(); | return m_tree.count(); | ||||
} | } | ||||
inline ptrdiff_t count_s() const | |||||
{ | |||||
return m_tree.count_s(); | |||||
} | |||||
inline void empty() | inline void empty() | ||||
{ | { | ||||
m_tree.clear(); | m_tree.clear(); | ||||
@@ -49,7 +49,7 @@ public: | |||||
memcpy(&(*this)[0], str, count() + 1); | memcpy(&(*this)[0], str, count() + 1); | ||||
} | } | ||||
inline String(char const *str, ptrdiff_t item_count) | |||||
inline String(char const *str, int item_count) | |||||
: super() | : super() | ||||
{ | { | ||||
using namespace std; | using namespace std; | ||||
@@ -64,7 +64,7 @@ public: | |||||
{ | { | ||||
} | } | ||||
inline char &operator [](ptrdiff_t n) | |||||
inline char &operator [](int n) | |||||
{ | { | ||||
/* Allow n == count() because we might have reasonable reasons | /* Allow n == count() because we might have reasonable reasons | ||||
* to access that hidden null character. */ | * to access that hidden null character. */ | ||||
@@ -73,7 +73,7 @@ public: | |||||
return ((super &)*this)[n]; | return ((super &)*this)[n]; | ||||
} | } | ||||
inline char const &operator [](ptrdiff_t n) const | |||||
inline char const &operator [](int n) const | |||||
{ | { | ||||
ASSERT(n >= 0); | ASSERT(n >= 0); | ||||
ASSERT(n <= count()); | ASSERT(n <= count()); | ||||
@@ -92,7 +92,7 @@ public: | |||||
return (*this)[count() - 1]; | return (*this)[count() - 1]; | ||||
} | } | ||||
inline ptrdiff_t count() const | |||||
inline int count() const | |||||
{ | { | ||||
return ((super const &)*this).count() - 1; | return ((super const &)*this).count() - 1; | ||||
} | } | ||||
@@ -110,14 +110,14 @@ public: | |||||
} | } | ||||
/* Does not initialise the newly allocated characters */ | /* Does not initialise the newly allocated characters */ | ||||
void resize(ptrdiff_t item_count) | |||||
void resize(int item_count) | |||||
{ | { | ||||
ASSERT(item_count >= 0); | ASSERT(item_count >= 0); | ||||
((super &)*this).resize(item_count + 1); | ((super &)*this).resize(item_count + 1); | ||||
((super &)*this).last() = '\0'; | ((super &)*this).last() = '\0'; | ||||
} | } | ||||
String sub(ptrdiff_t start, ptrdiff_t item_count = -1) const | |||||
String sub(int start, int item_count = -1) const | |||||
{ | { | ||||
ASSERT(start >= 0); | ASSERT(start >= 0); | ||||
if (start >= count()) | if (start >= count()) | ||||
@@ -132,40 +132,40 @@ public: | |||||
return index_of(s.C()) != INDEX_NONE; | return index_of(s.C()) != INDEX_NONE; | ||||
} | } | ||||
ptrdiff_t index_of(char token) const | |||||
int index_of(char token) const | |||||
{ | { | ||||
using namespace std; | using namespace std; | ||||
char const *tmp = strchr(C(), token); | char const *tmp = strchr(C(), token); | ||||
return tmp ? (ptrdiff_t)(tmp - C()) : INDEX_NONE; | |||||
return tmp ? int(tmp - C()) : INDEX_NONE; | |||||
} | } | ||||
ptrdiff_t index_of(String const& token) const { return index_of(token.C()); } | |||||
ptrdiff_t index_of(char const* token) const | |||||
int index_of(String const& token) const { return index_of(token.C()); } | |||||
int index_of(char const* token) const | |||||
{ | { | ||||
using namespace std; | using namespace std; | ||||
char const *tmp = strstr(C(), token); | char const *tmp = strstr(C(), token); | ||||
return tmp ? (ptrdiff_t)(tmp - C()) : INDEX_NONE; | |||||
return tmp ? int(tmp - C()) : INDEX_NONE; | |||||
} | } | ||||
ptrdiff_t last_index_of(char token) const | |||||
int last_index_of(char token) const | |||||
{ | { | ||||
using namespace std; | using namespace std; | ||||
char const *tmp = strrchr(C(), token); | char const *tmp = strrchr(C(), token); | ||||
return tmp ? (ptrdiff_t)(tmp - C()) : INDEX_NONE; | |||||
return tmp ? int(tmp - C()) : INDEX_NONE; | |||||
} | } | ||||
ptrdiff_t last_index_of(String const& token) const { return last_index_of(token.C()); } | |||||
ptrdiff_t last_index_of(char const* token) const | |||||
int last_index_of(String const& token) const { return last_index_of(token.C()); } | |||||
int last_index_of(char const* token) const | |||||
{ | { | ||||
using namespace std; | using namespace std; | ||||
ptrdiff_t token_len = strlen(token); | |||||
for (ptrdiff_t i = count() - token_len; i >= 0; --i) | |||||
if (strstr(C() + i, token)) | |||||
return i; | |||||
int token_len = strlen(token); | |||||
for (int i = count() - token_len; i >= 0; --i) | |||||
if (strstr(C() + i, token)) | |||||
return i; | |||||
return -1; | return -1; | ||||
} | } | ||||
@@ -189,7 +189,7 @@ public: | |||||
inline String& to_lower() | inline String& to_lower() | ||||
{ | { | ||||
String ret(*this); | String ret(*this); | ||||
for (ptrdiff_t i = 0; i < ret.count(); ++i) | |||||
for (int i = 0; i < ret.count(); ++i) | |||||
{ | { | ||||
if ('A' <= ret[i] && ret[i] <= 'Z') | if ('A' <= ret[i] && ret[i] <= 'Z') | ||||
ret[i] += 'a' - 'A'; | ret[i] += 'a' - 'A'; | ||||
@@ -201,7 +201,7 @@ public: | |||||
inline String& to_upper() | inline String& to_upper() | ||||
{ | { | ||||
String ret(*this); | String ret(*this); | ||||
for (ptrdiff_t i = 0; i < ret.count(); ++i) | |||||
for (int i = 0; i < ret.count(); ++i) | |||||
{ | { | ||||
if ('a' <= ret[i] && ret[i] <= 'z') | if ('a' <= ret[i] && ret[i] <= 'z') | ||||
ret[i] += 'A' - 'a'; | ret[i] += 'A' - 'a'; | ||||
@@ -230,7 +230,7 @@ public: | |||||
bool is_alpha() const | bool is_alpha() const | ||||
{ | { | ||||
for (ptrdiff_t i = 0; i < m_count; i++) | |||||
for (int i = 0; i < m_count; i++) | |||||
if (m_data[i] != '\0' && (m_data[i] < '0' || '9' < m_data[i])) | if (m_data[i] != '\0' && (m_data[i] < '0' || '9' < m_data[i])) | ||||
return false; | return false; | ||||
return true; | return true; | ||||
@@ -251,7 +251,7 @@ public: | |||||
inline String& operator +=(String const &s) | inline String& operator +=(String const &s) | ||||
{ | { | ||||
using namespace std; | using namespace std; | ||||
ptrdiff_t old_count = count(); | |||||
int old_count = count(); | |||||
resize(count() + s.count()); | resize(count() + s.count()); | ||||
memcpy(&(*this)[old_count], &s[0], count() - old_count); | memcpy(&(*this)[old_count], &s[0], count() - old_count); | ||||
return *this; | return *this; | ||||
@@ -281,7 +281,7 @@ public: | |||||
/* We parse the C string twice because of strlen + memcmp | /* We parse the C string twice because of strlen + memcmp | ||||
* but it's probably still faster than doing it by hand. */ | * but it's probably still faster than doing it by hand. */ | ||||
using namespace std; | using namespace std; | ||||
ptrdiff_t sz_len = strlen(sz); | |||||
int sz_len = strlen(sz); | |||||
return count() == sz_len | return count() == sz_len | ||||
&& memcmp(C(), sz, sz_len) == 0; | && memcmp(C(), sz, sz_len) == 0; | ||||
} | } | ||||
@@ -307,47 +307,9 @@ public: | |||||
#else | #else | ||||
# define LOL_FMT_ATTR(n, p) | # define LOL_FMT_ATTR(n, p) | ||||
#endif | #endif | ||||
static String Printf(char const *format, ...) LOL_FMT_ATTR(1, 2); | |||||
static String format(char const *format, ...) LOL_FMT_ATTR(1, 2); | |||||
#undef LOL_FMT_ATTR | #undef LOL_FMT_ATTR | ||||
static String VPrintf(char const *format, va_list ap); | |||||
/* TODO: remove these legacy functions one day */ | |||||
inline char &Last() { return last(); } | |||||
inline char const &Last() const { return last(); } | |||||
inline void Resize(ptrdiff_t item_count) { return resize(item_count); } | |||||
inline String& ToLower() { return to_lower(); } | |||||
inline String& ToUpper() { return to_upper(); } | |||||
inline String& CaseChange(bool case_to_upper) { return case_to_upper ? ToUpper() : ToLower(); } | |||||
inline String Sub(ptrdiff_t start, ptrdiff_t item_count = -1) const { return sub(start, item_count); } | |||||
inline bool Contains(String const &s) const { return contains(s); } | |||||
inline ptrdiff_t IndexOf(char token) const { return index_of(token); } | |||||
inline ptrdiff_t IndexOf(char const* token) const { return index_of(token); } | |||||
inline ptrdiff_t LastIndexOf(char token) const { return last_index_of(token); } | |||||
inline int Replace(char const old_token, char const new_token, bool all_occurrences = false) { return replace(old_token, new_token, all_occurrences); } | |||||
inline bool EndsWith(String const &s) const { return ends_with(s); } | |||||
inline bool IsAlpha() const { return is_alpha(); } | |||||
inline bool StartsWith(String const &s) const { return starts_with(s); } | |||||
inline ptrdiff_t Count() const { return count(); } | |||||
}; | |||||
class Line | |||||
{ | |||||
public: | |||||
Line(String const& s) | |||||
{ | |||||
m_line = s + "\n"; | |||||
} | |||||
inline operator String() | |||||
{ | |||||
return m_line; | |||||
} | |||||
inline operator const char*() | |||||
{ | |||||
return m_line.C(); | |||||
} | |||||
private: | |||||
String m_line; | |||||
static String vformat(char const *format, va_list ap); | |||||
}; | }; | ||||
inline bool operator ==(char const* sz, String const &s) | inline bool operator ==(char const* sz, String const &s) | ||||
@@ -138,8 +138,8 @@ public: | |||||
void *GetDevice(); | void *GetDevice(); | ||||
static void AddNew(ivec2 size); | static void AddNew(ivec2 size); | ||||
static ptrdiff_t GetCount(); | |||||
static Renderer* Get(ptrdiff_t index = 0); | |||||
static int GetCount(); | |||||
static Renderer* Get(int index = 0); | |||||
static void DestroyAll(); | static void DestroyAll(); | ||||
public: | public: | ||||
@@ -33,7 +33,7 @@ | |||||
namespace lol | namespace lol | ||||
{ | { | ||||
template<typename T, ptrdiff_t L> | |||||
template<typename T, int L> | |||||
class arraynd_initializer | class arraynd_initializer | ||||
{ | { | ||||
public: | public: | ||||
@@ -45,15 +45,15 @@ public: | |||||
void FillSizes(ptrdiff_t * sizes) | void FillSizes(ptrdiff_t * sizes) | ||||
{ | { | ||||
*sizes = std::max((ptrdiff_t)*sizes, (ptrdiff_t)(m_initializers.size())); | |||||
*sizes = max(*sizes, (ptrdiff_t)m_initializers.size()); | |||||
for (auto subinitializer : m_initializers) | for (auto subinitializer : m_initializers) | ||||
subinitializer.FillSizes(sizes - 1); | subinitializer.FillSizes(sizes - 1); | ||||
} | } | ||||
void FillValues(T * origin, ptrdiff_t prev, ptrdiff_t * sizes) | |||||
void FillValues(T * origin, int prev, ptrdiff_t * sizes) | |||||
{ | { | ||||
ptrdiff_t pos = 0; | |||||
int pos = 0; | |||||
for (auto subinitializer : m_initializers) | for (auto subinitializer : m_initializers) | ||||
subinitializer.FillValues(origin, pos++ + prev * *sizes, sizes - 1); | subinitializer.FillValues(origin, pos++ + prev * *sizes, sizes - 1); | ||||
@@ -77,14 +77,12 @@ public: | |||||
void FillSizes(ptrdiff_t * sizes) | void FillSizes(ptrdiff_t * sizes) | ||||
{ | { | ||||
*sizes = std::max((ptrdiff_t)*sizes, (ptrdiff_t)(m_initializers.size())); | |||||
*sizes = max(*sizes, (ptrdiff_t)m_initializers.size()); | |||||
} | } | ||||
void FillValues(T * origin, ptrdiff_t prev, ptrdiff_t * sizes) | |||||
void FillValues(T * origin, int prev, ptrdiff_t * sizes) | |||||
{ | { | ||||
UNUSED(sizes); | |||||
ptrdiff_t pos = 0; | |||||
int pos = 0; | |||||
for (auto value : m_initializers) | for (auto value : m_initializers) | ||||
*(origin + prev * *sizes + pos++) = value; | *(origin + prev * *sizes + pos++) = value; | ||||
@@ -96,7 +94,7 @@ private: | |||||
}; | }; | ||||
template<ptrdiff_t N, typename... T> | |||||
template<int N, typename... T> | |||||
class arraynd : protected array<T...> | class arraynd : protected array<T...> | ||||
{ | { | ||||
public: | public: | ||||
@@ -130,7 +128,7 @@ public: | |||||
fix_sizes(); | fix_sizes(); | ||||
ptrdiff_t pos = 0; | |||||
int pos = 0; | |||||
for (auto inner_initializer : initializer) | for (auto inner_initializer : initializer) | ||||
inner_initializer.FillValues(&super::operator[](0), pos++, &m_sizes[N - 2]); | inner_initializer.FillValues(&super::operator[](0), pos++, &m_sizes[N - 2]); | ||||
@@ -169,7 +167,7 @@ public: | |||||
#endif | #endif | ||||
/* Proxy to access slices */ | /* Proxy to access slices */ | ||||
template<typename ARRAY_TYPE, ptrdiff_t L = N - 1> | |||||
template<typename ARRAY_TYPE, int L = N - 1> | |||||
class slice | class slice | ||||
{ | { | ||||
public: | public: | ||||
@@ -232,43 +230,34 @@ public: | |||||
/* Resize the array. | /* Resize the array. | ||||
* FIXME: data gets scrambled; should we care? */ | * FIXME: data gets scrambled; should we care? */ | ||||
inline void set_size(vec_t<ptrdiff_t, N> sizes, element_t e = element_t()) | |||||
inline void resize(vec_t<int, N> sizes, element_t e = element_t()) | |||||
{ | { | ||||
m_sizes = sizes; | |||||
fix_sizes(e); | |||||
resize_s(vec_t<ptrdiff_t, N>(sizes), e); | |||||
} | } | ||||
#if PTRDIFF_MAX > INT_MAX | |||||
inline void set_size(vec_t<int, N> sizes, element_t e = element_t()) | |||||
inline void resize_s(vec_t<ptrdiff_t, N> sizes, element_t e = element_t()) | |||||
{ | { | ||||
m_sizes = vec_t<ptrdiff_t, N>(sizes); | |||||
m_sizes = sizes; | |||||
fix_sizes(e); | fix_sizes(e); | ||||
} | } | ||||
#endif | |||||
inline vec_t<ptrdiff_t, N> get_size() const | |||||
inline vec_t<int, N> size() const | |||||
{ | { | ||||
return this->m_sizes; | |||||
return vec_t<int, N>(this->m_sizes); | |||||
} | } | ||||
/* TODO: remove these legacy functions one day */ | |||||
inline vec_t<ptrdiff_t, N> GetSize() const { return get_size(); } | |||||
inline void SetSize(vec_t<ptrdiff_t, N> sizes, element_t e = element_t()) | |||||
{ | |||||
return set_size(sizes, e); | |||||
} | |||||
#if PTRDIFF_MAX > INT_MAX | |||||
inline void SetSize(vec_t<int, N> sizes, element_t e = element_t()) | |||||
inline vec_t<ptrdiff_t, N> size_s() const | |||||
{ | { | ||||
return set_size(sizes, e); | |||||
return this->m_sizes; | |||||
} | } | ||||
#endif | |||||
public: | public: | ||||
inline element_t *data() { return super::data(); } | inline element_t *data() { return super::data(); } | ||||
inline element_t const *data() const { return super::data(); } | inline element_t const *data() const { return super::data(); } | ||||
inline ptrdiff_t count() const { return super::count(); } | |||||
inline ptrdiff_t bytes() const { return super::bytes(); } | |||||
inline int count() const { return super::count(); } | |||||
inline int bytes() const { return super::bytes(); } | |||||
inline ptrdiff_t count_s() const { return super::count_s(); } | |||||
inline ptrdiff_t bytes_s() const { return super::bytes_s(); } | |||||
private: | private: | ||||
inline void fix_sizes(element_t e = element_t()) | inline void fix_sizes(element_t e = element_t()) | ||||
@@ -280,7 +269,7 @@ private: | |||||
for (int i = 0; i < N; ++i) | for (int i = 0; i < N; ++i) | ||||
total_size *= m_sizes[i]; | total_size *= m_sizes[i]; | ||||
this->Resize(total_size, e); | |||||
this->array<T...>::resize(total_size, e); | |||||
} | } | ||||
vec_t<ptrdiff_t, N> m_sizes; | vec_t<ptrdiff_t, N> m_sizes; | ||||
@@ -362,7 +362,7 @@ private: | |||||
{ | { | ||||
int best_delta = -1; | int best_delta = -1; | ||||
float best_t2 = t; | float best_t2 = t; | ||||
for (int i = 0; i < deltas.Count(); ++i) | |||||
for (int i = 0; i < deltas.count(); ++i) | |||||
{ | { | ||||
float t2 = eval(v + e * deltas[i]); | float t2 = eval(v + e * deltas[i]); | ||||
if (abs(t2) > abs(best_t2)) | if (abs(t2) > abs(best_t2)) | ||||
@@ -32,7 +32,7 @@ struct polynomial | |||||
/* A constant polynomial */ | /* A constant polynomial */ | ||||
explicit inline polynomial(T const &a) | explicit inline polynomial(T const &a) | ||||
{ | { | ||||
m_coefficients.Push(a); | |||||
m_coefficients.push(a); | |||||
reduce_degree(); | reduce_degree(); | ||||
} | } | ||||
@@ -40,7 +40,7 @@ struct polynomial | |||||
explicit polynomial(std::initializer_list<T> const &init) | explicit polynomial(std::initializer_list<T> const &init) | ||||
{ | { | ||||
for (auto a : init) | for (auto a : init) | ||||
m_coefficients.Push(a); | |||||
m_coefficients.push(a); | |||||
reduce_degree(); | reduce_degree(); | ||||
} | } | ||||
@@ -60,7 +60,7 @@ struct polynomial | |||||
polynomial<T> ret; | polynomial<T> ret; | ||||
for (int k = 0; k <= n; ++k) | for (int k = 0; k <= n; ++k) | ||||
ret.m_coefficients.Push(T(coeff(k, n))); | |||||
ret.m_coefficients.push(T(coeff(k, n))); | |||||
return ret; | return ret; | ||||
} | } | ||||
@@ -68,11 +68,11 @@ struct polynomial | |||||
* degree -1 on purpose. */ | * degree -1 on purpose. */ | ||||
inline int degree() const | inline int degree() const | ||||
{ | { | ||||
return (int)m_coefficients.Count() - 1; | |||||
return (int)m_coefficients.count() - 1; | |||||
} | } | ||||
/* Set one of the polynomial’s coefficients */ | /* Set one of the polynomial’s coefficients */ | ||||
void set(ptrdiff_t n, T const &a) | |||||
void set(int n, T const &a) | |||||
{ | { | ||||
ASSERT(n >= 0); | ASSERT(n >= 0); | ||||
@@ -80,7 +80,7 @@ struct polynomial | |||||
return; | return; | ||||
while (n > degree()) | while (n > degree()) | ||||
m_coefficients.Push(T(0)); | |||||
m_coefficients.push(T(0)); | |||||
m_coefficients[n] = a; | m_coefficients[n] = a; | ||||
reduce_degree(); | reduce_degree(); | ||||
@@ -102,7 +102,7 @@ struct polynomial | |||||
/* No need to reduce the degree after deriving. */ | /* No need to reduce the degree after deriving. */ | ||||
polynomial<T> ret; | polynomial<T> ret; | ||||
for (int i = 1; i <= degree(); ++i) | for (int i = 1; i <= degree(); ++i) | ||||
ret.m_coefficients.Push(m_coefficients[i] * T(i)); | |||||
ret.m_coefficients.push(m_coefficients[i] * T(i)); | |||||
return ret; | return ret; | ||||
} | } | ||||
@@ -183,7 +183,7 @@ struct polynomial | |||||
{ | { | ||||
polynomial<T> ret; | polynomial<T> ret; | ||||
for (auto a : m_coefficients) | for (auto a : m_coefficients) | ||||
ret.m_coefficients.Push(-a); | |||||
ret.m_coefficients.push(-a); | |||||
return ret; | return ret; | ||||
} | } | ||||
@@ -196,7 +196,7 @@ struct polynomial | |||||
m_coefficients[i] += p[i]; | m_coefficients[i] += p[i]; | ||||
for (int i = min_degree + 1; i <= p.degree(); ++i) | for (int i = min_degree + 1; i <= p.degree(); ++i) | ||||
m_coefficients.Push(p[i]); | |||||
m_coefficients.push(p[i]); | |||||
reduce_degree(); | reduce_degree(); | ||||
return *this; | return *this; | ||||
@@ -258,7 +258,7 @@ struct polynomial | |||||
{ | { | ||||
int n = p.degree() + q.degree(); | int n = p.degree() + q.degree(); | ||||
for (int i = 0; i <= n; ++i) | for (int i = 0; i <= n; ++i) | ||||
ret.m_coefficients.Push(T(0)); | |||||
ret.m_coefficients.push(T(0)); | |||||
for (int i = 0; i <= p.degree(); ++i) | for (int i = 0; i <= p.degree(); ++i) | ||||
for (int j = 0; j <= q.degree(); ++j) | for (int j = 0; j <= q.degree(); ++j) | ||||
@@ -288,7 +288,7 @@ struct polynomial | |||||
quotient.set(n, remainder.leading()); | quotient.set(n, remainder.leading()); | ||||
for (int i = 0; i < p.degree(); ++i) | for (int i = 0; i < p.degree(); ++i) | ||||
remainder.m_coefficients[n + i] -= remainder.leading() * p[i]; | remainder.m_coefficients[n + i] -= remainder.leading() * p[i]; | ||||
remainder.m_coefficients.Pop(); | |||||
remainder.m_coefficients.pop(); | |||||
} | } | ||||
return ret; | return ret; | ||||
@@ -298,8 +298,8 @@ private: | |||||
/* Enforce the non-zero leading coefficient rule. */ | /* Enforce the non-zero leading coefficient rule. */ | ||||
void reduce_degree() | void reduce_degree() | ||||
{ | { | ||||
while (m_coefficients.Count() && m_coefficients.Last() == T(0)) | |||||
m_coefficients.Pop(); | |||||
while (m_coefficients.count() && m_coefficients.last() == T(0)) | |||||
m_coefficients.pop(); | |||||
} | } | ||||
/* The polynomial coefficients */ | /* The polynomial coefficients */ | ||||
@@ -18,6 +18,8 @@ | |||||
using namespace lol; | using namespace lol; | ||||
#define Line(s) ((s) + "\n") | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
LolImGui::LolImGui() | LolImGui::LolImGui() | ||||
{ | { | ||||
@@ -54,7 +56,8 @@ LolImGui::LolImGui() | |||||
imgui_pixel.SetMainCode(String() + | imgui_pixel.SetMainCode(String() + | ||||
Line(String() | Line(String() | ||||
+ "vec4 col = " + pass_color + " * texture2D(" + m_texture + ", " + pass_texcoord + ");") | + "vec4 col = " + pass_color + " * texture2D(" + m_texture + ", " + pass_texcoord + ");") | ||||
+ Line("if (col.a == 0.0) discard; ") | |||||
+ Line(String() | |||||
+ "if (col.a == 0.0) discard; ") | |||||
+ Line(out_pixel + " = col;") | + Line(out_pixel + " = col;") | ||||
); | ); | ||||
@@ -227,7 +230,7 @@ void LolImGui::TickGame(float seconds) | |||||
cursor.y = 1.f - cursor.y; | cursor.y = 1.f - cursor.y; | ||||
cursor *= video_size; | cursor *= video_size; | ||||
io.MousePos = ImVec2(cursor.x, cursor.y); | io.MousePos = ImVec2(cursor.x, cursor.y); | ||||
Log::Debug(Line("%.2f/%.2f"), io.MousePos.x, io.MousePos.y); | |||||
Log::Debug("%.2f/%.2f\n", io.MousePos.x, io.MousePos.y); | |||||
io.MouseWheel = m_controller->GetAxisValue(LolImGuiAxis::Scroll); | io.MouseWheel = m_controller->GetAxisValue(LolImGuiAxis::Scroll); | ||||
for (int i = LolImGuiKey::MOUSE_KEY_START; i < LolImGuiKey::MOUSE_KEY_END; ++i) | for (int i = LolImGuiKey::MOUSE_KEY_START; i < LolImGuiKey::MOUSE_KEY_END; ++i) | ||||
@@ -240,11 +243,11 @@ void LolImGui::TickGame(float seconds) | |||||
case LolImGuiKey::Focus: | case LolImGuiKey::Focus: | ||||
if (m_controller->IsKeyReleased(i)) | if (m_controller->IsKeyReleased(i)) | ||||
{ | { | ||||
Log::Debug(Line("Not focused .....")); | |||||
Log::Debug("Not focused .....\n"); | |||||
io.MousePos = ImVec2(-1.f, -1.f); | io.MousePos = ImVec2(-1.f, -1.f); | ||||
} | } | ||||
else | else | ||||
Log::Debug(Line("Focused !!")); | |||||
Log::Debug("Focused !!\n"); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -50,17 +50,16 @@ class LuaBaseData | |||||
char const *filename = var;// lua_tostring(l, 1); | char const *filename = var;// lua_tostring(l, 1); | ||||
int status = LUA_ERRFILE; | int status = LUA_ERRFILE; | ||||
array<String> pathlist = System::GetPathList(filename); | |||||
File f; | File f; | ||||
for (int i = 0; i < pathlist.Count(); ++i) | |||||
for (auto candidate : System::GetPathList(filename)) | |||||
{ | { | ||||
f.Open(pathlist[i], FileAccess::Read); | |||||
f.Open(candidate, FileAccess::Read); | |||||
if (f.IsValid()) | if (f.IsValid()) | ||||
{ | { | ||||
String s = f.ReadString(); | String s = f.ReadString(); | ||||
f.Close(); | f.Close(); | ||||
Log::Debug("loading Lua file %s\n", pathlist[i].C()); | |||||
Log::Debug("loading Lua file %s\n", candidate.C()); | |||||
status = LuaDoCode(l, s); | status = LuaDoCode(l, s); | ||||
break; | break; | ||||
} | } | ||||
@@ -115,7 +114,7 @@ void Loader::Store(LuaState* l, Lolua::Loader* loader) | |||||
} | } | ||||
void Loader::Release(LuaState* l, Lolua::Loader* loader) | void Loader::Release(LuaState* l, Lolua::Loader* loader) | ||||
{ | { | ||||
for (ptrdiff_t i = 0; i < g_loaders.count(); ++i) | |||||
for (int i = 0; i < g_loaders.count(); ++i) | |||||
{ | { | ||||
if (g_loaders[i].m1 == l && g_loaders[i].m2 == loader) | if (g_loaders[i].m1 == l && g_loaders[i].m2 == loader) | ||||
{ | { | ||||
@@ -128,11 +127,11 @@ void Loader::Release(LuaState* l, Lolua::Loader* loader) | |||||
//Store lua object -------------------------------------------------------- | //Store lua object -------------------------------------------------------- | ||||
void Loader::StoreObject(LuaState* l, Object* obj) | void Loader::StoreObject(LuaState* l, Object* obj) | ||||
{ | { | ||||
for (ptrdiff_t i = 0; i < g_loaders.count(); ++i) | |||||
for (auto loader : g_loaders) | |||||
{ | { | ||||
if (g_loaders[i].m1 == l) | |||||
if (loader.m1 == l) | |||||
{ | { | ||||
g_loaders[i].m2->Store(obj); | |||||
loader.m2->Store(obj); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
@@ -63,29 +63,29 @@ struct ObjectLib | |||||
m_method_name = class_name + "_inst"; | m_method_name = class_name + "_inst"; | ||||
m_statics = statics; | m_statics = statics; | ||||
if (m_statics.Count() == 0 | |||||
|| m_statics.Last().name != nullptr | |||||
|| m_statics.Last().func != nullptr) | |||||
m_statics.Push({ nullptr, nullptr }); | |||||
if (m_statics.count() == 0 | |||||
|| m_statics.last().name != nullptr | |||||
|| m_statics.last().func != nullptr) | |||||
m_statics.push({ nullptr, nullptr }); | |||||
m_methods = methods; | m_methods = methods; | ||||
if (m_methods.Count() == 0 | |||||
|| m_methods.Last().name != nullptr | |||||
|| m_methods.Last().func != nullptr) | |||||
m_methods.Push({ nullptr, nullptr }); | |||||
if (m_methods.count() == 0 | |||||
|| m_methods.last().name != nullptr | |||||
|| m_methods.last().func != nullptr) | |||||
m_methods.push({ nullptr, nullptr }); | |||||
for (ClassVar const& cv : variables) | for (ClassVar const& cv : variables) | ||||
{ | { | ||||
if (cv.name && cv.get && cv.set) | if (cv.name && cv.get && cv.set) | ||||
{ | { | ||||
m_variables.Push({ cv.name, cv.get, cv.set }); | |||||
m_variables.push({ cv.name, cv.get, cv.set }); | |||||
} | } | ||||
} | } | ||||
if (m_variables.Count() == 0 | |||||
|| variables.Last().name != nullptr | |||||
|| variables.Last().get != nullptr | |||||
|| variables.Last().set != nullptr) | |||||
m_variables.Push(ClassVarStr()); | |||||
if (m_variables.count() == 0 | |||||
|| variables.last().name != nullptr | |||||
|| variables.last().get != nullptr | |||||
|| variables.last().set != nullptr) | |||||
m_variables.push(ClassVarStr()); | |||||
} | } | ||||
String m_class_name = ""; | String m_class_name = ""; | ||||
String m_static_name = ""; | String m_static_name = ""; | ||||
@@ -201,9 +201,9 @@ public: | |||||
template <typename TLuaClass> | template <typename TLuaClass> | ||||
static const char* GetMethodName() { return GetLib<TLuaClass>()->m_method_name.C(); } | static const char* GetMethodName() { return GetLib<TLuaClass>()->m_method_name.C(); } | ||||
template <typename TLuaClass> | template <typename TLuaClass> | ||||
static const ClassMethod* GetStaticMethods() { return GetLib<TLuaClass>()->m_statics.Data(); } | |||||
static const ClassMethod* GetStaticMethods() { return GetLib<TLuaClass>()->m_statics.data(); } | |||||
template <typename TLuaClass> | template <typename TLuaClass> | ||||
static const ClassMethod* GetInstanceMethods() { return GetLib<TLuaClass>()->m_methods.Data(); } | |||||
static const ClassMethod* GetInstanceMethods() { return GetLib<TLuaClass>()->m_methods.data(); } | |||||
template <typename TLuaClass> | template <typename TLuaClass> | ||||
static const array<ObjectLib::ClassVarStr>& GetVariables() { return GetLib<TLuaClass>()->m_variables; } | static const array<ObjectLib::ClassVarStr>& GetVariables() { return GetLib<TLuaClass>()->m_variables; } | ||||
@@ -17,7 +17,7 @@ namespace lol | |||||
#define LOL_PRINTF_TOSTRING(type, ...) \ | #define LOL_PRINTF_TOSTRING(type, ...) \ | ||||
template<> void type::printf() const { Log::Debug(__VA_ARGS__); } \ | template<> void type::printf() const { Log::Debug(__VA_ARGS__); } \ | ||||
template<> String type::tostring() const { return String::Printf(__VA_ARGS__); } | |||||
template<> String type::tostring() const { return String::format(__VA_ARGS__); } | |||||
LOL_PRINTF_TOSTRING(vec2, "[ %6.6f %6.6f ]\n", x, y); | LOL_PRINTF_TOSTRING(vec2, "[ %6.6f %6.6f ]\n", x, y); | ||||
LOL_PRINTF_TOSTRING(ivec2, "[ %i %i ]\n", x, y); | LOL_PRINTF_TOSTRING(ivec2, "[ %i %i ]\n", x, y); | ||||
@@ -40,8 +40,8 @@ template<> String mat2::tostring() const | |||||
{ | { | ||||
mat2 const &p = *this; | mat2 const &p = *this; | ||||
return String::Printf("[ %6.6f %6.6f\n", p[0][0], p[1][0]) + | |||||
String::Printf(" %6.6f %6.6f ]\n", p[0][1], p[1][1]); | |||||
return String::format("[ %6.6f %6.6f\n", p[0][0], p[1][0]) + | |||||
String::format(" %6.6f %6.6f ]\n", p[0][1], p[1][1]); | |||||
} | } | ||||
template<> void mat3::printf() const | template<> void mat3::printf() const | ||||
@@ -57,9 +57,9 @@ template<> String mat3::tostring() const | |||||
{ | { | ||||
mat3 const &p = *this; | mat3 const &p = *this; | ||||
return String::Printf("[ %6.6f %6.6f %6.6f\n", p[0][0], p[1][0], p[2][0]) + | |||||
String::Printf(" %6.6f %6.6f %6.6f\n", p[0][1], p[1][1], p[2][1]) + | |||||
String::Printf(" %6.6f %6.6f %6.6f ]\n", p[0][2], p[1][2], p[2][2]); | |||||
return String::format("[ %6.6f %6.6f %6.6f\n", p[0][0], p[1][0], p[2][0]) + | |||||
String::format(" %6.6f %6.6f %6.6f\n", p[0][1], p[1][1], p[2][1]) + | |||||
String::format(" %6.6f %6.6f %6.6f ]\n", p[0][2], p[1][2], p[2][2]); | |||||
} | } | ||||
template<> void mat4::printf() const | template<> void mat4::printf() const | ||||
@@ -80,13 +80,13 @@ template<> String mat4::tostring() const | |||||
{ | { | ||||
mat4 const &p = *this; | mat4 const &p = *this; | ||||
return String::Printf("[ %6.6f %6.6f %6.6f %6.6f\n", | |||||
return String::format("[ %6.6f %6.6f %6.6f %6.6f\n", | |||||
p[0][0], p[1][0], p[2][0], p[3][0]) + | p[0][0], p[1][0], p[2][0], p[3][0]) + | ||||
String::Printf(" %6.6f %6.6f %6.6f %6.6f\n", | |||||
String::format(" %6.6f %6.6f %6.6f %6.6f\n", | |||||
p[0][1], p[1][1], p[2][1], p[3][1]) + | p[0][1], p[1][1], p[2][1], p[3][1]) + | ||||
String::Printf(" %6.6f %6.6f %6.6f %6.6f\n", | |||||
String::format(" %6.6f %6.6f %6.6f %6.6f\n", | |||||
p[0][2], p[1][2], p[2][2], p[3][2]) + | p[0][2], p[1][2], p[2][2], p[3][2]) + | ||||
String::Printf(" %6.6f %6.6f %6.6f %6.6f ]\n", | |||||
String::format(" %6.6f %6.6f %6.6f %6.6f ]\n", | |||||
p[0][3], p[1][3], p[2][3], p[3][3]); | p[0][3], p[1][3], p[2][3], p[3][3]); | ||||
} | } | ||||
@@ -30,22 +30,22 @@ Mesh::~Mesh() | |||||
void Mesh::Render(Scene& scene, mat4 const &matrix) | void Mesh::Render(Scene& scene, mat4 const &matrix) | ||||
{ | { | ||||
//if (scene.HasPrimitiveRenderer(this) < m_submeshes.Count()) | |||||
//if (scene.HasPrimitiveRenderer(this) < m_submeshes.count()) | |||||
{ | { | ||||
for (int i = 0; i < m_submeshes.Count(); ++i) | |||||
for (int i = 0; i < m_submeshes.count(); ++i) | |||||
scene.AddPrimitiveRenderer(this, new PrimitiveMesh(m_submeshes[i], matrix)); | scene.AddPrimitiveRenderer(this, new PrimitiveMesh(m_submeshes[i], matrix)); | ||||
} | } | ||||
} | } | ||||
void Mesh::Render() | void Mesh::Render() | ||||
{ | { | ||||
for (int i = 0; i < m_submeshes.Count(); ++i) | |||||
for (int i = 0; i < m_submeshes.count(); ++i) | |||||
m_submeshes[i]->Render(); | m_submeshes[i]->Render(); | ||||
} | } | ||||
void Mesh::SetMaterial(Shader *shader) | void Mesh::SetMaterial(Shader *shader) | ||||
{ | { | ||||
for (int i = 0; i < m_submeshes.Count(); ++i) | |||||
for (int i = 0; i < m_submeshes.count(); ++i) | |||||
m_submeshes[i]->SetShader(shader); | m_submeshes[i]->SetShader(shader); | ||||
} | } | ||||
@@ -91,8 +91,8 @@ void SubMesh::SetVertexDeclaration(VertexDeclaration *vdecl) | |||||
void SubMesh::SetVertexBuffer(int index, VertexBuffer* vbo) | void SubMesh::SetVertexBuffer(int index, VertexBuffer* vbo) | ||||
{ | { | ||||
while (index >= m_vbos.Count()) | |||||
m_vbos.Push(nullptr); | |||||
while (index >= m_vbos.count()) | |||||
m_vbos.push(nullptr); | |||||
m_vbos[index] = vbo; | m_vbos[index] = vbo; | ||||
} | } | ||||
@@ -104,14 +104,14 @@ void SubMesh::SetIndexBuffer(IndexBuffer* ibo) | |||||
void SubMesh::AddTexture(const char* name, Texture* texture) | void SubMesh::AddTexture(const char* name, Texture* texture) | ||||
{ | { | ||||
m_textures.Push(String(name), texture); | |||||
m_textures.push(String(name), texture); | |||||
} | } | ||||
void SubMesh::Render() | void SubMesh::Render() | ||||
{ | { | ||||
int vertex_count = 0; | int vertex_count = 0; | ||||
for (int i = 0; i < m_vbos.Count(); ++i) | |||||
for (int i = 0; i < m_vbos.count(); ++i) | |||||
{ | { | ||||
ShaderAttrib attribs[12]; | ShaderAttrib attribs[12]; | ||||
@@ -130,12 +130,12 @@ void SubMesh::Render() | |||||
attribs[j] = m_shader->GetAttribLocation(usage, usages[usage_index]++); | attribs[j] = m_shader->GetAttribLocation(usage, usages[usage_index]++); | ||||
} | } | ||||
vertex_count = (int)m_vbos[i]->GetSize() / m_vdecl->GetStream(i).GetSize(); | |||||
vertex_count = m_vbos[i]->GetSize() / m_vdecl->GetStream(i).GetSize(); | |||||
m_vdecl->SetStream(m_vbos[i], attribs); | m_vdecl->SetStream(m_vbos[i], attribs); | ||||
} | } | ||||
for (int i = 0; i < m_textures.Count(); ++i) | |||||
for (int i = 0; i < m_textures.count(); ++i) | |||||
{ | { | ||||
// TODO: might be good to cache this | // TODO: might be good to cache this | ||||
ShaderUniform u_tex = m_shader->GetUniformLocation(m_textures[i].m1.C()); | ShaderUniform u_tex = m_shader->GetUniformLocation(m_textures[i].m1.C()); | ||||
@@ -145,7 +145,7 @@ void SubMesh::Render() | |||||
m_ibo->Bind(); | m_ibo->Bind(); | ||||
m_vdecl->Bind(); | m_vdecl->Bind(); | ||||
m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, 0, 0, vertex_count, | m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, 0, 0, vertex_count, | ||||
0, (int)m_ibo->GetSize() / sizeof(uint16_t)); | |||||
0, m_ibo->GetSize() / sizeof(uint16_t)); | |||||
m_vdecl->Unbind(); | m_vdecl->Unbind(); | ||||
m_ibo->Unbind(); | m_ibo->Unbind(); | ||||
} | } | ||||
@@ -61,9 +61,11 @@ public: | |||||
//TODO: Not sure about the name | //TODO: Not sure about the name | ||||
void Render(Scene& scene, mat4 const &matrix); | void Render(Scene& scene, mat4 const &matrix); | ||||
protected: | protected: | ||||
void Render(); | void Render(); | ||||
public: | |||||
array<class SubMesh *> m_submeshes; | array<class SubMesh *> m_submeshes; | ||||
}; | }; | ||||
@@ -72,7 +72,7 @@ void PrimitiveMesh::Render(Scene& scene, PrimitiveSource* primitive) | |||||
/* FIXME: GetUniform("blabla") is costly */ | /* FIXME: GetUniform("blabla") is costly */ | ||||
for (auto l : lights) | for (auto l : lights) | ||||
light_data << vec4(l->GetPosition(), (float)l->GetType()) << l->GetColor(); | light_data << vec4(l->GetPosition(), (float)l->GetType()) << l->GetColor(); | ||||
while (light_data.Count() < LOL_MAX_LIGHT_COUNT) | |||||
while (light_data.count() < LOL_MAX_LIGHT_COUNT) | |||||
light_data << vec4::zero << vec4::zero; | light_data << vec4::zero << vec4::zero; | ||||
ShaderUniform u_lights = shader->GetUniformLocation("u_lights"); | ShaderUniform u_lights = shader->GetUniformLocation("u_lights"); | ||||
@@ -42,14 +42,14 @@ MessageService::MessageService() | |||||
MessageService::~MessageService() | MessageService::~MessageService() | ||||
{ | { | ||||
m_bucket.Empty(); | |||||
m_bucket.empty(); | |||||
} | } | ||||
//Setup/Destroy | //Setup/Destroy | ||||
void MessageService::Setup() | void MessageService::Setup() | ||||
{ | { | ||||
g_messageservice = new MessageService(); | g_messageservice = new MessageService(); | ||||
g_messageservice->m_bucket.Resize(MessageBucket::MAX); | |||||
g_messageservice->m_bucket.resize(MessageBucket::MAX); | |||||
} | } | ||||
void MessageService::Destroy() | void MessageService::Destroy() | ||||
@@ -63,7 +63,7 @@ bool MessageService::Send(MessageBucket id, const String& message) | |||||
{ | { | ||||
if (g_messageservice) | if (g_messageservice) | ||||
{ | { | ||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.Count()); | |||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.count()); | |||||
return g_messageservice->Send(id, message.C()); | return g_messageservice->Send(id, message.C()); | ||||
} | } | ||||
return false; | return false; | ||||
@@ -73,7 +73,7 @@ bool MessageService::Send(MessageBucket id, const char* message) | |||||
{ | { | ||||
if (g_messageservice) | if (g_messageservice) | ||||
{ | { | ||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.Count()); | |||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.count()); | |||||
MessageService& g = *g_messageservice; | MessageService& g = *g_messageservice; | ||||
array<MessageList>& bucket = g.m_bucket[id.ToScalar()]; | array<MessageList>& bucket = g.m_bucket[id.ToScalar()]; | ||||
bucket << MessageList(time(nullptr), String(message)); | bucket << MessageList(time(nullptr), String(message)); | ||||
@@ -87,7 +87,7 @@ bool MessageService::FetchFirst(MessageBucket id, String& message) | |||||
{ | { | ||||
if (g_messageservice) | if (g_messageservice) | ||||
{ | { | ||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.Count()); | |||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.count()); | |||||
time_t timestamp; | time_t timestamp; | ||||
return g_messageservice->FetchFirst(id, message, timestamp); | return g_messageservice->FetchFirst(id, message, timestamp); | ||||
} | } | ||||
@@ -98,15 +98,15 @@ bool MessageService::FetchFirst(MessageBucket id, String& message, time_t& times | |||||
{ | { | ||||
if (g_messageservice) | if (g_messageservice) | ||||
{ | { | ||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.Count()); | |||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.count()); | |||||
MessageService& g = *g_messageservice; | MessageService& g = *g_messageservice; | ||||
array<MessageList>& bucket = g.m_bucket[id.ToScalar()]; | array<MessageList>& bucket = g.m_bucket[id.ToScalar()]; | ||||
if (bucket.Count()) | |||||
if (bucket.count()) | |||||
{ | { | ||||
message = bucket[0].m_message; | message = bucket[0].m_message; | ||||
timestamp = bucket[0].m_timestamp; | timestamp = bucket[0].m_timestamp; | ||||
bucket.Remove(0); | |||||
bucket.remove(0); | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -118,7 +118,7 @@ bool MessageService::FetchAll(MessageBucket id, String& message) | |||||
{ | { | ||||
if (g_messageservice) | if (g_messageservice) | ||||
{ | { | ||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.Count()); | |||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.count()); | |||||
time_t timestamp; | time_t timestamp; | ||||
return g_messageservice->FetchAll(id, message, timestamp); | return g_messageservice->FetchAll(id, message, timestamp); | ||||
} | } | ||||
@@ -129,17 +129,17 @@ bool MessageService::FetchAll(MessageBucket id, String& message, time_t& first_t | |||||
{ | { | ||||
if (g_messageservice) | if (g_messageservice) | ||||
{ | { | ||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.Count()); | |||||
ASSERT(0 <= id.ToScalar() && id.ToScalar() < g_messageservice->m_bucket.count()); | |||||
MessageService& g = *g_messageservice; | MessageService& g = *g_messageservice; | ||||
array<MessageList>& bucket = g.m_bucket[id.ToScalar()]; | array<MessageList>& bucket = g.m_bucket[id.ToScalar()]; | ||||
message = String(""); | message = String(""); | ||||
if (bucket.Count()) | |||||
if (bucket.count()) | |||||
{ | { | ||||
first_timestamp = bucket[0].m_timestamp; | first_timestamp = bucket[0].m_timestamp; | ||||
for (int i = 0; i < bucket.Count(); ++i) | |||||
for (int i = 0; i < bucket.count(); ++i) | |||||
message += bucket[i].m_message; | message += bucket[i].m_message; | ||||
bucket.Empty(); | |||||
bucket.empty(); | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -147,3 +147,4 @@ bool MessageService::FetchAll(MessageBucket id, String& message, time_t& first_t | |||||
} | } | ||||
} /* namespace lol */ | } /* namespace lol */ | ||||
@@ -53,7 +53,7 @@ D3d9Input::D3d9Input() | |||||
if (XInputGetState(i, &state) != ERROR_SUCCESS) | if (XInputGetState(i, &state) != ERROR_SUCCESS) | ||||
continue; | continue; | ||||
// TODO: we can put more friendly name here, such as LeftAxisX, ButtonX... | // TODO: we can put more friendly name here, such as LeftAxisX, ButtonX... | ||||
InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C()); | |||||
InputDeviceInternal* stick = new InputDeviceInternal(String::format("Joystick%d", i+1).C()); | |||||
stick->AddAxis(g_name_xbox_axis_left_x.C()); | stick->AddAxis(g_name_xbox_axis_left_x.C()); | ||||
stick->AddAxis(g_name_xbox_axis_left_y.C()); | stick->AddAxis(g_name_xbox_axis_left_y.C()); | ||||
@@ -77,7 +77,7 @@ D3d9Input::D3d9Input() | |||||
stick->AddKey(g_name_xbox_key_x.C()); | stick->AddKey(g_name_xbox_key_x.C()); | ||||
stick->AddKey(g_name_xbox_key_y.C()); | stick->AddKey(g_name_xbox_key_y.C()); | ||||
m_data->m_joysticks.Push(i, stick); | |||||
m_data->m_joysticks.push(i, stick); | |||||
} | } | ||||
#endif | #endif | ||||
@@ -88,10 +88,10 @@ D3d9Input::~D3d9Input() | |||||
{ | { | ||||
#if defined USE_XINPUT | #if defined USE_XINPUT | ||||
/* Unregister all the joysticks we added */ | /* Unregister all the joysticks we added */ | ||||
while (m_data->m_joysticks.Count()) | |||||
while (m_data->m_joysticks.count()) | |||||
{ | { | ||||
delete m_data->m_joysticks[0].m2; | delete m_data->m_joysticks[0].m2; | ||||
m_data->m_joysticks.Remove(0); | |||||
m_data->m_joysticks.remove(0); | |||||
} | } | ||||
#endif | #endif | ||||
delete m_data; | delete m_data; | ||||
@@ -102,7 +102,7 @@ void D3d9Input::TickGame(float seconds) | |||||
Entity::TickGame(seconds); | Entity::TickGame(seconds); | ||||
#if defined USE_XINPUT | #if defined USE_XINPUT | ||||
for (int i = 0; i < m_data->m_joysticks.Count(); i++) | |||||
for (int i = 0; i < m_data->m_joysticks.count(); i++) | |||||
{ | { | ||||
XINPUT_STATE state; | XINPUT_STATE state; | ||||
if (XInputGetState(m_data->m_joysticks[i].m1, &state) != ERROR_SUCCESS) | if (XInputGetState(m_data->m_joysticks[i].m1, &state) != ERROR_SUCCESS) | ||||
@@ -80,11 +80,11 @@ bool NaClInstance::Init(uint32_t argc, | |||||
main_mutex.Lock(); | main_mutex.Lock(); | ||||
char *env[] = { nullptr }; | char *env[] = { nullptr }; | ||||
Args arglist(argc, const_cast<char **>(argv), const_cast<char **>(env)); | Args arglist(argc, const_cast<char **>(argv), const_cast<char **>(env)); | ||||
main_queue.Push(&arglist); | |||||
main_queue.push(&arglist); | |||||
m_main_thread = new thread(MainRun, nullptr); | m_main_thread = new thread(MainRun, nullptr); | ||||
/* Push so that only MainSignal() can unblock us */ | /* Push so that only MainSignal() can unblock us */ | ||||
main_queue.Push(nullptr); | |||||
main_queue.Push(nullptr); | |||||
main_queue.push(nullptr); | |||||
main_queue.push(nullptr); | |||||
main_mutex.Unlock(); | main_mutex.Unlock(); | ||||
// My timer callback | // My timer callback | ||||
@@ -101,7 +101,7 @@ bool NaClInstance::Init(uint32_t argc, | |||||
void * NaClInstance::MainRun(void *data) | void * NaClInstance::MainRun(void *data) | ||||
{ | { | ||||
UNUSED(data); | UNUSED(data); | ||||
Args *arglist = main_queue.Pop(); | |||||
Args *arglist = main_queue.pop(); | |||||
/* Call the user's main() function. One of these will work. */ | /* Call the user's main() function. One of these will work. */ | ||||
lol_nacl_main(); | lol_nacl_main(); | ||||
@@ -114,8 +114,8 @@ void * NaClInstance::MainRun(void *data) | |||||
void NaClInstance::MainSignal() | void NaClInstance::MainSignal() | ||||
{ | { | ||||
/* FIXME: find something more elegant. */ | /* FIXME: find something more elegant. */ | ||||
main_queue.Pop(); | |||||
main_queue.Pop(); | |||||
main_queue.pop(); | |||||
main_queue.pop(); | |||||
} | } | ||||
void NaClInstance::HandleMessage(const pp::Var& message) | void NaClInstance::HandleMessage(const pp::Var& message) | ||||
@@ -173,7 +173,7 @@ void NaClInputData::Tick(float seconds) | |||||
ivec2 mousepos = m_mouse->GetCursorPixelPos(0); | ivec2 mousepos = m_mouse->GetCursorPixelPos(0); | ||||
vec2 mousepos_prev = vec2(mousepos); | vec2 mousepos_prev = vec2(mousepos); | ||||
/* Handle keyboard and WM events */ | /* Handle keyboard and WM events */ | ||||
for (int i = 0; i < m_input_events.Count(); ++i) | |||||
for (int i = 0; i < m_input_events.count(); ++i) | |||||
{ | { | ||||
pp::InputEvent &e = m_input_events[i]; | pp::InputEvent &e = m_input_events[i]; | ||||
switch (e.GetType()) | switch (e.GetType()) | ||||
@@ -223,7 +223,7 @@ void NaClInputData::Tick(float seconds) | |||||
} | } | ||||
} | } | ||||
} | } | ||||
m_input_events.Empty(); | |||||
m_input_events.empty(); | |||||
/* Handle mouse input */ | /* Handle mouse input */ | ||||
if (IsViewportSizeValid()) | if (IsViewportSizeValid()) | ||||
@@ -198,13 +198,14 @@ void SdlAppDisplay::Disable() | |||||
} | } | ||||
#if USE_SDL | #if USE_SDL | ||||
ptrdiff_t SceneDisplay::GetPhysicalCount() | |||||
int SceneDisplay::GetPhysicalCount() | |||||
{ | { | ||||
return (ptrdiff_t)SDL_GetNumVideoDisplays(); | |||||
return SDL_GetNumVideoDisplays(); | |||||
} | } | ||||
const char* SceneDisplay::GetPhysicalName(ptrdiff_t index) | |||||
const char* SceneDisplay::GetPhysicalName(int index) | |||||
{ | { | ||||
return SDL_GetDisplayName((int)index); | |||||
return SDL_GetDisplayName(index); | |||||
} | } | ||||
#elif USE_OLD_SDL && USE_D3D9 | #elif USE_OLD_SDL && USE_D3D9 | ||||
// Not implemented | // Not implemented | ||||
@@ -74,7 +74,7 @@ static int sdl12_to_scancode(int ch, int sc) | |||||
case id: return String(str); | case id: return String(str); | ||||
# include "input/keys.h" | # include "input/keys.h" | ||||
default: | default: | ||||
Log::Error(Line("ScanCodeToText unknown scancode %0d."), sc); | |||||
Log::Error("ScanCodeToText unknown scancode %0d\n", sc); | |||||
} | } | ||||
return String(); | return String(); | ||||
} | } | ||||
@@ -87,7 +87,7 @@ static int sdl12_to_scancode(int ch, int sc) | |||||
case id: return String(#name); | case id: return String(#name); | ||||
# include "input/keys.h" | # include "input/keys.h" | ||||
default: | default: | ||||
Log::Error(Line("ScanCodeToText unknown scancode %0d."), sc); | |||||
Log::Error("ScanCodeToText unknown scancode %0d\n", sc); | |||||
} | } | ||||
return String(); | return String(); | ||||
} | } | ||||
@@ -187,13 +187,13 @@ SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h) | |||||
continue; | continue; | ||||
} | } | ||||
InputDeviceInternal* stick = new InputDeviceInternal(String::Printf("Joystick%d", i+1).C()); | |||||
InputDeviceInternal* stick = new InputDeviceInternal(String::format("Joystick%d", i+1).C()); | |||||
for (int j = 0; j < SDL_JoystickNumAxes(sdlstick); ++j) | for (int j = 0; j < SDL_JoystickNumAxes(sdlstick); ++j) | ||||
stick->AddAxis(String::Printf("Axis%d", j + 1).C()); | |||||
stick->AddAxis(String::format("Axis%d", j + 1).C()); | |||||
for (int j = 0; j < SDL_JoystickNumButtons(sdlstick); ++j) | for (int j = 0; j < SDL_JoystickNumButtons(sdlstick); ++j) | ||||
stick->AddKey(String::Printf("Button%d", j + 1).C()); | |||||
stick->AddKey(String::format("Button%d", j + 1).C()); | |||||
m_data->m_joysticks.Push(sdlstick, stick); | |||||
m_data->m_joysticks.push(sdlstick, stick); | |||||
} | } | ||||
# endif //EMSCRIPTEN | # endif //EMSCRIPTEN | ||||
#endif | #endif | ||||
@@ -205,11 +205,11 @@ SdlInput::~SdlInput() | |||||
{ | { | ||||
#if (USE_SDL || USE_OLD_SDL) && !EMSCRIPTEN | #if (USE_SDL || USE_OLD_SDL) && !EMSCRIPTEN | ||||
/* Unregister all the joysticks we added */ | /* Unregister all the joysticks we added */ | ||||
while (m_data->m_joysticks.Count()) | |||||
while (m_data->m_joysticks.count()) | |||||
{ | { | ||||
SDL_JoystickClose(m_data->m_joysticks[0].m1); | SDL_JoystickClose(m_data->m_joysticks[0].m1); | ||||
delete m_data->m_joysticks[0].m2; | delete m_data->m_joysticks[0].m2; | ||||
m_data->m_joysticks.Remove(0); | |||||
m_data->m_joysticks.remove(0); | |||||
} | } | ||||
#endif | #endif | ||||
delete m_data; | delete m_data; | ||||
@@ -237,7 +237,7 @@ void SdlInputData::Tick(float seconds) | |||||
/* Pump all joystick events because no event is coming to us. */ | /* Pump all joystick events because no event is coming to us. */ | ||||
# if SDL_FORCE_POLL_JOYSTICK && !EMSCRIPTEN | # if SDL_FORCE_POLL_JOYSTICK && !EMSCRIPTEN | ||||
SDL_JoystickUpdate(); | SDL_JoystickUpdate(); | ||||
for (int j = 0; j < m_joysticks.Count(); j++) | |||||
for (int j = 0; j < m_joysticks.count(); j++) | |||||
{ | { | ||||
for (int i = 0; i < SDL_JoystickNumButtons(m_joysticks[j].m1); i++) | for (int i = 0; i < SDL_JoystickNumButtons(m_joysticks[j].m1); i++) | ||||
m_joysticks[j].m2->SetKey(i, SDL_JoystickGetButton(m_joysticks[j].m1, i) != 0); | m_joysticks[j].m2->SetKey(i, SDL_JoystickGetButton(m_joysticks[j].m1, i) != 0); | ||||
@@ -290,7 +290,7 @@ void SdlInputData::Tick(float seconds) | |||||
} | } | ||||
m_keyboard->SetKey(sc2, !m_keyboard->GetKey(sc2)); | m_keyboard->SetKey(sc2, !m_keyboard->GetKey(sc2)); | ||||
/* DEBUG STUFF | /* DEBUG STUFF | ||||
Log::Info(Line("Repeat: 0x%02x : %s/%s/%s/%i"), | |||||
Log::Info("Repeat: 0x%02x : %s/%s/%s/%i\n", | |||||
(int)m_keyboard, ScanCodeToText(sc2).C(), ScanCodeToName(sc2).C(), | (int)m_keyboard, ScanCodeToText(sc2).C(), ScanCodeToName(sc2).C(), | ||||
m_keyboard->GetKey(sc2) ? "up" : "down", event.key.repeat); | m_keyboard->GetKey(sc2) ? "up" : "down", event.key.repeat); | ||||
*/ | */ | ||||
@@ -311,13 +311,13 @@ void SdlInputData::Tick(float seconds) | |||||
&& !m_keyboard->GetKey(SDLOL_LAlt)) | && !m_keyboard->GetKey(SDLOL_LAlt)) | ||||
{ | { | ||||
String str = ScanCodeToText(sc); | String str = ScanCodeToText(sc); | ||||
str.CaseChange(m_keyboard->GetKey(SDLOL_CapsLockStatus) | |||||
^ (m_keyboard->GetKey(SDLOL_RShift) | |||||
|| m_keyboard->GetKey(SDLOL_LShift))); | |||||
str.case_change(m_keyboard->GetKey(SDLOL_CapsLockStatus) | |||||
^ (m_keyboard->GetKey(SDLOL_RShift) | |||||
|| m_keyboard->GetKey(SDLOL_LShift))); | |||||
m_keyboard->AddText(str); | m_keyboard->AddText(str); | ||||
} | } | ||||
/* DEBUG STUFF | /* DEBUG STUFF | ||||
Log::Info(Line("Repeat: 0x%02x : %s/%s/%s/%i"), | |||||
Log::Info("Repeat: 0x%02x : %s/%s/%s/%i\n", | |||||
(int)m_keyboard, ScanCodeToText(sc).C(), ScanCodeToName(sc).C(), | (int)m_keyboard, ScanCodeToText(sc).C(), ScanCodeToName(sc).C(), | ||||
event.type == SDL_KEYDOWN ? "up" : "down", event.key.repeat); | event.type == SDL_KEYDOWN ? "up" : "down", event.key.repeat); | ||||
*/ | */ | ||||
@@ -51,7 +51,7 @@ XboxInput::XboxInput() | |||||
Stick *stick = Input::CreateStick(); | Stick *stick = Input::CreateStick(); | ||||
stick->SetAxisCount(4); | stick->SetAxisCount(4); | ||||
stick->SetButtonCount(16); | stick->SetButtonCount(16); | ||||
m_data->m_joysticks.Push(i, stick); | |||||
m_data->m_joysticks.push(i, stick); | |||||
} | } | ||||
#endif | #endif | ||||
@@ -62,10 +62,10 @@ XboxInput::~XboxInput() | |||||
{ | { | ||||
#if defined _XBOX | #if defined _XBOX | ||||
/* Unregister all the joysticks we added */ | /* Unregister all the joysticks we added */ | ||||
while (m_data->m_joysticks.Count()) | |||||
while (m_data->m_joysticks.count()) | |||||
{ | { | ||||
Input::DestroyStick(m_data->m_joysticks[0].m2); | Input::DestroyStick(m_data->m_joysticks[0].m2); | ||||
m_data->m_joysticks.Remove(0); | |||||
m_data->m_joysticks.remove(0); | |||||
} | } | ||||
#endif | #endif | ||||
delete m_data; | delete m_data; | ||||
@@ -81,7 +81,7 @@ void XboxInput::TickDraw(float seconds, Scene &scene) | |||||
Entity::TickDraw(seconds, scene); | Entity::TickDraw(seconds, scene); | ||||
#if defined _XBOX | #if defined _XBOX | ||||
for (int i = 0; i < m_data->m_joysticks.Count(); i++) | |||||
for (int i = 0; i < m_data->m_joysticks.count(); i++) | |||||
{ | { | ||||
XINPUT_STATE state; | XINPUT_STATE state; | ||||
if (XInputGetState(m_data->m_joysticks[i].m1, &state) != ERROR_SUCCESS) | if (XInputGetState(m_data->m_joysticks[i].m1, &state) != ERROR_SUCCESS) | ||||
@@ -56,10 +56,9 @@ Sample::Sample(char const *path) | |||||
data->m_name = String("<sample> ") + path; | data->m_name = String("<sample> ") + path; | ||||
#if defined USE_SDL_MIXER | #if defined USE_SDL_MIXER | ||||
array<String> pathlist = System::GetPathList(path); | |||||
for (int i = 0; i < pathlist.Count(); ++i) | |||||
for (auto candidate : System::GetPathList(path)) | |||||
{ | { | ||||
data->m_chunk = Mix_LoadWAV(pathlist[i].C()); | |||||
data->m_chunk = Mix_LoadWAV(candidate.C()); | |||||
if (data->m_chunk) | if (data->m_chunk) | ||||
break; | break; | ||||
} | } | ||||
@@ -56,11 +56,12 @@ void SceneDisplay::Add(SceneDisplay* display) | |||||
{ | { | ||||
m_scene_displays << display; | m_scene_displays << display; | ||||
} | } | ||||
ptrdiff_t SceneDisplay::GetCount() | |||||
int SceneDisplay::GetCount() | |||||
{ | { | ||||
return m_scene_displays.count(); | return m_scene_displays.count(); | ||||
} | } | ||||
SceneDisplay* SceneDisplay::GetDisplay(ptrdiff_t index) | |||||
SceneDisplay* SceneDisplay::GetDisplay(int index) | |||||
{ | { | ||||
ASSERT(0 <= index && index < m_scene_displays.count()); | ASSERT(0 <= index && index < m_scene_displays.count()); | ||||
return m_scene_displays[index]; | return m_scene_displays[index]; | ||||
@@ -69,7 +70,7 @@ void SceneDisplay::DestroyAll() | |||||
{ | { | ||||
for (SceneDisplay* display : m_scene_displays) | for (SceneDisplay* display : m_scene_displays) | ||||
delete display; | delete display; | ||||
m_scene_displays.Empty(); | |||||
m_scene_displays.empty(); | |||||
} | } | ||||
/* ------------------------------------------------ */ | /* ------------------------------------------------ */ | ||||
@@ -206,29 +207,32 @@ void Scene::AddNew(ivec2 size) | |||||
{ | { | ||||
Scene::g_scenes << new Scene(size); | Scene::g_scenes << new Scene(size); | ||||
} | } | ||||
void Scene::DestroyScene(Scene* scene) | void Scene::DestroyScene(Scene* scene) | ||||
{ | { | ||||
Scene::g_scenes.remove_item(scene); | Scene::g_scenes.remove_item(scene); | ||||
delete scene; | delete scene; | ||||
} | } | ||||
void Scene::DestroyAll() | void Scene::DestroyAll() | ||||
{ | { | ||||
while (Scene::g_scenes.count()) | while (Scene::g_scenes.count()) | ||||
delete Scene::g_scenes.pop(); | delete Scene::g_scenes.pop(); | ||||
} | } | ||||
ptrdiff_t Scene::GetCount() | |||||
int Scene::GetCount() | |||||
{ | { | ||||
return g_scenes.count(); | return g_scenes.count(); | ||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
bool Scene::IsReady(ptrdiff_t index) | |||||
bool Scene::IsReady(int index) | |||||
{ | { | ||||
return 0 <= index && index < g_scenes.count() && !!g_scenes[index]; | return 0 <= index && index < g_scenes.count() && !!g_scenes[index]; | ||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
Scene& Scene::GetScene(ptrdiff_t index) | |||||
Scene& Scene::GetScene(int index) | |||||
{ | { | ||||
ASSERT(0 <= index && index < g_scenes.count() && !!g_scenes[index], "Trying to get a non-existent scene"); | ASSERT(0 <= index && index < g_scenes.count() && !!g_scenes[index], "Trying to get a non-existent scene"); | ||||
return *g_scenes[index]; | return *g_scenes[index]; | ||||
@@ -251,9 +255,9 @@ Camera* Scene::GetCamera(int cam_idx) | |||||
{ | { | ||||
ASSERT(!!data, "Trying to access a non-ready scene"); | ASSERT(!!data, "Trying to access a non-ready scene"); | ||||
return (0 <= cam_idx && cam_idx < data->m_camera_stack.Count()) ? | |||||
return (0 <= cam_idx && cam_idx < data->m_camera_stack.count()) ? | |||||
data->m_camera_stack[cam_idx] : | data->m_camera_stack[cam_idx] : | ||||
data->m_camera_stack.Last(); | |||||
data->m_camera_stack.last(); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -262,8 +266,8 @@ int Scene::PushCamera(Camera *cam) | |||||
ASSERT(!!data, "Trying to access a non-ready scene"); | ASSERT(!!data, "Trying to access a non-ready scene"); | ||||
Ticker::Ref(cam); | Ticker::Ref(cam); | ||||
data->m_camera_stack.Push(cam); | |||||
return (int)data->m_camera_stack.Count() - 1; | |||||
data->m_camera_stack.push(cam); | |||||
return (int)data->m_camera_stack.count() - 1; | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -273,12 +277,12 @@ void Scene::PopCamera(Camera *cam) | |||||
/* Parse from the end because that’s probably where we’ll find | /* Parse from the end because that’s probably where we’ll find | ||||
* our camera first. */ | * our camera first. */ | ||||
for (ptrdiff_t i = data->m_camera_stack.Count(); i--;) | |||||
for (int i = data->m_camera_stack.count(); i--;) | |||||
{ | { | ||||
if (data->m_camera_stack[i] == cam) | if (data->m_camera_stack[i] == cam) | ||||
{ | { | ||||
Ticker::Unref(cam); | Ticker::Unref(cam); | ||||
data->m_camera_stack.Remove(i); | |||||
data->m_camera_stack.remove(i); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
@@ -303,22 +307,22 @@ void Scene::Reset() | |||||
array<uintptr_t> keys = data->m_prim_renderers.keys(); | array<uintptr_t> keys = data->m_prim_renderers.keys(); | ||||
for (uintptr_t key : keys) | for (uintptr_t key : keys) | ||||
{ | { | ||||
for (ptrdiff_t idx = 0; idx < data->m_prim_renderers[key].count(); ++idx) | |||||
for (int idx = 0; idx < data->m_prim_renderers[key].count(); ++idx) | |||||
if (data->m_prim_renderers[key][idx]->m_fire_and_forget) | if (data->m_prim_renderers[key][idx]->m_fire_and_forget) | ||||
ReleasePrimitiveRenderer(idx--, key); | ReleasePrimitiveRenderer(idx--, key); | ||||
} | } | ||||
for (int i = 0; i < data->m_tile_bufs.Count(); i++) | |||||
for (int i = 0; i < data->m_tile_bufs.count(); i++) | |||||
delete data->m_tile_bufs[i]; | delete data->m_tile_bufs[i]; | ||||
data->m_tile_bufs.Empty(); | |||||
data->m_tile_bufs.empty(); | |||||
data->m_lights.Empty(); | |||||
data->m_lights.empty(); | |||||
} | } | ||||
//---- Primitive source stuff ------------------------------------------------- | //---- Primitive source stuff ------------------------------------------------- | ||||
ptrdiff_t Scene::HasPrimitiveSource(uintptr_t key) | |||||
int Scene::HasPrimitiveSource(uintptr_t key) | |||||
{ | { | ||||
ptrdiff_t count; | |||||
int count; | |||||
SceneData::m_prim_mutex.lock(); | SceneData::m_prim_mutex.lock(); | ||||
{ | { | ||||
count = SceneData::m_prim_sources[key].count(); | count = SceneData::m_prim_sources[key].count(); | ||||
@@ -326,9 +330,9 @@ ptrdiff_t Scene::HasPrimitiveSource(uintptr_t key) | |||||
SceneData::m_prim_mutex.unlock(); | SceneData::m_prim_mutex.unlock(); | ||||
return count; | return count; | ||||
} | } | ||||
ptrdiff_t Scene::AddPrimitiveSource(uintptr_t key, PrimitiveSource* source) | |||||
int Scene::AddPrimitiveSource(uintptr_t key, PrimitiveSource* source) | |||||
{ | { | ||||
ptrdiff_t count; | |||||
int count; | |||||
SceneData::m_prim_mutex.lock(); | SceneData::m_prim_mutex.lock(); | ||||
{ | { | ||||
count = SceneData::m_prim_sources[key].count(); | count = SceneData::m_prim_sources[key].count(); | ||||
@@ -337,7 +341,7 @@ ptrdiff_t Scene::AddPrimitiveSource(uintptr_t key, PrimitiveSource* source) | |||||
SceneData::m_prim_mutex.unlock(); | SceneData::m_prim_mutex.unlock(); | ||||
return count; | return count; | ||||
} | } | ||||
void Scene::SetPrimitiveSource(ptrdiff_t index, uintptr_t key, PrimitiveSource* source) | |||||
void Scene::SetPrimitiveSource(int index, uintptr_t key, PrimitiveSource* source) | |||||
{ | { | ||||
ASSERT(source); | ASSERT(source); | ||||
ASSERT(index < 0); | ASSERT(index < 0); | ||||
@@ -355,7 +359,7 @@ void Scene::SetPrimitiveSource(ptrdiff_t index, uintptr_t key, PrimitiveSource* | |||||
//Delete old AFTER having released the lock | //Delete old AFTER having released the lock | ||||
if (old) delete old; | if (old) delete old; | ||||
} | } | ||||
void Scene::ReleasePrimitiveSource(ptrdiff_t index, uintptr_t key) | |||||
void Scene::ReleasePrimitiveSource(int index, uintptr_t key) | |||||
{ | { | ||||
PrimitiveSource* old = nullptr; | PrimitiveSource* old = nullptr; | ||||
SceneData::m_prim_mutex.lock(); | SceneData::m_prim_mutex.lock(); | ||||
@@ -387,7 +391,7 @@ void Scene::ReleaseAllPrimitiveSource(uintptr_t key) | |||||
} | } | ||||
//---- Primitive renderer stuff ----------------------------------------------- | //---- Primitive renderer stuff ----------------------------------------------- | ||||
ptrdiff_t Scene::HasPrimitiveRenderer(uintptr_t key) | |||||
int Scene::HasPrimitiveRenderer(uintptr_t key) | |||||
{ | { | ||||
return data->m_prim_renderers[key].count(); | return data->m_prim_renderers[key].count(); | ||||
} | } | ||||
@@ -396,7 +400,7 @@ void Scene::AddPrimitiveRenderer(uintptr_t key, PrimitiveRenderer* renderer) | |||||
renderer->m_fire_and_forget = true; | renderer->m_fire_and_forget = true; | ||||
data->m_prim_renderers[key].push(renderer); | data->m_prim_renderers[key].push(renderer); | ||||
} | } | ||||
void Scene::SetPrimitiveRenderer(ptrdiff_t index, uintptr_t key, PrimitiveRenderer* renderer) | |||||
void Scene::SetPrimitiveRenderer(int index, uintptr_t key, PrimitiveRenderer* renderer) | |||||
{ | { | ||||
ASSERT(renderer); | ASSERT(renderer); | ||||
ASSERT(index < 0); | ASSERT(index < 0); | ||||
@@ -409,7 +413,7 @@ void Scene::SetPrimitiveRenderer(ptrdiff_t index, uintptr_t key, PrimitiveRender | |||||
data->m_prim_renderers[key].resize(index + 1); | data->m_prim_renderers[key].resize(index + 1); | ||||
data->m_prim_renderers[key][index] = renderer; | data->m_prim_renderers[key][index] = renderer; | ||||
} | } | ||||
void Scene::ReleasePrimitiveRenderer(ptrdiff_t index, uintptr_t key) | |||||
void Scene::ReleasePrimitiveRenderer(int index, uintptr_t key) | |||||
{ | { | ||||
ASSERT(0 <= index && index < data->m_prim_renderers[key].count()); | ASSERT(0 <= index && index < data->m_prim_renderers[key].count()); | ||||
ASSERT(data->m_prim_renderers[key][index]); | ASSERT(data->m_prim_renderers[key][index]); | ||||
@@ -441,9 +445,9 @@ void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale, float | |||||
t.angle = angle; | t.angle = angle; | ||||
if (tileset->GetPalette()) | if (tileset->GetPalette()) | ||||
data->m_palettes.Push(t); | |||||
data->m_palettes.push(t); | |||||
else | else | ||||
data->m_tiles.Push(t); | |||||
data->m_tiles.push(t); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -491,7 +495,7 @@ void Scene::AddLine(vec3 a, vec3 b, vec4 color) | |||||
{ | { | ||||
ASSERT(!!data, "Trying to access a non-ready scene"); | ASSERT(!!data, "Trying to access a non-ready scene"); | ||||
data->m_lines.Push(a, b, color, | |||||
data->m_lines.push(a, b, color, | |||||
data->m_new_line_time, data->m_new_line_mask, false, false); | data->m_new_line_time, data->m_new_line_mask, false, false); | ||||
} | } | ||||
@@ -500,7 +504,7 @@ void Scene::AddLight(Light *l) | |||||
{ | { | ||||
ASSERT(!!data, "Trying to access a non-ready scene"); | ASSERT(!!data, "Trying to access a non-ready scene"); | ||||
data->m_lights.Push(l); | |||||
data->m_lights.push(l); | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
@@ -545,7 +549,7 @@ void Scene::RenderPrimitives() | |||||
array<uintptr_t> keys = data->m_prim_renderers.keys(); | array<uintptr_t> keys = data->m_prim_renderers.keys(); | ||||
for (uintptr_t key : keys) | for (uintptr_t key : keys) | ||||
{ | { | ||||
for (ptrdiff_t idx = 0; idx < data->m_prim_renderers[key].count(); ++idx) | |||||
for (int idx = 0; idx < data->m_prim_renderers[key].count(); ++idx) | |||||
{ | { | ||||
/* TODO: Not sure if thread compliant */ | /* TODO: Not sure if thread compliant */ | ||||
data->m_prim_renderers[key][idx]->Render(*this, idx < SceneData::m_prim_sources[key].count() ? SceneData::m_prim_sources[key][idx] : nullptr); | data->m_prim_renderers[key][idx]->Render(*this, idx < SceneData::m_prim_sources[key].count() ? SceneData::m_prim_sources[key][idx] : nullptr); | ||||
@@ -561,7 +565,7 @@ void Scene::RenderTiles() // XXX: rename to Blit() | |||||
RenderContext rc; | RenderContext rc; | ||||
/* Early test if nothing needs to be rendered */ | /* Early test if nothing needs to be rendered */ | ||||
if (!data->m_tiles.Count() && !data->m_palettes.Count()) | |||||
if (!data->m_tiles.count() && !data->m_palettes.count()) | |||||
return; | return; | ||||
rc.SetDepthFunc(DepthFunc::LessOrEqual); | rc.SetDepthFunc(DepthFunc::LessOrEqual); | ||||
@@ -585,7 +589,7 @@ void Scene::RenderTiles() // XXX: rename to Blit() | |||||
Shader *shader = (p == 0) ? data->m_tile_shader : data->m_palette_shader; | Shader *shader = (p == 0) ? data->m_tile_shader : data->m_palette_shader; | ||||
array<Tile>& tiles = (p == 0) ? data->m_tiles : data->m_palettes; | array<Tile>& tiles = (p == 0) ? data->m_tiles : data->m_palettes; | ||||
if (tiles.Count() == 0) | |||||
if (tiles.count() == 0) | |||||
continue; | continue; | ||||
ShaderUniform uni_mat, uni_tex, uni_pal, uni_texsize; | ShaderUniform uni_mat, uni_tex, uni_pal, uni_texsize; | ||||
@@ -606,10 +610,10 @@ void Scene::RenderTiles() // XXX: rename to Blit() | |||||
uni_pal = data->m_palette_shader->GetUniformLocation("u_palette"); | uni_pal = data->m_palette_shader->GetUniformLocation("u_palette"); | ||||
uni_texsize = shader->GetUniformLocation("u_texsize"); | uni_texsize = shader->GetUniformLocation("u_texsize"); | ||||
for (int buf = 0, i = 0, n; i < tiles.Count(); i = n, buf += 2) | |||||
for (int buf = 0, i = 0, n; i < tiles.count(); i = n, buf += 2) | |||||
{ | { | ||||
/* Count how many quads will be needed */ | /* Count how many quads will be needed */ | ||||
for (n = i + 1; n < tiles.Count(); n++) | |||||
for (n = i + 1; n < tiles.count(); n++) | |||||
if (tiles[i].tileset != tiles[n].tileset) | if (tiles[i].tileset != tiles[n].tileset) | ||||
break; | break; | ||||
@@ -619,8 +623,8 @@ void Scene::RenderTiles() // XXX: rename to Blit() | |||||
VertexBuffer *vb2 = new VertexBuffer(6 * (n - i) * sizeof(vec2)); | VertexBuffer *vb2 = new VertexBuffer(6 * (n - i) * sizeof(vec2)); | ||||
vec2 *texture = (vec2 *)vb2->Lock(0, 0); | vec2 *texture = (vec2 *)vb2->Lock(0, 0); | ||||
data->m_tile_bufs.Push(vb1); | |||||
data->m_tile_bufs.Push(vb2); | |||||
data->m_tile_bufs.push(vb1); | |||||
data->m_tile_bufs.push(vb2); | |||||
for (int j = i; j < n; j++) | for (int j = i; j < n; j++) | ||||
{ | { | ||||
@@ -662,7 +666,7 @@ void Scene::RenderTiles() // XXX: rename to Blit() | |||||
tiles[i].tileset->Unbind(); | tiles[i].tileset->Unbind(); | ||||
} | } | ||||
tiles.Empty(); | |||||
tiles.empty(); | |||||
shader->Unbind(); | shader->Unbind(); | ||||
} | } | ||||
@@ -682,7 +686,7 @@ void Scene::RenderLines(float seconds) // XXX: rename to Blit() | |||||
RenderContext rc; | RenderContext rc; | ||||
if (!data->m_lines.Count()) | |||||
if (!data->m_lines.count()) | |||||
return; | return; | ||||
rc.SetDepthFunc(DepthFunc::LessOrEqual); | rc.SetDepthFunc(DepthFunc::LessOrEqual); | ||||
@@ -690,13 +694,13 @@ void Scene::RenderLines(float seconds) // XXX: rename to Blit() | |||||
rc.SetBlendEquation(BlendEquation::Add, BlendEquation::Max); | rc.SetBlendEquation(BlendEquation::Add, BlendEquation::Max); | ||||
rc.SetAlphaFunc(AlphaFunc::GreaterOrEqual, 0.01f); | rc.SetAlphaFunc(AlphaFunc::GreaterOrEqual, 0.01f); | ||||
int linecount = (int)data->m_lines.Count(); | |||||
int linecount = (int)data->m_lines.count(); | |||||
if (!data->m_line_shader) | if (!data->m_line_shader) | ||||
data->m_line_shader = Shader::Create(LOLFX_RESOURCE_NAME(line)); | data->m_line_shader = Shader::Create(LOLFX_RESOURCE_NAME(line)); | ||||
array<vec4, vec4, vec4, vec4> buff; | array<vec4, vec4, vec4, vec4> buff; | ||||
buff.Resize(linecount); | |||||
buff.resize(linecount); | |||||
int real_linecount = 0; | int real_linecount = 0; | ||||
mat4 const inv_view_proj = inverse(GetCamera()->GetProjection() * GetCamera()->GetView()); | mat4 const inv_view_proj = inverse(GetCamera()->GetProjection() * GetCamera()->GetView()); | ||||
for (int i = 0; i < linecount; i++) | for (int i = 0; i < linecount; i++) | ||||
@@ -712,13 +716,13 @@ void Scene::RenderLines(float seconds) // XXX: rename to Blit() | |||||
data->m_lines[i].m4 -= seconds; | data->m_lines[i].m4 -= seconds; | ||||
if (data->m_lines[i].m4 < 0.f) | if (data->m_lines[i].m4 < 0.f) | ||||
{ | { | ||||
data->m_lines.RemoveSwap(i--); | |||||
data->m_lines.remove_swap(i--); | |||||
linecount--; | linecount--; | ||||
} | } | ||||
} | } | ||||
VertexBuffer *vb = new VertexBuffer(buff.Bytes()); | |||||
VertexBuffer *vb = new VertexBuffer(buff.bytes()); | |||||
float *vertex = (float *)vb->Lock(0, 0); | float *vertex = (float *)vb->Lock(0, 0); | ||||
memcpy(vertex, buff.Data(), buff.Bytes()); | |||||
memcpy(vertex, buff.data(), buff.bytes()); | |||||
vb->Unlock(); | vb->Unlock(); | ||||
data->m_line_shader->Bind(); | data->m_line_shader->Bind(); | ||||
@@ -741,7 +745,7 @@ void Scene::RenderLines(float seconds) // XXX: rename to Blit() | |||||
data->m_line_vdecl->Unbind(); | data->m_line_vdecl->Unbind(); | ||||
data->m_line_shader->Unbind(); | data->m_line_shader->Unbind(); | ||||
//data->m_lines.Empty(); | |||||
//data->m_lines.empty(); | |||||
delete vb; | delete vb; | ||||
} | } | ||||
@@ -70,13 +70,13 @@ public: | |||||
/* TODO: Should that be there or in Video ? */ | /* TODO: Should that be there or in Video ? */ | ||||
static void Add(SceneDisplay* display); | static void Add(SceneDisplay* display); | ||||
static ptrdiff_t GetCount(); | |||||
static SceneDisplay* GetDisplay(ptrdiff_t index = 0); | |||||
static int GetCount(); | |||||
static SceneDisplay* GetDisplay(int index = 0); | |||||
static void DestroyAll(); | static void DestroyAll(); | ||||
/* Implement these in the platform section */ | /* Implement these in the platform section */ | ||||
static ptrdiff_t GetPhysicalCount(); | |||||
static const char* GetPhysicalName(ptrdiff_t index = 0); | |||||
static int GetPhysicalCount(); | |||||
static const char* GetPhysicalName(int index = 0); | |||||
//protected: | //protected: | ||||
virtual void Enable(); | virtual void Enable(); | ||||
@@ -106,9 +106,9 @@ private: //Private because I don't know if we should have it | |||||
private: | private: | ||||
static void DestroyAll(); | static void DestroyAll(); | ||||
public: | public: | ||||
static ptrdiff_t GetCount(); | |||||
static bool IsReady(ptrdiff_t index = 0); | |||||
static Scene& GetScene(ptrdiff_t index = 0); | |||||
static int GetCount(); | |||||
static bool IsReady(int index = 0); | |||||
static Scene& GetScene(int index = 0); | |||||
public: | public: | ||||
//TODO: don't like the name | //TODO: don't like the name | ||||
@@ -127,16 +127,16 @@ public: | |||||
# define _KEY_IDX (uintptr_t)key /* TOUKY: I don't like that. hash should be fixed to handle these custom stuff */ | # define _KEY_IDX (uintptr_t)key /* TOUKY: I don't like that. hash should be fixed to handle these custom stuff */ | ||||
/* ============================== */ | /* ============================== */ | ||||
private: | private: | ||||
ptrdiff_t HasPrimitiveSource(uintptr_t key); | |||||
ptrdiff_t AddPrimitiveSource(uintptr_t key, class PrimitiveSource* source); | |||||
void SetPrimitiveSource(ptrdiff_t index, uintptr_t key, class PrimitiveSource* source); | |||||
void ReleasePrimitiveSource(ptrdiff_t index, uintptr_t key); | |||||
int HasPrimitiveSource(uintptr_t key); | |||||
int AddPrimitiveSource(uintptr_t key, class PrimitiveSource* source); | |||||
void SetPrimitiveSource(int index, uintptr_t key, class PrimitiveSource* source); | |||||
void ReleasePrimitiveSource(int index, uintptr_t key); | |||||
void ReleaseAllPrimitiveSource(uintptr_t key); | void ReleaseAllPrimitiveSource(uintptr_t key); | ||||
public: | public: | ||||
/* === Primitive source stuff === */ | /* === Primitive source stuff === */ | ||||
/* Returns the number of primitive source set to the given entity */ | /* Returns the number of primitive source set to the given entity */ | ||||
template <typename T> | template <typename T> | ||||
ptrdiff_t HasPrimitiveSource(T* key) | |||||
int HasPrimitiveSource(T* key) | |||||
{ | { | ||||
ASSERT(key); | ASSERT(key); | ||||
return HasPrimitiveSource(_KEY_IDX); | return HasPrimitiveSource(_KEY_IDX); | ||||
@@ -144,7 +144,7 @@ public: | |||||
/* Add a primitive sources linked to the given entity | /* Add a primitive sources linked to the given entity | ||||
* Returns the slot number */ | * Returns the slot number */ | ||||
template <typename T> | template <typename T> | ||||
ptrdiff_t AddPrimitiveSource(T* key, class PrimitiveSource* source) | |||||
int AddPrimitiveSource(T* key, class PrimitiveSource* source) | |||||
{ | { | ||||
ASSERT(key); | ASSERT(key); | ||||
return AddPrimitiveSource(_KEY_IDX, source); | return AddPrimitiveSource(_KEY_IDX, source); | ||||
@@ -153,14 +153,14 @@ public: | |||||
* Deletes the old one | * Deletes the old one | ||||
* The slot is kept even if source == nullptr */ | * The slot is kept even if source == nullptr */ | ||||
template <typename T> | template <typename T> | ||||
void SetPrimitiveSource(ptrdiff_t index, T* key, class PrimitiveSource* source) | |||||
void SetPrimitiveSource(int index, T* key, class PrimitiveSource* source) | |||||
{ | { | ||||
ASSERT(key); | ASSERT(key); | ||||
SetPrimitiveSource(index, _KEY_IDX, source); | SetPrimitiveSource(index, _KEY_IDX, source); | ||||
} | } | ||||
/* Remove primitive source at index set to the given entity */ | /* Remove primitive source at index set to the given entity */ | ||||
template <typename T> | template <typename T> | ||||
void ReleasePrimitiveSource(ptrdiff_t index, T* key) | |||||
void ReleasePrimitiveSource(int index, T* key) | |||||
{ | { | ||||
ASSERT(key); | ASSERT(key); | ||||
ReleasePrimitiveSource(index, _KEY_IDX); | ReleasePrimitiveSource(index, _KEY_IDX); | ||||
@@ -174,16 +174,16 @@ public: | |||||
} | } | ||||
private: | private: | ||||
ptrdiff_t HasPrimitiveRenderer(uintptr_t key); | |||||
int HasPrimitiveRenderer(uintptr_t key); | |||||
void AddPrimitiveRenderer(uintptr_t key, class PrimitiveRenderer* renderer); | void AddPrimitiveRenderer(uintptr_t key, class PrimitiveRenderer* renderer); | ||||
void SetPrimitiveRenderer(ptrdiff_t index, uintptr_t key, class PrimitiveRenderer* renderer); | |||||
void ReleasePrimitiveRenderer(ptrdiff_t index, uintptr_t key); | |||||
void SetPrimitiveRenderer(int index, uintptr_t key, class PrimitiveRenderer* renderer); | |||||
void ReleasePrimitiveRenderer(int index, uintptr_t key); | |||||
void ReleaseAllPrimitiveRenderer(uintptr_t key); | void ReleaseAllPrimitiveRenderer(uintptr_t key); | ||||
public: | public: | ||||
/* === Primitive renderer stuff === */ | /* === Primitive renderer stuff === */ | ||||
/* Returns the number of primitive renderer set to the given entity */ | /* Returns the number of primitive renderer set to the given entity */ | ||||
template <typename T> | template <typename T> | ||||
ptrdiff_t HasPrimitiveRenderer(T* key) | |||||
int HasPrimitiveRenderer(T* key) | |||||
{ | { | ||||
ASSERT(key); | ASSERT(key); | ||||
return HasPrimitiveRenderer(_KEY_IDX); | return HasPrimitiveRenderer(_KEY_IDX); | ||||
@@ -201,14 +201,14 @@ public: | |||||
* Deletes the old one | * Deletes the old one | ||||
* Will assert if renderer == nullptr */ | * Will assert if renderer == nullptr */ | ||||
template <typename T> | template <typename T> | ||||
void SetPrimitiveRenderer(ptrdiff_t index, T* key, class PrimitiveRenderer* renderer) | |||||
void SetPrimitiveRenderer(int index, T* key, class PrimitiveRenderer* renderer) | |||||
{ | { | ||||
ASSERT(key && renderer); | ASSERT(key && renderer); | ||||
SetPrimitiveRenderer(index, _KEY_IDX, renderer); | SetPrimitiveRenderer(index, _KEY_IDX, renderer); | ||||
} | } | ||||
/* Remove primitive renderer at index set to the given entity */ | /* Remove primitive renderer at index set to the given entity */ | ||||
template <typename T> | template <typename T> | ||||
void ReleasePrimitiveRenderer(ptrdiff_t index, T* key) | |||||
void ReleasePrimitiveRenderer(int index, T* key) | |||||
{ | { | ||||
ASSERT(key); | ASSERT(key); | ||||
ReleasePrimitiveRenderer(index, _KEY_IDX); | ReleasePrimitiveRenderer(index, _KEY_IDX); | ||||
@@ -120,20 +120,20 @@ class FileData | |||||
String ReadString() | String ReadString() | ||||
{ | { | ||||
array<uint8_t> buf; | array<uint8_t> buf; | ||||
buf.Resize(BUFSIZ); | |||||
buf.resize(BUFSIZ); | |||||
String ret; | String ret; | ||||
while (IsValid()) | while (IsValid()) | ||||
{ | { | ||||
int done = Read(&buf[0], (int)buf.Count()); | |||||
int done = Read(&buf[0], buf.count()); | |||||
if (done <= 0) | if (done <= 0) | ||||
break; | break; | ||||
int oldsize = (int)ret.Count(); | |||||
ret.Resize(oldsize + done); | |||||
int oldsize = ret.count(); | |||||
ret.resize(oldsize + done); | |||||
memcpy(&ret[oldsize], &buf[0], done); | memcpy(&ret[oldsize], &buf[0], done); | ||||
buf.Resize(buf.Count() * 3 / 2); | |||||
buf.resize(buf.count() * 3 / 2); | |||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
@@ -148,7 +148,7 @@ class FileData | |||||
if (done <= 0) | if (done <= 0) | ||||
return -1; | return -1; | ||||
return (int)done; | |||||
return done; | |||||
#else | #else | ||||
return 0; | return 0; | ||||
#endif | #endif | ||||
@@ -156,7 +156,7 @@ class FileData | |||||
int WriteString(const String &buf) | int WriteString(const String &buf) | ||||
{ | { | ||||
return Write((uint8_t const *)buf.C(), (int)buf.Count()); | |||||
return Write((uint8_t const *)buf.C(), buf.count()); | |||||
} | } | ||||
long int GetPosFromStart() | long int GetPosFromStart() | ||||
@@ -355,7 +355,7 @@ class DirectoryData | |||||
#elif defined(_WIN32) | #elif defined(_WIN32) | ||||
m_directory = directory; | m_directory = directory; | ||||
String filter = m_directory + String("*"); | String filter = m_directory + String("*"); | ||||
filter.Replace('/', '\\', true); | |||||
filter.replace('/', '\\', true); | |||||
WIN32_FIND_DATA FindFileData; | WIN32_FIND_DATA FindFileData; | ||||
m_handle = FindFirstFile(filter.C(), &FindFileData); | m_handle = FindFirstFile(filter.C(), &FindFileData); | ||||
stat(directory.C(), &m_stat); | stat(directory.C(), &m_stat); | ||||
@@ -399,7 +399,7 @@ class DirectoryData | |||||
/* FIXME: not implemented */ | /* FIXME: not implemented */ | ||||
#elif defined(_WIN32) | #elif defined(_WIN32) | ||||
String filter = m_directory + String("*"); | String filter = m_directory + String("*"); | ||||
filter.Replace('/', '\\', true); | |||||
filter.replace('/', '\\', true); | |||||
WIN32_FIND_DATA find_data; | WIN32_FIND_DATA find_data; | ||||
HANDLE handle = FindFirstFile(filter.C(), &find_data); | HANDLE handle = FindFirstFile(filter.C(), &find_data); | ||||
bool file_valid = (handle != INVALID_HANDLE_VALUE); | bool file_valid = (handle != INVALID_HANDLE_VALUE); | ||||
@@ -426,7 +426,7 @@ class DirectoryData | |||||
#elif HAVE_STDIO_H | #elif HAVE_STDIO_H | ||||
/* FIXME: not implemented */ | /* FIXME: not implemented */ | ||||
#endif | #endif | ||||
return ((files && files->Count()) || (directories && directories->Count())); | |||||
return ((files && files->count()) || (directories && directories->count())); | |||||
} | } | ||||
inline bool IsValid() const | inline bool IsValid() const | ||||
@@ -539,14 +539,14 @@ bool Directory::GetContent(array<String>* files, array<Directory>* directories) | |||||
bool found_some = m_data->GetContentList(&sfiles, &sdirectories); | bool found_some = m_data->GetContentList(&sfiles, &sdirectories); | ||||
if (directories) | if (directories) | ||||
for (int i = 0; i < sdirectories.Count(); i++) | |||||
directories->Push(Directory(m_name + sdirectories[i])); | |||||
for (int i = 0; i < sdirectories.count(); i++) | |||||
directories->push(Directory(m_name + sdirectories[i])); | |||||
if (files) | if (files) | ||||
for (int i = 0; i < sfiles.Count(); i++) | |||||
files->Push(m_name + sfiles[i]); | |||||
for (int i = 0; i < sfiles.count(); i++) | |||||
files->push(m_name + sfiles[i]); | |||||
return (files && files->Count()) || (directories || directories->Count()); | |||||
return (files && files->count()) || (directories || directories->count()); | |||||
} | } | ||||
//-- | //-- | ||||
@@ -589,7 +589,7 @@ String Directory::GetCurrent() | |||||
TCHAR buff[MAX_PATH * 2]; | TCHAR buff[MAX_PATH * 2]; | ||||
GetCurrentDirectory(MAX_PATH, buff); | GetCurrentDirectory(MAX_PATH, buff); | ||||
result = buff; | result = buff; | ||||
result.Replace('\\', '/', true); | |||||
result.replace('\\', '/', true); | |||||
#elif HAVE_STDIO_H | #elif HAVE_STDIO_H | ||||
/* FIXME: not implemented */ | /* FIXME: not implemented */ | ||||
#endif | #endif | ||||
@@ -603,7 +603,7 @@ bool Directory::SetCurrent(String directory) | |||||
/* FIXME: not implemented */ | /* FIXME: not implemented */ | ||||
#elif defined(_WIN32) | #elif defined(_WIN32) | ||||
String result = directory; | String result = directory; | ||||
result.Replace('/', '\\', true); | |||||
result.replace('/', '\\', true); | |||||
return !!SetCurrentDirectory(result.C()); | return !!SetCurrentDirectory(result.C()); | ||||
#elif HAVE_STDIO_H | #elif HAVE_STDIO_H | ||||
/* FIXME: not implemented */ | /* FIXME: not implemented */ | ||||
@@ -86,24 +86,24 @@ void Init(int argc, char *argv[], | |||||
* add current directory in case we were launched from another place. | * add current directory in case we were launched from another place. | ||||
*/ | */ | ||||
if (!got_rootdir && projectdir.Count() && solutiondir.Count()) | |||||
if (!got_rootdir && projectdir.count() && solutiondir.count()) | |||||
{ | { | ||||
/* This data dir is for standalone executables */ | /* This data dir is for standalone executables */ | ||||
String rootdir = binarydir; | String rootdir = binarydir; | ||||
if (rootdir.Count() && rootdir.Last() != SEPARATOR) | |||||
if (rootdir.count() && rootdir.last() != SEPARATOR) | |||||
rootdir += SEPARATOR; | rootdir += SEPARATOR; | ||||
AddDataDir(rootdir); | AddDataDir(rootdir); | ||||
/* This data dir is for engine stuff */ | /* This data dir is for engine stuff */ | ||||
rootdir = solutiondir; | rootdir = solutiondir; | ||||
if (rootdir.Count() && rootdir.Last() != SEPARATOR) | |||||
if (rootdir.count() && rootdir.last() != SEPARATOR) | |||||
rootdir += SEPARATOR; | rootdir += SEPARATOR; | ||||
rootdir += "../src/"; /* FIXME: use SEPARATOR? */ | rootdir += "../src/"; /* FIXME: use SEPARATOR? */ | ||||
AddDataDir(rootdir); | AddDataDir(rootdir); | ||||
/* This data dir is for project-specific stuff */ | /* This data dir is for project-specific stuff */ | ||||
rootdir = projectdir; | rootdir = projectdir; | ||||
if (rootdir.Count() && rootdir.Last() != SEPARATOR) | |||||
if (rootdir.count() && rootdir.last() != SEPARATOR) | |||||
rootdir += SEPARATOR; | rootdir += SEPARATOR; | ||||
AddDataDir(rootdir); | AddDataDir(rootdir); | ||||
@@ -119,13 +119,13 @@ void Init(int argc, char *argv[], | |||||
/* First climb back the hierarchy to get to the engine root and | /* First climb back the hierarchy to get to the engine root and | ||||
* add a data dir for engine stuff. */ | * add a data dir for engine stuff. */ | ||||
String rootdir = binarydir; | String rootdir = binarydir; | ||||
if (rootdir.Count() && rootdir.Last() != SEPARATOR) | |||||
if (rootdir.count() && rootdir.last() != SEPARATOR) | |||||
rootdir += SEPARATOR; | rootdir += SEPARATOR; | ||||
for (int i = 1; i < sourcesubdir.Count(); ++i) | |||||
for (int i = 1; i < sourcesubdir.count(); ++i) | |||||
{ | { | ||||
if ((sourcesubdir[i] == SEPARATOR | if ((sourcesubdir[i] == SEPARATOR | ||||
&& sourcesubdir[i - 1] != SEPARATOR) | && sourcesubdir[i - 1] != SEPARATOR) | ||||
|| i == sourcesubdir.Count() - 1) | |||||
|| i == sourcesubdir.count() - 1) | |||||
rootdir += "../"; | rootdir += "../"; | ||||
} | } | ||||
rootdir += "src/"; | rootdir += "src/"; | ||||
@@ -139,8 +139,8 @@ void Init(int argc, char *argv[], | |||||
} | } | ||||
Log::Debug("binary dir: “%s”\n", binarydir.C()); | Log::Debug("binary dir: “%s”\n", binarydir.C()); | ||||
for (int i = 0; i < data_dir.Count(); ++i) | |||||
Log::Debug("data dir %d/%d: “%s”\n", i + 1, data_dir.Count(), | |||||
for (int i = 0; i < data_dir.count(); ++i) | |||||
Log::Debug("data dir %d/%d: “%s”\n", i + 1, data_dir.count(), | |||||
data_dir[i].C()); | data_dir[i].C()); | ||||
} | } | ||||
@@ -157,10 +157,10 @@ array<String> GetPathList(String const &file) | |||||
{ | { | ||||
array<String> ret; | array<String> ret; | ||||
for (int i = 0; i < data_dir.Count(); ++i) | |||||
for (int i = 0; i < data_dir.count(); ++i) | |||||
ret << data_dir[i] + file; | ret << data_dir[i] + file; | ||||
if (ret.Count() == 0) | |||||
if (ret.count() == 0) | |||||
ret << file; | ret << file; | ||||
return ret; | return ret; | ||||
@@ -23,8 +23,8 @@ void DefaultThreadManager::AddJob(ThreadJob* job) | |||||
bool DefaultThreadManager::GetWorkResult(array<ThreadJob*>& results) | bool DefaultThreadManager::GetWorkResult(array<ThreadJob*>& results) | ||||
{ | { | ||||
results += m_job_result; | results += m_job_result; | ||||
m_job_result.Empty(); | |||||
return results.Count() > 0; | |||||
m_job_result.empty(); | |||||
return results.count() > 0; | |||||
} | } | ||||
//FileUpdateTesterJob --------------------------------------------------------- | //FileUpdateTesterJob --------------------------------------------------------- | ||||
@@ -219,7 +219,7 @@ void AsyncImageLoader::TreatResult(ThreadJob* result) | |||||
Image* src = m_images[job->GetPath()]; | Image* src = m_images[job->GetPath()]; | ||||
m_images.remove(job->GetPath()); | m_images.remove(job->GetPath()); | ||||
src->Copy(job->GetImage()); | src->Copy(job->GetImage()); | ||||
m_loaded_images.PushUnique(src); | |||||
m_loaded_images.push_unique(src); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -36,10 +36,10 @@ lolunit_declare_fixture(ArrayTest) | |||||
lolunit_declare_test(ArrayPush) | lolunit_declare_test(ArrayPush) | ||||
{ | { | ||||
array<int> a; | array<int> a; | ||||
a.Push(0); | |||||
a.Push(1); | |||||
a.Push(2); | |||||
a.Push(3); | |||||
a.push(0); | |||||
a.push(1); | |||||
a.push(2); | |||||
a.push(3); | |||||
lolunit_assert_equal(a[0], 0); | lolunit_assert_equal(a[0], 0); | ||||
lolunit_assert_equal(a[1], 1); | lolunit_assert_equal(a[1], 1); | ||||
@@ -101,18 +101,18 @@ lolunit_declare_fixture(ArrayTest) | |||||
{ | { | ||||
array<int> a; | array<int> a; | ||||
a << 0 << 1 << 2 << 3; | a << 0 << 1 << 2 << 3; | ||||
a.Remove(1); | |||||
a.remove(1); | |||||
lolunit_assert_equal(a.Count(), 3); | |||||
lolunit_assert_equal(a.count(), 3); | |||||
lolunit_assert_equal(a[0], 0); | lolunit_assert_equal(a[0], 0); | ||||
lolunit_assert_equal(a[1], 2); | lolunit_assert_equal(a[1], 2); | ||||
lolunit_assert_equal(a[2], 3); | lolunit_assert_equal(a[2], 3); | ||||
array<int> b; | array<int> b; | ||||
b << 0 << 1 << 2 << 3; | b << 0 << 1 << 2 << 3; | ||||
b.Remove(-2); | |||||
b.remove(-2); | |||||
lolunit_assert_equal(b.Count(), 3); | |||||
lolunit_assert_equal(b.count(), 3); | |||||
lolunit_assert_equal(b[0], 0); | lolunit_assert_equal(b[0], 0); | ||||
lolunit_assert_equal(b[1], 1); | lolunit_assert_equal(b[1], 1); | ||||
lolunit_assert_equal(b[2], 3); | lolunit_assert_equal(b[2], 3); | ||||
@@ -122,18 +122,18 @@ lolunit_declare_fixture(ArrayTest) | |||||
{ | { | ||||
array<int> a; | array<int> a; | ||||
a << 0 << 1 << 2 << 3; | a << 0 << 1 << 2 << 3; | ||||
a.RemoveSwap(1); | |||||
a.remove_swap(1); | |||||
lolunit_assert_equal(a.Count(), 3); | |||||
lolunit_assert_equal(a.count(), 3); | |||||
lolunit_assert_equal(a[0], 0); | lolunit_assert_equal(a[0], 0); | ||||
lolunit_assert_equal(a[1], 3); | lolunit_assert_equal(a[1], 3); | ||||
lolunit_assert_equal(a[2], 2); | lolunit_assert_equal(a[2], 2); | ||||
array<int> b; | array<int> b; | ||||
b << 0 << 1 << 2 << 3; | b << 0 << 1 << 2 << 3; | ||||
b.Remove(1, 2); | |||||
b.remove(1, 2); | |||||
lolunit_assert_equal(b.Count(), 2); | |||||
lolunit_assert_equal(b.count(), 2); | |||||
lolunit_assert_equal(b[0], 0); | lolunit_assert_equal(b[0], 0); | ||||
lolunit_assert_equal(b[1], 3); | lolunit_assert_equal(b[1], 3); | ||||
} | } | ||||
@@ -141,7 +141,7 @@ lolunit_declare_fixture(ArrayTest) | |||||
lolunit_declare_test(EightElements) | lolunit_declare_test(EightElements) | ||||
{ | { | ||||
array<int, long, float, double, unsigned, char, bool, void *> a; | array<int, long, float, double, unsigned, char, bool, void *> a; | ||||
a.Push(1, 2, 3.f, 4.0, 5, 'a', true, 0); | |||||
a.push(1, 2, 3.f, 4.0, 5, 'a', true, 0); | |||||
lolunit_assert_equal(a[0].m1, 1); | lolunit_assert_equal(a[0].m1, 1); | ||||
lolunit_assert_equal(a[0].m2, 2); | lolunit_assert_equal(a[0].m2, 2); | ||||
@@ -156,9 +156,10 @@ lolunit_declare_fixture(ArrayTest) | |||||
lolunit_declare_test(ArraySwap) | lolunit_declare_test(ArraySwap) | ||||
{ | { | ||||
array<int, int> a; | array<int, int> a; | ||||
a.Push(10, 20); | |||||
a.Push(30, 40); | |||||
a.Swap(0, 1); | |||||
a.push(10, 20); | |||||
a.push(30, 40); | |||||
std::swap(a[0], a[1]); | |||||
lolunit_assert_equal(30, a[0].m1); | lolunit_assert_equal(30, a[0].m1); | ||||
lolunit_assert_equal(40, a[0].m2); | lolunit_assert_equal(40, a[0].m2); | ||||
@@ -171,18 +172,18 @@ lolunit_declare_fixture(ArrayTest) | |||||
array<int> a; | array<int> a; | ||||
a << 1 << 2; | a << 1 << 2; | ||||
a.Insert(5, 0); | |||||
a.insert(5, 0); | |||||
lolunit_assert_equal(5, a[0]); | lolunit_assert_equal(5, a[0]); | ||||
lolunit_assert_equal(1, a[1]); | lolunit_assert_equal(1, a[1]); | ||||
lolunit_assert_equal(2, a[2]); | lolunit_assert_equal(2, a[2]); | ||||
a.Insert(6, 3); | |||||
a.insert(6, 3); | |||||
lolunit_assert_equal(5, a[0]); | lolunit_assert_equal(5, a[0]); | ||||
lolunit_assert_equal(1, a[1]); | lolunit_assert_equal(1, a[1]); | ||||
lolunit_assert_equal(2, a[2]); | lolunit_assert_equal(2, a[2]); | ||||
lolunit_assert_equal(6, a[3]); | lolunit_assert_equal(6, a[3]); | ||||
a.Insert(7, 2); | |||||
a.insert(7, 2); | |||||
lolunit_assert_equal(5, a[0]); | lolunit_assert_equal(5, a[0]); | ||||
lolunit_assert_equal(1, a[1]); | lolunit_assert_equal(1, a[1]); | ||||
lolunit_assert_equal(7, a[2]); | lolunit_assert_equal(7, a[2]); | ||||
@@ -193,17 +194,17 @@ lolunit_declare_fixture(ArrayTest) | |||||
lolunit_declare_test(ArrayInsertTuple) | lolunit_declare_test(ArrayInsertTuple) | ||||
{ | { | ||||
array<int, float, String> b; | array<int, float, String> b; | ||||
b.Insert(0, 5, 6.f, "lol"); | |||||
b.insert(0, 5, 6.f, "lol"); | |||||
lolunit_assert_equal(5, b[0].m1); | lolunit_assert_equal(5, b[0].m1); | ||||
lolunit_assert_equal(6.f, b[0].m2); | lolunit_assert_equal(6.f, b[0].m2); | ||||
b.Insert(1, 8, 9.f, "hi there"); | |||||
b.insert(1, 8, 9.f, "hi there"); | |||||
lolunit_assert_equal(5, b[0].m1); | lolunit_assert_equal(5, b[0].m1); | ||||
lolunit_assert_equal(6.f, b[0].m2); | lolunit_assert_equal(6.f, b[0].m2); | ||||
lolunit_assert_equal(8, b[1].m1); | lolunit_assert_equal(8, b[1].m1); | ||||
lolunit_assert_equal(9.f, b[1].m2); | lolunit_assert_equal(9.f, b[1].m2); | ||||
b.Insert(1, 4, 5.f, "anyone home?"); | |||||
b.insert(1, 4, 5.f, "anyone home?"); | |||||
lolunit_assert_equal(5, b[0].m1); | lolunit_assert_equal(5, b[0].m1); | ||||
lolunit_assert_equal(6.f, b[0].m2); | lolunit_assert_equal(6.f, b[0].m2); | ||||
lolunit_assert_equal(4, b[1].m1); | lolunit_assert_equal(4, b[1].m1); | ||||
@@ -253,7 +254,7 @@ lolunit_declare_fixture(ArrayTest) | |||||
{ | { | ||||
array<TrackedObj> a; | array<TrackedObj> a; | ||||
a.Push(TrackedObj()); | |||||
a.push(TrackedObj()); | |||||
} | } | ||||
lolunit_assert_equal(TrackedObj::m_ctor, TrackedObj::m_dtor); | lolunit_assert_equal(TrackedObj::m_ctor, TrackedObj::m_dtor); | ||||
@@ -262,9 +263,9 @@ lolunit_declare_fixture(ArrayTest) | |||||
{ | { | ||||
array<TrackedObj> a; | array<TrackedObj> a; | ||||
a.Resize(2); | |||||
a.Resize(4); | |||||
a.Resize(1); | |||||
a.resize(2); | |||||
a.resize(4); | |||||
a.resize(1); | |||||
} | } | ||||
lolunit_assert_equal(TrackedObj::m_ctor, TrackedObj::m_dtor); | lolunit_assert_equal(TrackedObj::m_ctor, TrackedObj::m_dtor); | ||||
} | } | ||||
@@ -67,10 +67,10 @@ lolunit_declare_fixture(MapTest) | |||||
a << i; | a << i; | ||||
m[i] = -1; | m[i] = -1; | ||||
} | } | ||||
for (int i = 0; i < a.Count(); i++) | |||||
for (int i = 0; i < a.count(); i++) | |||||
m[i] = i; | m[i] = i; | ||||
a.Shuffle(); | a.Shuffle(); | ||||
for (int i = 0; i < a.Count(); i++) | |||||
for (int i = 0; i < a.count(); i++) | |||||
m.remove(a[i]); | m.remove(a[i]); | ||||
} | } | ||||
@@ -81,13 +81,13 @@ lolunit_declare_fixture(MapTest) | |||||
for (int i = 0; i < 20; i++) | for (int i = 0; i < 20; i++) | ||||
{ | { | ||||
a << String::Printf("test_str_%i", i); | |||||
m[a.Last()] = -1; | |||||
a << String::format("test_str_%i", i); | |||||
m[a.last()] = -1; | |||||
} | } | ||||
for (int i = 0; i < a.Count(); i++) | |||||
for (int i = 0; i < a.count(); i++) | |||||
m[a[i]] = i; | m[a[i]] = i; | ||||
a.Shuffle(); | a.Shuffle(); | ||||
for (int i = 0; i < a.Count(); i++) | |||||
for (int i = 0; i < a.count(); i++) | |||||
m.remove(a[i]); | m.remove(a[i]); | ||||
} | } | ||||
@@ -284,10 +284,10 @@ lolunit_declare_fixture(MapTest) | |||||
"Cyberano_Ns:Feather17" }; | "Cyberano_Ns:Feather17" }; | ||||
map<String, int> bones_map; | map<String, int> bones_map; | ||||
for (int i = 0; i < bones.Count(); ++i) | |||||
for (int i = 0; i < bones.count(); ++i) | |||||
bones_map[bones[i]] = i; | bones_map[bones[i]] = i; | ||||
for (int i = 0; i < bones.Count(); ++i) | |||||
for (int i = 0; i < bones.count(); ++i) | |||||
lolunit_assert_equal(bones_map[bones[i]], i); | lolunit_assert_equal(bones_map[bones[i]], i); | ||||
} | } | ||||
}; | }; | ||||
@@ -151,12 +151,12 @@ lolunit_declare_fixture(string_test) | |||||
lolunit_declare_test(string_printf) | lolunit_declare_test(string_printf) | ||||
{ | { | ||||
String s1 = "3a"; | String s1 = "3a"; | ||||
String s2 = String::Printf("%d%x", 3, 10); | |||||
String s2 = String::format("%d%x", 3, 10); | |||||
lolunit_assert(s1 == s2); | lolunit_assert(s1 == s2); | ||||
String s3 = "abc 3"; | String s3 = "abc 3"; | ||||
String s4 = String::Printf("abc %d", 3); | |||||
String s4 = String::format("abc %d", 3); | |||||
lolunit_assert(s3 == s4); | lolunit_assert(s3 == s4); | ||||
} | } | ||||
@@ -177,14 +177,14 @@ lolunit_declare_fixture(string_test) | |||||
lolunit_declare_test(index_of) | lolunit_declare_test(index_of) | ||||
{ | { | ||||
String s1 = "Hello World"; | String s1 = "Hello World"; | ||||
ptrdiff_t i1 = s1.index_of('H'); | |||||
ptrdiff_t i2 = s1.index_of('W'); | |||||
ptrdiff_t i3 = s1.index_of('d'); | |||||
ptrdiff_t i4 = s1.index_of("Hello"); | |||||
ptrdiff_t i5 = s1.index_of("World"); | |||||
ptrdiff_t i6 = s1.index_of("lo"); | |||||
ptrdiff_t i7 = s1.index_of("Hello World"); | |||||
ptrdiff_t i8 = s1.index_of("Sup' dude"); | |||||
int i1 = s1.index_of('H'); | |||||
int i2 = s1.index_of('W'); | |||||
int i3 = s1.index_of('d'); | |||||
int i4 = s1.index_of("Hello"); | |||||
int i5 = s1.index_of("World"); | |||||
int i6 = s1.index_of("lo"); | |||||
int i7 = s1.index_of("Hello World"); | |||||
int i8 = s1.index_of("Sup' dude"); | |||||
lolunit_assert(i1 == 0); | lolunit_assert(i1 == 0); | ||||
lolunit_assert(i2 == 6); | lolunit_assert(i2 == 6); | ||||
@@ -199,15 +199,15 @@ lolunit_declare_fixture(string_test) | |||||
lolunit_declare_test(last_index_of) | lolunit_declare_test(last_index_of) | ||||
{ | { | ||||
String s1 = "Hello World"; | String s1 = "Hello World"; | ||||
ptrdiff_t i1 = s1.last_index_of('H'); | |||||
ptrdiff_t i2 = s1.last_index_of('W'); | |||||
ptrdiff_t i3 = s1.last_index_of('d'); | |||||
ptrdiff_t i4 = s1.last_index_of("Hello"); | |||||
ptrdiff_t i5 = s1.last_index_of("World"); | |||||
ptrdiff_t i6 = s1.last_index_of("lo"); | |||||
ptrdiff_t i7 = s1.last_index_of("Hello World"); | |||||
ptrdiff_t i8 = s1.last_index_of("Sup' dude"); | |||||
ptrdiff_t i9 = s1.last_index_of('l'); | |||||
int i1 = s1.last_index_of('H'); | |||||
int i2 = s1.last_index_of('W'); | |||||
int i3 = s1.last_index_of('d'); | |||||
int i4 = s1.last_index_of("Hello"); | |||||
int i5 = s1.last_index_of("World"); | |||||
int i6 = s1.last_index_of("lo"); | |||||
int i7 = s1.last_index_of("Hello World"); | |||||
int i8 = s1.last_index_of("Sup' dude"); | |||||
int i9 = s1.last_index_of('l'); | |||||
lolunit_assert(i1 == 0); | lolunit_assert(i1 == 0); | ||||
lolunit_assert(i2 == 6); | lolunit_assert(i2 == 6); | ||||
@@ -95,7 +95,7 @@ lolunit_declare_fixture(ColorTest) | |||||
vec3 v2 = Color::RGBToHSV(v1); | vec3 v2 = Color::RGBToHSV(v1); | ||||
vec3 v3 = Color::HSVToRGB(v2); | vec3 v3 = Color::HSVToRGB(v2); | ||||
String rgb = String::Printf("[%f %f %f]", v1.r, v1.g, v1.b); | |||||
String rgb = String::format("[%f %f %f]", v1.r, v1.g, v1.b); | |||||
lolunit_set_context(&rgb[0]); | lolunit_set_context(&rgb[0]); | ||||
if (r != g || g != b) | if (r != g || g != b) | ||||
@@ -117,7 +117,7 @@ lolunit_declare_fixture(ColorTest) | |||||
vec3 v2 = Color::RGBToHSL(v1); | vec3 v2 = Color::RGBToHSL(v1); | ||||
vec3 v3 = Color::HSVToHSL(Color::RGBToHSV(v1)); | vec3 v3 = Color::HSVToHSL(Color::RGBToHSV(v1)); | ||||
String rgb = String::Printf("[%f %f %f]", v1.r, v1.g, v1.b); | |||||
String rgb = String::format("[%f %f %f]", v1.r, v1.g, v1.b); | |||||
lolunit_set_context(&rgb[0]); | lolunit_set_context(&rgb[0]); | ||||
/* Don’t check hue if saturation is zero. */ | /* Don’t check hue if saturation is zero. */ | ||||
@@ -49,8 +49,8 @@ lolunit_declare_fixture(Array2DTest) | |||||
{ 5, 6, 7, 8 }, | { 5, 6, 7, 8 }, | ||||
{ 9, 8, 7, 6 } }; | { 9, 8, 7, 6 } }; | ||||
lolunit_assert_equal(a.GetSize().x, 4); | |||||
lolunit_assert_equal(a.GetSize().y, 3); | |||||
lolunit_assert_equal(a.size().x, 4); | |||||
lolunit_assert_equal(a.size().y, 3); | |||||
lolunit_assert_equal(a[0][0], 1); | lolunit_assert_equal(a[0][0], 1); | ||||
lolunit_assert_equal(a[1][0], 2); | lolunit_assert_equal(a[1][0], 2); | ||||
@@ -52,9 +52,9 @@ lolunit_declare_fixture(Array3DTest) | |||||
{ -5, -6, -7, -8 }, | { -5, -6, -7, -8 }, | ||||
{ -9, -8, -7, -6 } } }; | { -9, -8, -7, -6 } } }; | ||||
lolunit_assert_equal(a.GetSize().x, 4); | |||||
lolunit_assert_equal(a.GetSize().y, 3); | |||||
lolunit_assert_equal(a.GetSize().z, 2); | |||||
lolunit_assert_equal(a.size().x, 4); | |||||
lolunit_assert_equal(a.size().y, 3); | |||||
lolunit_assert_equal(a.size().z, 2); | |||||
lolunit_assert_equal(a[0][0][0], 1); | lolunit_assert_equal(a[0][0][0], 1); | ||||
lolunit_assert_equal(a[1][0][0], 2); | lolunit_assert_equal(a[1][0][0], 2); | ||||
@@ -24,7 +24,7 @@ lolunit_declare_fixture(ArrayNDTest) | |||||
lolunit_declare_test(Array2D) | lolunit_declare_test(Array2D) | ||||
{ | { | ||||
arraynd<2, int> a; | arraynd<2, int> a; | ||||
a.SetSize(vec_t<int, 2>(2, 2)); | |||||
a.resize(vec_t<int, 2>(2, 2)); | |||||
/* Non-const accessors */ | /* Non-const accessors */ | ||||
a[0][0] = 1; | a[0][0] = 1; | ||||
@@ -53,9 +53,9 @@ lolunit_declare_fixture(ArrayNDTest) | |||||
arraynd<3, int> e = { { {1, 2}, {3, 4} }, { {5, 6}, {7, 8} } }; | arraynd<3, int> e = { { {1, 2}, {3, 4} }, { {5, 6}, {7, 8} } }; | ||||
lolunit_assert_equal(e.GetSize()[0], 2); | |||||
lolunit_assert_equal(e.GetSize()[1], 2); | |||||
lolunit_assert_equal(e.GetSize()[2], 2); | |||||
lolunit_assert_equal(e.size()[0], 2); | |||||
lolunit_assert_equal(e.size()[1], 2); | |||||
lolunit_assert_equal(e.size()[2], 2); | |||||
lolunit_assert_equal(e[0][0][0], 1); | lolunit_assert_equal(e[0][0][0], 1); | ||||
lolunit_assert_equal(e[1][0][0], 2); | lolunit_assert_equal(e[1][0][0], 2); | ||||
@@ -68,9 +68,9 @@ lolunit_declare_fixture(ArrayNDTest) | |||||
arraynd<3, int> f = { { {1, 2, 3, 4}, {5, 6, 7} }, { {8, 9}, {10} } }; | arraynd<3, int> f = { { {1, 2, 3, 4}, {5, 6, 7} }, { {8, 9}, {10} } }; | ||||
lolunit_assert_equal(f.GetSize()[0], 4); | |||||
lolunit_assert_equal(f.GetSize()[1], 2); | |||||
lolunit_assert_equal(f.GetSize()[2], 2); | |||||
lolunit_assert_equal(f.size()[0], 4); | |||||
lolunit_assert_equal(f.size()[1], 2); | |||||
lolunit_assert_equal(f.size()[2], 2); | |||||
lolunit_assert_equal(f[0][0][0], 1); | lolunit_assert_equal(f[0][0][0], 1); | ||||
lolunit_assert_equal(f[1][0][0], 2); | lolunit_assert_equal(f[1][0][0], 2); | ||||
@@ -341,6 +341,7 @@ lolunit_declare_fixture(MatrixTest) | |||||
vec4(0, 0, 1, 0), | vec4(0, 0, 1, 0), | ||||
vec4(0, -1, 0, 0), | vec4(0, -1, 0, 0), | ||||
vec4(0, 0, -1, 1)); | vec4(0, 0, -1, 1)); | ||||
/* Invert matrix and check that the results are finite */ | /* Invert matrix and check that the results are finite */ | ||||
mat4 m1 = inverse(m); | mat4 m1 = inverse(m); | ||||
for (int j = 0; j < 4; ++j) | for (int j = 0; j < 4; ++j) | ||||
@@ -239,7 +239,7 @@ lolunit_declare_fixture(PolynomialTest) | |||||
polynomial<float> p { 42.f }; | polynomial<float> p { 42.f }; | ||||
auto roots = p.roots(); | auto roots = p.roots(); | ||||
lolunit_assert_equal(roots.Count(), 0); | |||||
lolunit_assert_equal(roots.count(), 0); | |||||
} | } | ||||
lolunit_declare_test(RootsDegree1) | lolunit_declare_test(RootsDegree1) | ||||
@@ -248,7 +248,7 @@ lolunit_declare_fixture(PolynomialTest) | |||||
polynomial<float> p { -6.f, 2.f }; | polynomial<float> p { -6.f, 2.f }; | ||||
auto roots = p.roots(); | auto roots = p.roots(); | ||||
lolunit_assert_equal(roots.Count(), 1); | |||||
lolunit_assert_equal(roots.count(), 1); | |||||
lolunit_assert_equal(roots[0], 3.f); | lolunit_assert_equal(roots[0], 3.f); | ||||
} | } | ||||
@@ -258,14 +258,14 @@ lolunit_declare_fixture(PolynomialTest) | |||||
polynomial<float> p { 81.f, -18.f, 1.f }; | polynomial<float> p { 81.f, -18.f, 1.f }; | ||||
auto roots1 = p.roots(); | auto roots1 = p.roots(); | ||||
lolunit_assert_equal(roots1.Count(), 1); | |||||
lolunit_assert_equal(roots1.count(), 1); | |||||
lolunit_assert_equal(roots1[0], 9.f); | lolunit_assert_equal(roots1[0], 9.f); | ||||
/* p(x) = 42 - 20x + 2x² */ | /* p(x) = 42 - 20x + 2x² */ | ||||
polynomial<float> q { 42.f, -20.f, 2.f }; | polynomial<float> q { 42.f, -20.f, 2.f }; | ||||
auto roots2 = q.roots(); | auto roots2 = q.roots(); | ||||
lolunit_assert_equal(roots2.Count(), 2); | |||||
lolunit_assert_equal(roots2.count(), 2); | |||||
lolunit_assert_equal(roots2[0], 3.f); | lolunit_assert_equal(roots2[0], 3.f); | ||||
lolunit_assert_equal(roots2[1], 7.f); | lolunit_assert_equal(roots2[1], 7.f); | ||||
} | } | ||||
@@ -20,16 +20,16 @@ lolunit_declare_fixture(QuaternionTest) | |||||
void SetUp() | void SetUp() | ||||
{ | { | ||||
/* Generate identity quaternions */ | /* Generate identity quaternions */ | ||||
m_vectorpairs.Push(vec3::axis_x, vec3::axis_x); | |||||
m_vectorpairs.Push(2.f * vec3::axis_x, 3.f * vec3::axis_x); | |||||
m_vectorpairs.push(vec3::axis_x, vec3::axis_x); | |||||
m_vectorpairs.push(2.f * vec3::axis_x, 3.f * vec3::axis_x); | |||||
/* Generate 90-degree rotations */ | /* Generate 90-degree rotations */ | ||||
m_vectorpairs.Push(vec3::axis_x, vec3::axis_y); | |||||
m_vectorpairs.Push(2.f * vec3::axis_x, 3.f * vec3::axis_y); | |||||
m_vectorpairs.push(vec3::axis_x, vec3::axis_y); | |||||
m_vectorpairs.push(2.f * vec3::axis_x, 3.f * vec3::axis_y); | |||||
/* Generate 180-degree rotations */ | /* Generate 180-degree rotations */ | ||||
m_vectorpairs.Push(vec3::axis_x, -vec3::axis_x); | |||||
m_vectorpairs.Push(2.f * vec3::axis_x, -3.f * vec3::axis_x); | |||||
m_vectorpairs.push(vec3::axis_x, -vec3::axis_x); | |||||
m_vectorpairs.push(2.f * vec3::axis_x, -3.f * vec3::axis_x); | |||||
/* Fill array with random test values */ | /* Fill array with random test values */ | ||||
for (int i = 0; i < 10000; ++i) | for (int i = 0; i < 10000; ++i) | ||||
@@ -38,7 +38,7 @@ lolunit_declare_fixture(QuaternionTest) | |||||
* vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)); | * vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)); | ||||
vec3 v2 = lol::pow(10.f, rand(-5.f, 5.f)) | vec3 v2 = lol::pow(10.f, rand(-5.f, 5.f)) | ||||
* vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)); | * vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)); | ||||
m_vectorpairs.Push(v1, v2); | |||||
m_vectorpairs.push(v1, v2); | |||||
} | } | ||||
} | } | ||||
@@ -38,9 +38,9 @@ lolunit_declare_fixture(thread_test) | |||||
{ | { | ||||
Timer timer; | Timer timer; | ||||
m_done = false; | m_done = false; | ||||
Log::Info(Line("%s: STARTED WORK"), GetName()); | |||||
Log::Info("%s: STARTED WORK\n", GetName()); | |||||
timer.Wait(2.f); | timer.Wait(2.f); | ||||
Log::Info(Line("%s: ENDED WORK"), GetName()); | |||||
Log::Info("%s: ENDED WORK\n", GetName()); | |||||
m_done = true; | m_done = true; | ||||
return true; | return true; | ||||
} | } | ||||
@@ -81,15 +81,15 @@ lolunit_declare_fixture(thread_test) | |||||
void AddJob(ThreadJob* job) | void AddJob(ThreadJob* job) | ||||
{ | { | ||||
Log::Info(Line("%s DISPATCHING JOB %s"), GetName(), job->GetName()); | |||||
Log::Info("%s DISPATCHING JOB %s\n", GetName(), job->GetName()); | |||||
DispatchJob(job); | DispatchJob(job); | ||||
} | } | ||||
bool GetWorkResult(array<ThreadJob*>& results) | bool GetWorkResult(array<ThreadJob*>& results) | ||||
{ | { | ||||
results += m_job_result; | results += m_job_result; | ||||
m_job_result.Empty(); | |||||
Log::Info(Line("%s GETWORKRESULT (%i)"), GetName(), results.count()); | |||||
return results.Count() > 0; | |||||
m_job_result.empty(); | |||||
Log::Info("%s GETWORKRESULT (%i)\n", GetName(), results.count()); | |||||
return results.count() > 0; | |||||
} | } | ||||
virtual void TickGame(float seconds) | virtual void TickGame(float seconds) | ||||
@@ -99,7 +99,7 @@ lolunit_declare_fixture(thread_test) | |||||
case UnitTestStatus::NOT_QUEUED: | case UnitTestStatus::NOT_QUEUED: | ||||
if (!!GetDispatchCount()) | if (!!GetDispatchCount()) | ||||
{ | { | ||||
Log::Info(Line("%s TICKGAME %s"), GetName(), m_status.ToString().C()); | |||||
Log::Info("%s TICKGAME %s\n", GetName(), m_status.ToString().C()); | |||||
m_status = UnitTestStatus::QUEUED; | m_status = UnitTestStatus::QUEUED; | ||||
} | } | ||||
break; | break; | ||||
@@ -110,14 +110,14 @@ lolunit_declare_fixture(thread_test) | |||||
if (GetDispatchedCount()) | if (GetDispatchedCount()) | ||||
#endif | #endif | ||||
{ | { | ||||
Log::Info(Line("%s TICKGAME %s"), GetName(), m_status.ToString().C()); | |||||
Log::Info("%s TICKGAME %s\n", GetName(), m_status.ToString().C()); | |||||
m_status = UnitTestStatus::RETRIEVED; | m_status = UnitTestStatus::RETRIEVED; | ||||
} | } | ||||
break; | break; | ||||
case UnitTestStatus::RETRIEVED: | case UnitTestStatus::RETRIEVED: | ||||
if (m_job_result.count() == 4) | if (m_job_result.count() == 4) | ||||
{ | { | ||||
Log::Info(Line("%s TICKGAME %s"), GetName(), m_status.ToString().C()); | |||||
Log::Info("%s TICKGAME %s\n", GetName(), m_status.ToString().C()); | |||||
m_status = UnitTestStatus::DONE; | m_status = UnitTestStatus::DONE; | ||||
} | } | ||||
break; | break; | ||||
@@ -151,10 +151,10 @@ lolunit_declare_fixture(thread_test) | |||||
lolunit_declare_test(threads) | lolunit_declare_test(threads) | ||||
{ | { | ||||
Log::Info(Line("%s START"), m_manager.GetName()); | |||||
Log::Info("%s START\n", m_manager.GetName()); | |||||
//Start threads manager | //Start threads manager | ||||
m_manager.Start(); | m_manager.Start(); | ||||
Log::Info(Line("%s STARTED"), m_manager.GetName()); | |||||
Log::Info("%s STARTED\n", m_manager.GetName()); | |||||
UnitTestJob job[4]; | UnitTestJob job[4]; | ||||
lolunit_assert_equal(0, m_manager.Test_GetDispatchCount()); | lolunit_assert_equal(0, m_manager.Test_GetDispatchCount()); | ||||
@@ -187,10 +187,10 @@ lolunit_declare_fixture(thread_test) | |||||
m_manager.GetWorkResult(results); | m_manager.GetWorkResult(results); | ||||
lolunit_assert_equal(4, results.count()); | lolunit_assert_equal(4, results.count()); | ||||
Log::Info(Line("%s STOP"), m_manager.GetName()); | |||||
Log::Info("%s STOP\n", m_manager.GetName()); | |||||
//Stop manager | //Stop manager | ||||
m_manager.Stop(); | m_manager.Stop(); | ||||
Log::Info(Line("%s STOPPED"), m_manager.GetName()); | |||||
Log::Info("%s STOPPED\n", m_manager.GetName()); | |||||
} | } | ||||
lolunit_declare_test(queue_try_push) | lolunit_declare_test(queue_try_push) | ||||
@@ -60,7 +60,7 @@ void Text::SetText(String const &text) | |||||
void Text::SetInt(int val) | void Text::SetInt(int val) | ||||
{ | { | ||||
data->m_text = String::Printf("%i", val); | |||||
data->m_text = String::format("%i", val); | |||||
} | } | ||||
void Text::SetPos(vec3 pos) | void Text::SetPos(vec3 pos) | ||||
@@ -41,9 +41,9 @@ public: | |||||
~TickerData() | ~TickerData() | ||||
{ | { | ||||
ASSERT(nentities == 0, | ASSERT(nentities == 0, | ||||
"still %td entities in ticker\n", nentities); | |||||
ASSERT(m_autolist.Count() == 0, | |||||
"still %ti autoreleased entities\n", m_autolist.Count()); | |||||
"still %d entities in ticker\n", nentities); | |||||
ASSERT(m_autolist.count() == 0, | |||||
"still %d autoreleased entities\n", m_autolist.count()); | |||||
Log::Debug("%d frames required to quit\n", frame - quitframe); | Log::Debug("%d frames required to quit\n", frame - quitframe); | ||||
#if LOL_FEATURE_THREADS | #if LOL_FEATURE_THREADS | ||||
@@ -58,8 +58,8 @@ private: | |||||
/* Entity management */ | /* Entity management */ | ||||
array<Entity *> m_todolist, m_autolist; | array<Entity *> m_todolist, m_autolist; | ||||
array<Entity *> m_list[Entity::ALLGROUP_END]; | array<Entity *> m_list[Entity::ALLGROUP_END]; | ||||
array<ptrdiff_t> m_scenes[Entity::ALLGROUP_END]; | |||||
ptrdiff_t nentities; | |||||
array<int> m_scenes[Entity::ALLGROUP_END]; | |||||
int nentities; | |||||
/* Fixed framerate management */ | /* Fixed framerate management */ | ||||
int frame, recording; | int frame, recording; | ||||
@@ -121,11 +121,11 @@ void Ticker::Ref(Entity *entity) | |||||
/* Get the entity out of the m_autorelease list. This is usually | /* Get the entity out of the m_autorelease list. This is usually | ||||
* very fast since the last entry in autolist is the last | * very fast since the last entry in autolist is the last | ||||
* registered entity. */ | * registered entity. */ | ||||
for (ptrdiff_t i = data->m_autolist.Count(); i--; ) | |||||
for (int i = data->m_autolist.count(); i--; ) | |||||
{ | { | ||||
if (data->m_autolist[i] == entity) | if (data->m_autolist[i] == entity) | ||||
{ | { | ||||
data->m_autolist.RemoveSwap(i); | |||||
data->m_autolist.remove_swap(i); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -219,7 +219,7 @@ void TickerData::GameThreadTick() | |||||
Log::Debug("%s Group %d\n", | Log::Debug("%s Group %d\n", | ||||
(g < Entity::GAMEGROUP_END) ? "Game" : "Draw", g); | (g < Entity::GAMEGROUP_END) ? "Game" : "Draw", g); | ||||
for (int i = 0; i < data->m_list[g].Count(); ++i) | |||||
for (int i = 0; i < data->m_list[g].count(); ++i) | |||||
{ | { | ||||
Entity *e = data->m_list[g][i]; | Entity *e = data->m_list[g][i]; | ||||
Log::Debug(" \\-- [%p] %s (m_ref %d, destroy %d)\n", | Log::Debug(" \\-- [%p] %s (m_ref %d, destroy %d)\n", | ||||
@@ -270,7 +270,7 @@ void TickerData::GameThreadTick() | |||||
data->panic = 2 * (data->panic + 1); | data->panic = 2 * (data->panic + 1); | ||||
for (int g = 0; g < Entity::ALLGROUP_END && n < data->panic; ++g) | for (int g = 0; g < Entity::ALLGROUP_END && n < data->panic; ++g) | ||||
for (int i = 0; i < data->m_list[g].Count() && n < data->panic; ++i) | |||||
for (int i = 0; i < data->m_list[g].count() && n < data->panic; ++i) | |||||
{ | { | ||||
Entity * e = data->m_list[g][i]; | Entity * e = data->m_list[g][i]; | ||||
if (e->m_ref) | if (e->m_ref) | ||||
@@ -285,7 +285,7 @@ void TickerData::GameThreadTick() | |||||
#if !LOL_BUILD_RELEASE | #if !LOL_BUILD_RELEASE | ||||
if (n) | if (n) | ||||
Log::Error("%td entities stuck after %d frames, poked %d\n", | |||||
Log::Error("%d entities stuck after %d frames, poked %d\n", | |||||
data->nentities, data->quitdelay, n); | data->nentities, data->quitdelay, n); | ||||
#endif | #endif | ||||
@@ -299,7 +299,7 @@ void TickerData::GameThreadTick() | |||||
bool do_reserve = true; | bool do_reserve = true; | ||||
for (int g = 0; g < Entity::ALLGROUP_END; ++g) | for (int g = 0; g < Entity::ALLGROUP_END; ++g) | ||||
{ | { | ||||
for (ptrdiff_t i = data->m_list[g].Count(); i--;) | |||||
for (int i = data->m_list[g].count(); i--;) | |||||
{ | { | ||||
Entity *e = data->m_list[g][i]; | Entity *e = data->m_list[g][i]; | ||||
@@ -307,7 +307,7 @@ void TickerData::GameThreadTick() | |||||
{ | { | ||||
/* Game tick list: | /* Game tick list: | ||||
* If entity is to be destroyed, remove it */ | * If entity is to be destroyed, remove it */ | ||||
data->m_list[g].RemoveSwap(i); | |||||
data->m_list[g].remove_swap(i); | |||||
if (do_reserve) | if (do_reserve) | ||||
{ | { | ||||
do_reserve = false; | do_reserve = false; | ||||
@@ -320,15 +320,15 @@ void TickerData::GameThreadTick() | |||||
/* Draw tick list: | /* Draw tick list: | ||||
* If entity is to be destroyed, | * If entity is to be destroyed, | ||||
* remove it and store it. */ | * remove it and store it. */ | ||||
data->m_list[g].RemoveSwap(i); | |||||
ptrdiff_t removal_count = 0; | |||||
for (ptrdiff_t i = 0; i < Scene::GetCount(); i++) | |||||
data->m_list[g].remove_swap(i); | |||||
int removal_count = 0; | |||||
for (int j = 0; j < Scene::GetCount(); j++) | |||||
{ | { | ||||
//If entity is concerned by this scene, add it in the list | //If entity is concerned by this scene, add it in the list | ||||
if (Scene::GetScene(i).IsRelevant(e)) | |||||
if (Scene::GetScene(j).IsRelevant(e)) | |||||
removal_count++; | removal_count++; | ||||
//Update scene index | //Update scene index | ||||
data->m_scenes[e->m_drawgroup][i] -= removal_count; | |||||
data->m_scenes[e->m_drawgroup][j] -= removal_count; | |||||
} | } | ||||
if (do_reserve) | if (do_reserve) | ||||
{ | { | ||||
@@ -352,9 +352,9 @@ void TickerData::GameThreadTick() | |||||
} | } | ||||
/* Insert waiting objects into the appropriate lists */ | /* Insert waiting objects into the appropriate lists */ | ||||
while (data->m_todolist.Count()) | |||||
while (data->m_todolist.count()) | |||||
{ | { | ||||
Entity *e = data->m_todolist.Last(); | |||||
Entity *e = data->m_todolist.last(); | |||||
//If the entity has no mask, default it | //If the entity has no mask, default it | ||||
if (e->m_scene_mask == 0) | if (e->m_scene_mask == 0) | ||||
@@ -369,8 +369,8 @@ void TickerData::GameThreadTick() | |||||
if (data->m_scenes[e->m_drawgroup].count() < Scene::GetCount()) | if (data->m_scenes[e->m_drawgroup].count() < Scene::GetCount()) | ||||
data->m_scenes[e->m_drawgroup].resize(Scene::GetCount()); | data->m_scenes[e->m_drawgroup].resize(Scene::GetCount()); | ||||
ptrdiff_t added_count = 0; | |||||
for (ptrdiff_t i = 0; i < Scene::GetCount(); i++) | |||||
int added_count = 0; | |||||
for (int i = 0; i < Scene::GetCount(); i++) | |||||
{ | { | ||||
//If entity is concerned by this scene, add it in the list | //If entity is concerned by this scene, add it in the list | ||||
if (Scene::GetScene(i).IsRelevant(e)) | if (Scene::GetScene(i).IsRelevant(e)) | ||||
@@ -390,7 +390,7 @@ void TickerData::GameThreadTick() | |||||
/* Tick objects for the game loop */ | /* Tick objects for the game loop */ | ||||
for (int g = Entity::GAMEGROUP_BEGIN; g < Entity::GAMEGROUP_END && !data->quit /* Stop as soon as required */; ++g) | for (int g = Entity::GAMEGROUP_BEGIN; g < Entity::GAMEGROUP_END && !data->quit /* Stop as soon as required */; ++g) | ||||
{ | { | ||||
for (ptrdiff_t i = 0; i < data->m_list[g].Count() && !data->quit /* Stop as soon as required */; ++i) | |||||
for (int i = 0; i < data->m_list[g].count() && !data->quit /* Stop as soon as required */; ++i) | |||||
{ | { | ||||
Entity *e = data->m_list[g][i]; | Entity *e = data->m_list[g][i]; | ||||
if (!e->m_destroy) | if (!e->m_destroy) | ||||
@@ -426,15 +426,15 @@ void TickerData::DrawThreadTick() | |||||
switch (g) | switch (g) | ||||
{ | { | ||||
case Entity::DRAWGROUP_BEGIN: | case Entity::DRAWGROUP_BEGIN: | ||||
for (ptrdiff_t i = 0; i < Scene::GetCount(); i++) | |||||
for (int i = 0; i < Scene::GetCount(); i++) | |||||
Scene::GetScene(i).Reset(); | Scene::GetScene(i).Reset(); | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
ptrdiff_t scene_idx = 0; | |||||
for (int i = 0; i < data->m_list[g].Count() && !data->quit /* Stop as soon as required */; ++i) | |||||
int scene_idx = 0; | |||||
for (int i = 0; i < data->m_list[g].count() && !data->quit /* Stop as soon as required */; ++i) | |||||
{ | { | ||||
//We're outside of the range of the current scene, on to the next | //We're outside of the range of the current scene, on to the next | ||||
if (i >= data->m_scenes[g][scene_idx]) | if (i >= data->m_scenes[g][scene_idx]) | ||||
@@ -463,7 +463,7 @@ void TickerData::DrawThreadTick() | |||||
} | } | ||||
//Do the scene render loop | //Do the scene render loop | ||||
for (ptrdiff_t idx = 0; idx < Scene::GetCount() && !data->quit /* Stop as soon as required */; ++idx) | |||||
for (int idx = 0; idx < Scene::GetCount() && !data->quit /* Stop as soon as required */; ++idx) | |||||
{ | { | ||||
Scene& scene = Scene::GetScene(idx); | Scene& scene = Scene::GetScene(idx); | ||||
@@ -571,10 +571,10 @@ int Ticker::GetFrameNum() | |||||
void Ticker::Shutdown() | void Ticker::Shutdown() | ||||
{ | { | ||||
/* We're bailing out. Release all m_autorelease objects. */ | /* We're bailing out. Release all m_autorelease objects. */ | ||||
while (data->m_autolist.Count()) | |||||
while (data->m_autolist.count()) | |||||
{ | { | ||||
data->m_autolist.Last()->m_ref--; | |||||
data->m_autolist.Remove(-1); | |||||
data->m_autolist.last()->m_ref--; | |||||
data->m_autolist.remove(-1); | |||||
} | } | ||||
data->quit = 1; | data->quit = 1; | ||||