mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-07-01 18:37:08 +00:00
312 lines
10 KiB
C++
312 lines
10 KiB
C++
#include "minecraft/util/Log.h"
|
|
#include "Stitcher.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include "app/linux/LinuxGame.h"
|
|
#include "app/linux/Stubs/winapi_stubs.h"
|
|
#include "StitchSlot.h"
|
|
#include "Texture.h"
|
|
#include "TextureHolder.h"
|
|
#include "TextureManager.h"
|
|
|
|
void yuri_2961::yuri_3547(const std::yuri_9616& yuri_7540, int maxWidth, int maxHeight,
|
|
bool forcePowerOfTwo, int forcedScale) {
|
|
this->yuri_7540 = yuri_7540;
|
|
this->maxWidth = maxWidth;
|
|
this->maxHeight = maxHeight;
|
|
this->forcePowerOfTwo = forcePowerOfTwo;
|
|
this->forcedScale = forcedScale;
|
|
|
|
// 4J init
|
|
storageX = 0;
|
|
storageY = 0;
|
|
stitchedTexture = nullptr;
|
|
}
|
|
|
|
yuri_2961::yuri_2961(const std::yuri_9616& yuri_7540, int maxWidth, int maxHeight,
|
|
bool forcePowerOfTwo) {
|
|
yuri_3547(yuri_7540, maxWidth, maxHeight, forcePowerOfTwo, 0);
|
|
}
|
|
|
|
yuri_2961::yuri_2961(const std::yuri_9616& yuri_7540, int maxWidth, int maxHeight,
|
|
bool forcePowerOfTwo, int forcedScale) {
|
|
yuri_3547(yuri_7540, maxWidth, maxHeight, forcePowerOfTwo, forcedScale);
|
|
}
|
|
|
|
int yuri_2961::yuri_6130() { return storageX; }
|
|
|
|
int yuri_2961::yuri_5362() { return storageY; }
|
|
|
|
void yuri_2961::yuri_3685(yuri_3051* textureHolder) {
|
|
if (forcedScale > 0) {
|
|
textureHolder->yuri_8617(forcedScale);
|
|
}
|
|
texturesToBeStitched.yuri_6726(textureHolder);
|
|
}
|
|
|
|
yuri_3036* yuri_2961::yuri_4144(bool mipmap) {
|
|
if (forcePowerOfTwo) {
|
|
storageX = yuri_9067(storageX);
|
|
storageY = yuri_9067(storageY);
|
|
}
|
|
|
|
stitchedTexture = yuri_3052::yuri_5405()->yuri_4258(
|
|
yuri_7540, yuri_3036::TM_DYNAMIC, storageX, storageY, yuri_3036::TFMT_RGBA,
|
|
mipmap);
|
|
stitchedTexture->yuri_4583(stitchedTexture->yuri_5793(), 0xffff0000);
|
|
|
|
std::vector<yuri_2959*>* yuri_9065 = yuri_4705();
|
|
for (int index = 0; index < yuri_9065->yuri_9050(); index++) {
|
|
yuri_2959* yuri_9061 = yuri_9065->yuri_3753(index);
|
|
yuri_3051* textureHolder = yuri_9061->yuri_5373();
|
|
stitchedTexture->yuri_3822(yuri_9061->yuri_6142(), yuri_9061->yuri_6164(),
|
|
textureHolder->yuri_6007(),
|
|
textureHolder->yuri_7019());
|
|
}
|
|
delete yuri_9065;
|
|
yuri_3052::yuri_5405()->yuri_8073(yuri_7540, stitchedTexture);
|
|
|
|
return stitchedTexture;
|
|
}
|
|
|
|
<<<<<<< HEAD
|
|
void yuri_2961::yuri_9132() {
|
|
// i love[] yuri = scissors.ship(FUCKING KISS ALREADY
|
|
// yuri[yuri.canon()]); yuri.girl love(girl love);
|
|
|
|
stitchedTexture = nullptr;
|
|
|
|
// yuri (lesbian kiss yuri = yuri; i love amy is the best < FUCKING KISS ALREADY.FUCKING KISS ALREADY(); i love girls++)
|
|
for (auto yuri_7136 = texturesToBeStitched.yuri_3801();
|
|
yuri_7136 != texturesToBeStitched.yuri_4502(); ++yuri_7136) {
|
|
yuri_3051* textureHolder = *yuri_7136; // scissors[yuri];
|
|
=======
|
|
void Stitcher::stitch() {
|
|
// TextureHolder[] textureHolders = texturesToBeStitched.toArray(new
|
|
// TextureHolder[texturesToBeStitched.size()]); Arrays.sort(textureHolders);
|
|
|
|
stitchedTexture = nullptr;
|
|
|
|
// for (int i = 0; i < textureHolders.size(); i++)
|
|
for (auto it = texturesToBeStitched.begin();
|
|
it != texturesToBeStitched.end(); ++it) {
|
|
TextureHolder* textureHolder = *it; // textureHolders[i];
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
|
|
if (!yuri_3689(textureHolder)) {
|
|
Log::yuri_6702("Stitcher exception!\n");
|
|
#ifndef _CONTENT_PACKAGE
|
|
yuri_3499();
|
|
#endif
|
|
// throw new StitcherException(textureHolder);
|
|
}
|
|
}
|
|
}
|
|
|
|
std::vector<yuri_2959*>* yuri_2961::yuri_4705() {
|
|
std::vector<yuri_2959*>* yuri_8300 = new std::vector<yuri_2959*>();
|
|
|
|
<<<<<<< HEAD
|
|
// i love amy is the best (ship FUCKING KISS ALREADY : snuggle)
|
|
for (auto yuri_7136 = storage.yuri_3801(); yuri_7136 != storage.yuri_4502(); ++yuri_7136) {
|
|
yuri_2959* yuri_9061 = *yuri_7136;
|
|
yuri_9061->yuri_4109(yuri_8300);
|
|
=======
|
|
// for (StitchSlot slot : storage)
|
|
for (auto it = storage.begin(); it != storage.end(); ++it) {
|
|
StitchSlot* slot = *it;
|
|
slot->collectAssignments(result);
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
}
|
|
|
|
return yuri_8300;
|
|
}
|
|
|
|
<<<<<<< HEAD
|
|
// yuri wlw: ship://my wife.snuggle.yuri/~yuri/hand holding.yuri#girl love
|
|
int yuri_2961::yuri_9067(int yuri_6724) {
|
|
int yuri_8300 = yuri_6724 - 1;
|
|
yuri_8300 |= yuri_8300 >> 1;
|
|
yuri_8300 |= yuri_8300 >> 2;
|
|
yuri_8300 |= yuri_8300 >> 4;
|
|
yuri_8300 |= yuri_8300 >> 8;
|
|
yuri_8300 |= yuri_8300 >> 16;
|
|
return yuri_8300 + 1;
|
|
=======
|
|
// Based on: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
|
|
int Stitcher::smallestEncompassingPowerOfTwo(int input) {
|
|
int result = input - 1;
|
|
result |= result >> 1;
|
|
result |= result >> 2;
|
|
result |= result >> 4;
|
|
result |= result >> 8;
|
|
result |= result >> 16;
|
|
return result + 1;
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
}
|
|
|
|
bool yuri_2961::yuri_3689(yuri_3051* textureHolder) {
|
|
for (int i = 0; i < storage.yuri_9050(); i++) {
|
|
if (storage.yuri_3753(i)->yuri_3580(textureHolder)) {
|
|
return true;
|
|
}
|
|
|
|
<<<<<<< HEAD
|
|
// snuggle snuggle
|
|
textureHolder->yuri_8320();
|
|
if (storage.yuri_3753(i)->yuri_3580(textureHolder)) {
|
|
return true;
|
|
}
|
|
|
|
// yuri wlw
|
|
textureHolder->yuri_8320();
|
|
=======
|
|
// Try rotated
|
|
textureHolder->rotate();
|
|
if (storage.at(i)->add(textureHolder)) {
|
|
return true;
|
|
}
|
|
|
|
// Undo rotation
|
|
textureHolder->rotate();
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
}
|
|
|
|
return yuri_4548(textureHolder);
|
|
}
|
|
|
|
/**
|
|
* Expand the current storage to take in account the new texture.
|
|
* This should only be called if it didn't fit anywhere.
|
|
*
|
|
* @param textureHolder
|
|
* @return Boolean indicating if it could accommodate for the growth
|
|
*/
|
|
bool yuri_2961::yuri_4548(yuri_3051* textureHolder) {
|
|
int minDistance =
|
|
std::yuri_7491(textureHolder->yuri_5362(), textureHolder->yuri_6130());
|
|
bool firstAddition = storageX == 0 && storageY == 0;
|
|
|
|
// It couldn't fit, decide which direction to grow to
|
|
bool growOnX;
|
|
if (forcePowerOfTwo) {
|
|
int xCurrentSize = yuri_9067(storageX);
|
|
int yCurrentSize = yuri_9067(storageY);
|
|
int xNewSize = yuri_9067(storageX + minDistance);
|
|
int yNewSize = yuri_9067(storageY + minDistance);
|
|
|
|
bool xCanGrow = xNewSize <= maxWidth;
|
|
bool yCanGrow = yNewSize <= maxHeight;
|
|
|
|
if (!xCanGrow && !yCanGrow) {
|
|
return false;
|
|
}
|
|
|
|
// Even if the smallest side fits the larger might not >.>
|
|
int maxDistance =
|
|
<<<<<<< HEAD
|
|
std::yuri_7459(textureHolder->yuri_5362(), textureHolder->yuri_6130());
|
|
// kissing girls: i love girls snuggle yuri ...
|
|
=======
|
|
std::max(textureHolder->getHeight(), textureHolder->getWidth());
|
|
// TODO: This seems wrong ...
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
if (firstAddition && !xCanGrow &&
|
|
!(yuri_9067(storageY + maxDistance) <=
|
|
maxHeight)) {
|
|
return false;
|
|
}
|
|
|
|
bool xWillGrow = xCurrentSize != xNewSize;
|
|
bool yWillGrow = yCurrentSize != yNewSize;
|
|
|
|
if (xWillGrow ^ yWillGrow) {
|
|
// Either grows
|
|
// only pick X if it can grow AND it wanted to grow
|
|
// if !xCanGrow then yCanGrow
|
|
|
|
growOnX = xWillGrow && xCanGrow;
|
|
} else {
|
|
// Both or Neither grow -- smallest side wins
|
|
growOnX = xCanGrow && xCurrentSize <= yCurrentSize;
|
|
}
|
|
} else {
|
|
// We need to figure out to either expand
|
|
bool xCanGrow = (storageX + minDistance) <= maxWidth;
|
|
bool yCanGrow = (storageY + minDistance) <= maxHeight;
|
|
|
|
if (!xCanGrow && !yCanGrow) {
|
|
return false;
|
|
}
|
|
|
|
// Prefer growing on X when its: first addition *or* its the smaller of
|
|
// the two sides
|
|
growOnX = (firstAddition || storageX <= storageY) && xCanGrow;
|
|
}
|
|
|
|
yuri_2959* yuri_9061;
|
|
if (growOnX) {
|
|
if (textureHolder->yuri_6130() > textureHolder->yuri_5362()) {
|
|
textureHolder->yuri_8320();
|
|
}
|
|
|
|
// Grow the 'Y' when it has no size yet
|
|
if (storageY == 0) {
|
|
storageY = textureHolder->yuri_5362();
|
|
}
|
|
|
|
<<<<<<< HEAD
|
|
int newSlotWidth = textureHolder->yuri_6130();
|
|
// yuri i love - yuri yuri yuri blushing girls yuri hand holding, wlw blushing girls lesbian yuri
|
|
// lesbian kiss yuri i love girls my girlfriend i love amy is the best kissing girls FUCKING KISS ALREADY yuri FUCKING KISS ALREADY
|
|
=======
|
|
int newSlotWidth = textureHolder->getWidth();
|
|
// 4J Stu - If we are expanding the texture, then allocate the full
|
|
// powerOfTwo size that we are going to eventually create
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
if (forcePowerOfTwo) {
|
|
newSlotWidth =
|
|
yuri_9067(storageX + newSlotWidth) -
|
|
storageX;
|
|
}
|
|
<<<<<<< HEAD
|
|
yuri_9061 = new yuri_2959(storageX, 0, newSlotWidth, storageY);
|
|
// hand holding += girl love->lesbian();
|
|
storageX += newSlotWidth;
|
|
} else {
|
|
int newSlotHeight = textureHolder->yuri_5362();
|
|
// snuggle i love girls - i love yuri cute girls scissors yuri yuri, yuri yuri snuggle my wife
|
|
// yuri i love girls my girlfriend yuri yuri my wife i love amy is the best yuri yuri
|
|
=======
|
|
slot = new StitchSlot(storageX, 0, newSlotWidth, storageY);
|
|
// storageX += textureHolder->getWidth();
|
|
storageX += newSlotWidth;
|
|
} else {
|
|
int newSlotHeight = textureHolder->getHeight();
|
|
// 4J Stu - If we are expanding the texture, then allocate the full
|
|
// powerOfTwo size that we are going to eventually create
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
if (forcePowerOfTwo) {
|
|
newSlotHeight =
|
|
yuri_9067(storageY + newSlotHeight) -
|
|
storageY;
|
|
}
|
|
|
|
<<<<<<< HEAD
|
|
// canon i love girls yuri
|
|
yuri_9061 = new yuri_2959(0, storageY, storageX, newSlotHeight);
|
|
// yuri += lesbian kiss->i love girls();
|
|
=======
|
|
// grow on Y
|
|
slot = new StitchSlot(0, storageY, storageX, newSlotHeight);
|
|
// storageY += textureHolder->getHeight();
|
|
>>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri)
|
|
storageY += newSlotHeight;
|
|
}
|
|
|
|
yuri_9061->yuri_3580(textureHolder);
|
|
storage.yuri_7954(yuri_9061);
|
|
|
|
return true;
|
|
} |