why does vsc do this sometimes?
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include "../util/output/aviwriter.hpp"
|
#include "../util/output/aviwriter.hpp"
|
||||||
#include "../util/output/bmpwriter.hpp"
|
#include "../util/output/bmpwriter.hpp"
|
||||||
#include "../util/timing_decorator.cpp"
|
#include "../util/timing_decorator.cpp"
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
struct AnimationConfig {
|
struct AnimationConfig {
|
||||||
int width = 1024;
|
int width = 1024;
|
||||||
@@ -173,7 +174,7 @@ bool exportavi(std::vector<frame> frames, AnimationConfig config) {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
void mainLogic(){
|
||||||
AnimationConfig config;
|
AnimationConfig config;
|
||||||
// std::cout << "g2c2175" << std::endl;
|
// std::cout << "g2c2175" << std::endl;
|
||||||
|
|
||||||
@@ -202,6 +203,38 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exportavi(frames,config);
|
exportavi(frames,config);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
static bool window = true;
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(1110,667));
|
||||||
|
|
||||||
|
if (ImGui::Begin("window_name", &window))
|
||||||
|
{
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(ImVec2(435.5,200));
|
||||||
|
ImGui::PushItemWidth(200);
|
||||||
|
static int i1 = 123;
|
||||||
|
ImGui::InputInt("Width", &i1);
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(ImVec2(432,166));
|
||||||
|
ImGui::PushItemWidth(200);
|
||||||
|
static int i2 = 123;
|
||||||
|
ImGui::InputInt("Height", &i2);
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(ImVec2(533.5,271));
|
||||||
|
ImGui::Button("Start", ImVec2(43,19)); //remove size argument (ImVec2) to auto-resize
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(ImVec2(400.5,366));
|
||||||
|
ImGui::PushItemWidth(200);
|
||||||
|
static int i6 = 123;
|
||||||
|
ImGui::InputInt("number of Seeds", &i6);
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
FunctionTimer::printStats(FunctionTimer::Mode::ENHANCED);
|
FunctionTimer::printStats(FunctionTimer::Mode::ENHANCED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Grid2 {
|
class Grid2 {
|
||||||
private:
|
protected:
|
||||||
//all positions
|
//all positions
|
||||||
reverselookupassistantclasscausecppisdumb Positions;
|
reverselookupassistantclasscausecppisdumb Positions;
|
||||||
//all colors
|
//all colors
|
||||||
|
|||||||
@@ -46,24 +46,27 @@ public:
|
|||||||
Orientations[id] = orientation;
|
Orientations[id] = orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getGridRegionAsBGR(const Vec2& minCorner, const Vec2& maxCorner, int& width, int& height, std::vector<uint8_t>& bgrData) const {
|
void getGridRegionAsBGR(const Vec2& minCorner, const Vec2& maxCorner, int& width, int& height, std::vector<uint8_t>& rgbData) const {
|
||||||
TIME_FUNCTION;
|
TIME_FUNCTION;
|
||||||
|
// std::cout << "excessdebug g2.483" << std::endl;
|
||||||
// Calculate dimensions
|
// Calculate dimensions
|
||||||
width = static_cast<int>(maxCorner.x - minCorner.x);
|
width = static_cast<int>(maxCorner.x - minCorner.x);
|
||||||
height = static_cast<int>(maxCorner.y - minCorner.y);
|
height = static_cast<int>(maxCorner.y - minCorner.y);
|
||||||
|
|
||||||
if (width <= 0 || height <= 0) {
|
if (width <= 0 || height <= 0) {
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
bgrData.clear();
|
rgbData.clear();
|
||||||
bgrData.shrink_to_fit();
|
rgbData.shrink_to_fit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// std::cout << "excessdebug g2.494" << std::endl;
|
||||||
|
|
||||||
// Initialize RGB data (3 bytes per pixel: R, G, B)
|
// Initialize RGB data (3 bytes per pixel: R, G, B)
|
||||||
std::vector<Vec4> rgbaBuffer(width * height, Vec4(0.0f, 0.0f, 0.0f, 0.0f));
|
std::vector<Vec4> rgbaBuffer(width * height, Vec4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
// For each position in the grid, find the corresponding pixel
|
// For each position in the grid, find the corresponding pixel
|
||||||
for (const auto& [id, pos] : Positions) {
|
for (const auto& [id, pos] : Positions) {
|
||||||
|
// std::cout << "excessdebug g2.501." << id << std::endl;
|
||||||
size_t size = Sizes.at(id);
|
size_t size = Sizes.at(id);
|
||||||
|
|
||||||
// Calculate pixel coordinates
|
// Calculate pixel coordinates
|
||||||
@@ -76,34 +79,42 @@ public:
|
|||||||
pixelXM = std::min(width - 1, pixelXM);
|
pixelXM = std::min(width - 1, pixelXM);
|
||||||
pixelYm = std::max(0, pixelYm);
|
pixelYm = std::max(0, pixelYm);
|
||||||
pixelYM = std::min(height - 1, pixelYM);
|
pixelYM = std::min(height - 1, pixelYM);
|
||||||
|
// std::cout << "excessdebug g2.514." << id << std::endl;
|
||||||
|
|
||||||
// Ensure within bounds
|
// Ensure within bounds
|
||||||
if (pixelXM >= minCorner.x && pixelXm < width && pixelYM >= minCorner.y && pixelYm < height) {
|
if (pixelXM >= minCorner.x && pixelXm < width && pixelYM >= minCorner.y && pixelYm < height) {
|
||||||
|
// std::cout << "excessdebug g2.518." << id << " - (" << pixelXm << "," << pixelYM << ")" << std::endl;
|
||||||
const Vec4& color = Colors.at(id);
|
const Vec4& color = Colors.at(id);
|
||||||
float srcAlpha = color.a;
|
float srcAlpha = color.a;
|
||||||
float invSrcAlpha = 1.0f - srcAlpha;
|
float invSrcAlpha = 1.0f - srcAlpha;
|
||||||
for (int py = pixelYm; py <= pixelYM; ++py){
|
for (int py = pixelYm; py <= pixelYM; ++py){
|
||||||
for (int px = pixelXm; px <= pixelXM; ++px){
|
for (int px = pixelXm; px <= pixelXM; ++px){
|
||||||
int index = (py * width + px) * 3;
|
// std::cout << "excessdebug g2.524." << id << " - (" << py << "," << px << ")" << std::endl;
|
||||||
Vec4& dest = rgbaBuffer[index];
|
int index = (py * width + px);
|
||||||
|
Vec4 dest = rgbaBuffer[index];
|
||||||
|
|
||||||
dest.r = color.r * srcAlpha + dest.r * invSrcAlpha;
|
dest.r = color.r * srcAlpha + dest.r; // * invSrcAlpha;
|
||||||
dest.g = color.g * srcAlpha + dest.g * invSrcAlpha;
|
dest.g = color.g * srcAlpha + dest.g; // * invSrcAlpha;
|
||||||
dest.b = color.b * srcAlpha + dest.b * invSrcAlpha;
|
dest.b = color.b * srcAlpha + dest.b; // * invSrcAlpha;
|
||||||
dest.a = srcAlpha + dest.a * invSrcAlpha;
|
dest.a = srcAlpha + dest.a; // * invSrcAlpha;
|
||||||
|
rgbaBuffer[index] = dest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bgrData.resize(dest.size() * 4);
|
rgbData.resize(rgbaBuffer.size() * 3);
|
||||||
for (int i = 0; i < width * height; ++i) {
|
for (int i = 0; i < rgbaBuffer.size(); ++i) {
|
||||||
const Vec4& color = rgbaBuffer[i];
|
const Vec4& color = rgbaBuffer[i];
|
||||||
int bgrIndex = i * 3;
|
int bgrIndex = i * 3;
|
||||||
|
|
||||||
// Convert from [0,1] to [0,255] and store as BGR
|
// Convert from [0,1] to [0,255] and store as RGB
|
||||||
bgrData[bgrIndex + 0] = static_cast<uint8_t>(color.b * 255); // Blue
|
// rgbData.push_back(color.r);
|
||||||
bgrData[bgrIndex + 1] = static_cast<uint8_t>(color.g * 255); // Green
|
// rgbData.push_back(color.g);
|
||||||
bgrData[bgrIndex + 2] = static_cast<uint8_t>(color.r * 255); // Red
|
// rgbData.push_back(color.b);
|
||||||
|
rgbData[bgrIndex + 2] = static_cast<unsigned char>(color.r * 255);
|
||||||
|
rgbData[bgrIndex + 1] = static_cast<unsigned char>(color.g * 255);
|
||||||
|
rgbData[bgrIndex + 0] = static_cast<unsigned char>(color.b * 255);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user