This commit is contained in:
Arthur-D 2014-10-01 11:52:53 +02:00
commit c6d789d1ff
9 changed files with 69 additions and 105 deletions

View File

@ -35,7 +35,7 @@ void main(void)
float updated_lifetime = lifetime + (float(dt)/lifetime_initial);
if (updated_lifetime > 1.)
{
if (gl_VertexID <= level)
if (gl_VertexID < level)
{
float dt_from_last_frame = fract(updated_lifetime) * lifetime_initial;
vec4 updated_initialposition = sourcematrix * vec4(particle_position_initial, 1.0);

View File

@ -584,30 +584,30 @@ void CGUIContextMenu::draw()
skin->getColor(c), false, true, clip);
// draw submenu symbol
if (Items[i].SubMenu && sprites)
{
core::rect<s32> r = rect;
r.UpperLeftCorner.X = r.LowerRightCorner.X - 15;
sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT),
r.getCenter(), clip, skin->getColor(c),
(i == HighLighted) ? ChangeTime : 0,
(i == HighLighted) ? os::Timer::getTime() : 0,
(i == HighLighted), true);
}
//if (Items[i].SubMenu && sprites)
//{
// core::rect<s32> r = rect;
// r.UpperLeftCorner.X = r.LowerRightCorner.X - 15;
//
// sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT),
// r.getCenter(), clip, skin->getColor(c),
// (i == HighLighted) ? ChangeTime : 0,
// (i == HighLighted) ? os::Timer::getTime() : 0,
// (i == HighLighted), true);
//}
// draw checked symbol
if (Items[i].Checked && sprites)
{
core::rect<s32> r = rect;
r.LowerRightCorner.X = r.UpperLeftCorner.X - 15;
r.UpperLeftCorner.X = r.LowerRightCorner.X + 15;
sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED),
r.getCenter(), clip, skin->getColor(c),
(i == HighLighted) ? ChangeTime : 0,
(i == HighLighted) ? os::Timer::getTime() : 0,
(i == HighLighted), true);
}
//if (Items[i].Checked && sprites)
//{
// core::rect<s32> r = rect;
// r.LowerRightCorner.X = r.UpperLeftCorner.X - 15;
// r.UpperLeftCorner.X = r.LowerRightCorner.X + 15;
// sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED),
// r.getCenter(), clip, skin->getColor(c),
// (i == HighLighted) ? ChangeTime : 0,
// (i == HighLighted) ? os::Timer::getTime() : 0,
// (i == HighLighted), true);
//}
}
}

View File

@ -820,7 +820,6 @@ void getGLLimits(HardwareStats::Json *json)
STRING(VERSION);
STRING(VENDOR);
STRING(RENDERER);
STRING(EXTENSIONS);
INTEGER(SUBPIXEL_BITS);
INTEGER(MAX_TEXTURE_SIZE);
INTEGER(MAX_CUBE_MAP_TEXTURE_SIZE);

View File

@ -449,21 +449,4 @@ void ParticleSystemProxy::render() {
m_first_execution = false;
simulate();
draw();
}
bool ParticleSystemProxy::update()
{
doParticleSystem(os::Timer::getTime());
return (IsVisible && (Particles.size() != 0));
}
void ParticleSystemProxy::OnRegisterSceneNode()
{
doParticleSystem(os::Timer::getTime());
if (IsVisible && (Particles.size() != 0))
{
SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT);
ISceneNode::OnRegisterSceneNode();
}
}
}

View File

@ -70,7 +70,6 @@ public:
virtual void setEmitter(scene::IParticleEmitter* emitter);
virtual void render();
virtual void OnRegisterSceneNode();
void setAlphaAdditive(bool val) { m_alpha_additive = val; }
void setIncreaseFactor(float val) { size_increase_factor = val; }
void setColorFrom(float r, float g, float b) { m_color_from[0] = r; m_color_from[1] = g; m_color_from[2] = b; }
@ -79,7 +78,6 @@ public:
const float* getColorTo() const { return m_color_to; }
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);
void setFlip();
bool update();
};
#endif // GPUPARTICLES_H

View File

