Skip to content

Commit

Permalink
Added some debug info, added whitespce to part of the cloud code for …
Browse files Browse the repository at this point in the history
…easier visibility, ive tried several things to fix this (, changng render que, base don cloud, etc,all of that, and it has had no effect, phosphate is still not showing up.

aded more debug info, uncovered pretty bad JSON bug i need to fix, where everything we grab from there is in alphabetical order, but other places we load them are not, which causes values to mismatch, this could be th cause of numerous bugs, eg biome background bug may end up having to do with it aswell as the phosphate not spawning bug also is confirmed to have to do with it (though with this change it spawns properly just with the wrong color)

removed redundant check, made the for loops use the value i defined earlier.

added more null compound checks taht were missing and got rid of a redundant check, im locking this code down heh :P

simplified compoundCount code, undid silly change i made earlier, added default color, made vector4's in color for clouds properly use floats, removed annoyting log when you hit iron.

added default color, made it bright white, mad eit not check if compounds wer enull before grabbing color , and now phosphate appears as the default color, so its color is not being assigned properly.

removed "fake" compounds

added back original code for pushing back teh clouds as hhenri ordered

Did alot of things i didnt commit (and didnt save) because they didnt work (including changing the way it loads compounds), got rid of old DEBUG info we no longer need added new debug info, got rid of unused variable, removed default colors, sorry about the deleted spaces i think tehy just got deleted because i put something new there then deleted that, will fix.
  • Loading branch information
Untrustedlife authored and hhyyrylainen committed Feb 15, 2019
1 parent 09113a8 commit b92db01
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 98 deletions.
3 changes: 1 addition & 2 deletions scripts/microbe_stage/biome.as
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ void setBiome(uint64 biomeId, CellStageWorld@ world){
LOG_INFO("Setting biome to: " + biomeId);
// Getting the base biome to change to.
currentBiome = biomeId;

auto biome = getCurrentBiome();

auto biomeCompounds = biome.getCompoundKeys();
LOG_INFO("biomeCompounds.length = " + biomeCompounds.length());
for(uint i = 0; i < biomeCompounds.length(); ++i){
auto compoundId = biomeCompounds[i];
auto compoundId = SimulationParameters::compoundRegistry().getTypeData(biomeCompounds[i]).id;

if(SimulationParameters::compoundRegistry().getTypeData(compoundId).isCloud){

Expand Down
8 changes: 1 addition & 7 deletions scripts/microbe_stage/setup.as
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void cellHitFloatingOrganelle(GameWorld@ world, ObjectID firstEntity, ObjectID s
world.QueueDestroyEntity(floatingEntity);
}

// TODO: also put these physics callback somewhere more sensible (maybe physics_callbacks.as?)

void cellHitIron(GameWorld@ world, ObjectID firstEntity, ObjectID secondEntity)
{
// Determine which is the iron
Expand All @@ -310,12 +310,6 @@ void cellHitIron(GameWorld@ world, ObjectID firstEntity, ObjectID secondEntity)
floatingEntity = secondEntity;
cellEntity = firstEntity;
}

// TODO: use this to detect stuff
LOG_INFO("Model: " + model.GraphicalObject.getMesh().getName());
LOG_INFO("TODO: organelle unlock progress if cell: " + cellEntity + " is the player");

//world.QueueDestroyEntity(floatingEntity);
}

// Cell Hit Oxytoxy
Expand Down
3 changes: 1 addition & 2 deletions src/ThriveGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,9 @@ void
// This is needed for the compound clouds to work in general
const auto compoundCount = SimulationParameters::compoundRegistry.getSize();


LEVIATHAN_ASSERT(SimulationParameters::compoundRegistry.getSize() > 0,
"compound registry is empty when creating cloud entities for them");
std::unordered_map<Leviathan::ObjectID, thrive::CompoundCloudComponent> u =
{};

std::vector<Compound> clouds;

Expand Down
174 changes: 87 additions & 87 deletions src/microbe_stage/compound_cloud_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,37 @@ CompoundCloudComponent::CompoundCloudComponent(CompoundCloudSystem& owner,
m_textureName("cloud_" + std::to_string(++CloudTextureNumber)),
m_owner(owner)
{
LOG_INFO("got here");
if(!first)
throw std::runtime_error(
"CompoundCloudComponent needs at least one Compound type");

// Read data
// Redundant check (see the throw above)
if(first) {

m_compoundId1 = first->id;
m_color1 =
Ogre::Vector4(first->colour.r, first->colour.g, first->colour.b, 1);
}
m_color1 =
Ogre::Vector4(first->colour.r, first->colour.g, first->colour.b, 1.0f);
m_compoundId1 = first->id;
LOG_INFO("cloud colors are " + std::to_string(first->colour.r));
LOG_INFO("cloud first compound ID is " + std::to_string(m_compoundId1));

if(second) {

m_compoundId2 = second->id;
m_color2 = Ogre::Vector4(
second->colour.r, second->colour.g, second->colour.b, 1);
second->colour.r, second->colour.g, second->colour.b, 1.0f);
}

if(third) {

m_compoundId3 = third->id;
m_color3 =
Ogre::Vector4(third->colour.r, third->colour.g, third->colour.b, 1);
m_color3 = Ogre::Vector4(
third->colour.r, third->colour.g, third->colour.b, 1.0f);
}

if(fourth) {

m_compoundId4 = fourth->id;
m_color4 = Ogre::Vector4(
fourth->colour.r, fourth->colour.g, fourth->colour.b, 1);
fourth->colour.r, fourth->colour.g, fourth->colour.b, 1.0f);
}
}

Expand Down Expand Up @@ -160,12 +159,13 @@ void
if(x >= m_density1.size() || y >= m_density1[0].size())
throw std::runtime_error(
"CompoundCloudComponent coordinates out of range");

switch(getSlotForCompound(compound)) {
case SLOT::FIRST: m_density1[x][y] += dens; break;
case SLOT::SECOND: m_density2[x][y] += dens; break;
case SLOT::THIRD: m_density3[x][y] += dens; break;
case SLOT::FOURTH: m_density4[x][y] += dens; break;
if(compound != NULL_COMPOUND) {
switch(getSlotForCompound(compound)) {
case SLOT::FIRST: m_density1[x][y] += dens; break;
case SLOT::SECOND: m_density2[x][y] += dens; break;
case SLOT::THIRD: m_density3[x][y] += dens; break;
case SLOT::FOURTH: m_density4[x][y] += dens; break;
}
}
}

Expand All @@ -175,39 +175,41 @@ int
size_t y,
float rate)
{
switch(getSlotForCompound(compound)) {
case SLOT::FIRST: {
int amountToGive = static_cast<int>(m_density1[x][y] * rate);
m_density1[x][y] -= amountToGive;
if(m_density1[x][y] < 1)
m_density1[x][y] = 0;

return amountToGive;
}
case SLOT::SECOND: {
int amountToGive = static_cast<int>(m_density2[x][y] * rate);
m_density2[x][y] -= amountToGive;
if(m_density2[x][y] < 1)
m_density2[x][y] = 0;
if(compound != NULL_COMPOUND) {
switch(getSlotForCompound(compound)) {
case SLOT::FIRST: {
int amountToGive = static_cast<int>(m_density1[x][y] * rate);
m_density1[x][y] -= amountToGive;
if(m_density1[x][y] < 1)
m_density1[x][y] = 0;

return amountToGive;
}
case SLOT::THIRD: {
int amountToGive = static_cast<int>(m_density3[x][y] * rate);
m_density3[x][y] -= amountToGive;
if(m_density3[x][y] < 1)
m_density3[x][y] = 0;
return amountToGive;
}
case SLOT::SECOND: {
int amountToGive = static_cast<int>(m_density2[x][y] * rate);
m_density2[x][y] -= amountToGive;
if(m_density2[x][y] < 1)
m_density2[x][y] = 0;

return amountToGive;
}
case SLOT::FOURTH: {
int amountToGive = static_cast<int>(m_density4[x][y] * rate);
m_density4[x][y] -= amountToGive;
if(m_density4[x][y] < 1)
m_density4[x][y] = 0;
return amountToGive;
}
case SLOT::THIRD: {
int amountToGive = static_cast<int>(m_density3[x][y] * rate);
m_density3[x][y] -= amountToGive;
if(m_density3[x][y] < 1)
m_density3[x][y] = 0;

return amountToGive;
}
return amountToGive;
}
case SLOT::FOURTH: {
int amountToGive = static_cast<int>(m_density4[x][y] * rate);
m_density4[x][y] -= amountToGive;
if(m_density4[x][y] < 1)
m_density4[x][y] = 0;

return amountToGive;
}
}
}

LEVIATHAN_ASSERT(false, "Shouldn't get here");
Expand All @@ -220,25 +222,26 @@ int
size_t y,
float rate)
{
switch(getSlotForCompound(compound)) {
case SLOT::FIRST: {
int amountToGive = static_cast<int>(m_density1[x][y] * rate);
return amountToGive;
}
case SLOT::SECOND: {
int amountToGive = static_cast<int>(m_density2[x][y] * rate);
return amountToGive;
}
case SLOT::THIRD: {
int amountToGive = static_cast<int>(m_density3[x][y] * rate);
return amountToGive;
}
case SLOT::FOURTH: {
int amountToGive = static_cast<int>(m_density4[x][y] * rate);
return amountToGive;
}
if(compound != NULL_COMPOUND) {
switch(getSlotForCompound(compound)) {
case SLOT::FIRST: {
int amountToGive = static_cast<int>(m_density1[x][y] * rate);
return amountToGive;
}
case SLOT::SECOND: {
int amountToGive = static_cast<int>(m_density2[x][y] * rate);
return amountToGive;
}
case SLOT::THIRD: {
int amountToGive = static_cast<int>(m_density3[x][y] * rate);
return amountToGive;
}
case SLOT::FOURTH: {
int amountToGive = static_cast<int>(m_density4[x][y] * rate);
return amountToGive;
}
}
}

LEVIATHAN_ASSERT(false, "Shouldn't get here");
return -1;
}
Expand Down Expand Up @@ -285,13 +288,13 @@ void

// Clear data. Maybe there is a faster way
if(m_compoundId1 != NULL_COMPOUND) {
for(size_t x = 0; x < m_density1.size(); ++x) {
for(size_t y = 0; y < m_density1[x].size(); ++y) {
for(size_t x = 0; x < m_density1.size(); ++x) {
for(size_t y = 0; y < m_density1[x].size(); ++y) {
m_density1[x][y] = 0;
m_oldDens1[x][y] = 0;
}
}
}
}
}

if(m_compoundId2 != NULL_COMPOUND) {
for(size_t x = 0; x < m_density2.size(); ++x) {
Expand Down Expand Up @@ -687,7 +690,7 @@ void
LOG_INFO("CompoundCloudSystem doing initial spawning");

m_cloudGridCenter = Float3(0, 0, 0);
for(size_t i = 0; i < m_cloudTypes.size(); i += CLOUDS_IN_ONE) {
for(size_t i = 0; i < cloudTypesNum; i += CLOUDS_IN_ONE) {

// Center
_spawnCloud(world, m_cloudGridCenter, i);
Expand Down Expand Up @@ -843,7 +846,7 @@ void
size_t farAwayRepositionedIndex = 0;

// Loop through the cloud groups
for(size_t c = 0; c < m_cloudTypes.size(); c += CLOUDS_IN_ONE) {
for(size_t c = 0; c < cloudTypesNum; c += CLOUDS_IN_ONE) {
// Loop for moving clouds
for(size_t i = 0; i < std::size(requiredCloudPositions); ++i) {
bool hasCloud = false;
Expand All @@ -856,7 +859,6 @@ void
if(((pos - requiredPos).HAddAbs() < Leviathan::EPSILON) &&
(m_cloudTypes[c].id ==
iter->second->getCompoundId1())) {
LOG_INFO("Clouds were at same position");
hasCloud = true;
break;
}
Expand Down Expand Up @@ -888,26 +890,26 @@ void
size_t startIndex)
{
auto entity = world.CreateEntity();

Compound* first =
startIndex < m_cloudTypes.size() ? &m_cloudTypes[startIndex] : nullptr;

Compound* second = startIndex + 1 < m_cloudTypes.size() ?
&m_cloudTypes[startIndex + 1] :
nullptr;

Compound* third = startIndex + 2 < m_cloudTypes.size() ?
&m_cloudTypes[startIndex + 2] :
nullptr;

Compound* fourth = startIndex + 3 < m_cloudTypes.size() ?
&m_cloudTypes[startIndex + 3] :
nullptr;

CompoundCloudComponent& cloud = world.Create_CompoundCloudComponent(
entity, *this, first, second, third, fourth);

// Set correct position
// TODO: this should probably be made a constructor parameter
cloud.m_position = pos;

initializeCloud(cloud, world.GetScene());
m_managedClouds[entity] = &cloud;
}
Expand All @@ -917,6 +919,8 @@ void
CompoundCloudSystem::initializeCloud(CompoundCloudComponent& cloud,
Ogre::SceneManager* scene)
{
LOG_INFO(
"cloud first compound ID is " + std::to_string(cloud.m_compoundId1));
LOG_INFO("Initializing a new compound cloud entity");

// All the densities
Expand Down Expand Up @@ -993,18 +997,14 @@ void
pass->setFragmentProgram("CompoundCloud_PS");

// Set colour parameter //
if(cloud.m_compoundId1 != NULL_COMPOUND)
pass->getFragmentProgramParameters()->setNamedConstant(
"cloudColour1", cloud.m_color1);
if(cloud.m_compoundId2 != NULL_COMPOUND)
pass->getFragmentProgramParameters()->setNamedConstant(
"cloudColour2", cloud.m_color2);
if(cloud.m_compoundId3 != NULL_COMPOUND)
pass->getFragmentProgramParameters()->setNamedConstant(
"cloudColour3", cloud.m_color3);
if(cloud.m_compoundId4 != NULL_COMPOUND)
pass->getFragmentProgramParameters()->setNamedConstant(
"cloudColour4", cloud.m_color4);
pass->getFragmentProgramParameters()->setNamedConstant(
"cloudColour1", cloud.m_color1);
pass->getFragmentProgramParameters()->setNamedConstant(
"cloudColour2", cloud.m_color2);
pass->getFragmentProgramParameters()->setNamedConstant(
"cloudColour3", cloud.m_color3);
pass->getFragmentProgramParameters()->setNamedConstant(
"cloudColour4", cloud.m_color4);

// The perlin noise texture needs to be tileable. We can't do tricks with
// the cloud's position
Expand Down

0 comments on commit b92db01

Please sign in to comment.