@ -439,7 +439,7 @@ parseSceneManager(core::list<scene::ISceneNode*> List, std::vector<scene::IScene
if (ParticleSystemProxy *node = dynamic_cast<ParticleSystemProxy *>(*I))
{
if (!isCulledPrecise(cam, *I, false) && node->update())
if (!isCulledPrecise(cam, *I, false))
ParticlesList::getInstance()->push_back(node);
continue;
}

View File

@ -43,7 +43,6 @@ IconButtonWidget::IconButtonWidget(ScaleMode scale_mode, const bool tab_stop,
m_font = NULL;
m_texture = NULL;
m_highlight_texture = NULL;
m_deactivated_texture = NULL;
m_custom_aspect_ratio = 1.0f;
m_texture_w = 0;
@ -56,12 +55,6 @@ IconButtonWidget::IconButtonWidget(ScaleMode scale_mode, const bool tab_stop,
m_icon_path_type = pathType;
}
// -----------------------------------------------------------------------------
IconButtonWidget::~IconButtonWidget()
{
if (m_deactivated_texture != NULL)
m_deactivated_texture->drop();
}
// -----------------------------------------------------------------------------
void IconButtonWidget::add()
{
// ---- Icon
@ -278,57 +271,22 @@ void IconButtonWidget::unfocused(const int playerID, Widget* new_focus)
}
}
// -----------------------------------------------------------------------------
video::ITexture* IconButtonWidget::getDeactivatedTexture(video::ITexture* texture)
{
SColor c;
u32 g;
video::IVideoDriver* driver = irr_driver->getVideoDriver();
video::IImage* image = driver->createImageFromData (texture->getColorFormat(),
texture->getSize(), texture->lock(), false);
texture->unlock();
//Turn the image into grayscale
for (u32 x = 0; x < image->getDimension().Width; x++)
{
for (u32 y = 0; y < image->getDimension().Height; y++)
{
c = image->getPixel(x, y);
g = ((c.getRed() + c.getGreen() + c.getBlue()) / 3);
c.set(std::max (0, (int)c.getAlpha() - 120), g, g, g);
image->setPixel(x, y, c);
}
}
texture = driver->addTexture(texture->getName().getPath() + "_disabled", image);
texture->grab();
return texture;
}
// -----------------------------------------------------------------------------
void IconButtonWidget::setTexture(video::ITexture* texture)
{
m_texture = texture;
if (texture == NULL)
{
if (m_deactivated_texture != NULL)
m_deactivated_texture->drop();
m_deactivated_texture = NULL;
m_texture_w = 0;
m_texture_h = 0;
}
else
{
m_deactivated_texture = getDeactivatedTexture(texture);
m_texture_w = texture->getSize().Width;
m_texture_h = texture->getSize().Height;
}
}
// -----------------------------------------------------------------------------
void IconButtonWidget::setLabelFont()
{

View File

@ -44,10 +44,8 @@ namespace GUIEngine
private:
irr::video::ITexture* m_texture;
irr::video::ITexture* m_highlight_texture;
irr::video::ITexture* m_deactivated_texture;
int m_texture_w, m_texture_h;
video::ITexture* getDeactivatedTexture(video::ITexture* texture);
void setLabelFont();
public:
@ -90,7 +88,7 @@ namespace GUIEngine
IconButtonWidget(ScaleMode scale_mode=SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, const bool tab_stop=true,
const bool focusable=true, IconPathType pathType=ICON_PATH_TYPE_RELATIVE);
virtual ~IconButtonWidget();
virtual ~IconButtonWidget() {};
/** \brief Implement callback from base class Widget */
virtual void add();
@ -160,8 +158,7 @@ namespace GUIEngine
virtual void unfocused(const int playerID, Widget* new_focus);
// --------------------------------------------------------------------
/** Returns the texture of this button. */
const video::ITexture* getTexture() const {
return (Widget::isActivated() ? m_texture : m_deactivated_texture); }
const video::ITexture* getTexture() const { return m_texture; }
};
}

View File

@ -390,6 +390,9 @@ void btKart::updateVehicle( btScalar step )
m_num_wheels_on_ground++;
}
// Test if the kart is falling so fast
// that the chassis might hit the track
// ------------------------------------
bool needs_cushioning_test = false;
for(int i=0; i<m_wheelInfo.size(); i++)
{
@ -405,20 +408,33 @@ void btKart::updateVehicle( btScalar step )
const btVector3 &v = m_chassisBody->getLinearVelocity();
btVector3 down(0, 1, 0);
btVector3 v_down = (v * down) * down;
btScalar max_compensate_speed = m_wheelInfo[0].m_maxSuspensionForce * m_chassisBody->getInvMass() * step *4;
// Estimate what kind of downward speed can be compensated by the
// suspension. Atm the parameters are set that the suspension is
// actually capped at max suspension force, so the maximum
// speed that can be caught by the suspension without the chassis
// hitting the ground can be based on that. Note that there are
// 4 suspensions, all adding together.
btScalar max_compensate_speed = m_wheelInfo[0].m_maxSuspensionForce
* m_chassisBody->getInvMass()
* step * 4;
// If the downward speed is too fast to be caught by the suspension,
// slow down the falling speed by applying an appropriately impulse:
if(-v_down.getY() > max_compensate_speed)
{
btVector3 impulse = down * (-v_down.getY() - max_compensate_speed) / m_chassisBody->getInvMass();
float v_old = m_chassisBody->getLinearVelocity().getY();
btVector3 impulse = down * (-v_down.getY() - max_compensate_speed)
/ m_chassisBody->getInvMass();
//float v_old = m_chassisBody->getLinearVelocity().getY();
m_chassisBody->applyCentralImpulse(impulse);
Log::verbose("physics", "Cushioning %f from %f m/s to %f m/s", impulse.getY(),
v_old, m_chassisBody->getLinearVelocity().getY());
//Log::verbose("physics", "Cushioning %f from %f m/s to %f m/s", impulse.getY(),
// v_old, m_chassisBody->getLinearVelocity().getY());
}
}
for(int i=0; i<m_wheelInfo.size(); i++)
m_wheelInfo[i].m_was_on_ground = m_wheelInfo[i].m_raycastInfo.m_isInContact;
// If the kart is flying, try to keep it parallel to the ground.
// -------------------------------------------------------------
if(m_num_wheels_on_ground==0)
{
btVector3 kart_up = getChassisWorldTransform().getBasis().getColumn(1);
@ -431,7 +447,8 @@ void btKart::updateVehicle( btScalar step )
// Work around: make sure that either both wheels on one axis
// are on ground, or none of them. This avoids the problem of
// the kart suddenly getting additional angular velocity because
// e.g. only one rear wheel is on the ground.
// e.g. only one rear wheel is on the ground and then the kart
// rotates very abruptly.
for(int i=0; i<m_wheelInfo.size(); i+=2)
{
if( m_wheelInfo[i ].m_raycastInfo.m_isInContact !=
@ -453,8 +470,10 @@ void btKart::updateVehicle( btScalar step )
}
} // for i=0; i<m_wheelInfo.size(); i+=2
updateSuspension(step);
// Apply suspension forcen (i.e. upwards force)
// --------------------------------------------
updateSuspension(step);
for (int i=0;i<m_wheelInfo.size();i++)
{
@ -476,9 +495,10 @@ void btKart::updateVehicle( btScalar step )
}
// Update friction (i.e. forward force)
// ------------------------------------
updateFriction( step);
for (int i=0;i<m_wheelInfo.size();i++)
{
btWheelInfo& wheel = m_wheelInfo[i];
@ -512,13 +532,20 @@ void btKart::updateVehicle( btScalar step )
wheel.m_deltaRotation *= btScalar(0.99);
}
float f = -m_kart->getSpeed()
* m_kart->getKartProperties()->getDownwardImpulseFactor();
btVector3 downwards_impulse = m_chassisBody->getWorldTransform().getBasis()
* btVector3(0, f, 0);
m_chassisBody->applyCentralImpulse(downwards_impulse);
// If configured, add a force to keep karts on the track
// -----------------------------------------------------
float dif = m_kart->getKartProperties()->getDownwardImpulseFactor();
if(dif!=0)
{
float f = -m_kart->getSpeed() * dif;
btVector3 downwards_impulse = m_chassisBody->getWorldTransform().getBasis()
* btVector3(0, f, 0);
m_chassisBody->applyCentralImpulse(downwards_impulse);
}
// Apply additional impulse set by supertuxkart
// --------------------------------------------
if(m_time_additional_impulse>0)
{
float dt = step > m_time_additional_impulse
@ -528,6 +555,8 @@ void btKart::updateVehicle( btScalar step )
m_time_additional_impulse -= dt;
}
// Apply additional rotation set by supertuxkart
// ---------------------------------------------
if(m_time_additional_rotation>0)
{
btTransform &t = m_chassisBody->getWorldTransform();