Codea 2.5.2 (99) beta

A small update to address some bugs you reported:

• Some editor scrolling bugs came to light and were fixed, especially relating to selecting results from the find/replace sidebar

• Invoking find/replace from the keyboard shortcut should work now (Update: this seems intermittent. It still occurs for me and I can’t consistently reproduce the find/replace bar not working from the keyboard)

• Hides the Materials pack from the Shader Lab. Shader Lab isn’t built to handle those, yet

I posted in previous thread. Nobody took in care.

@TokOut I logged your issue in the tracker when you posted it for @john to look at. I don’t think he has had a chance to yet.

Using find in the editor seems to be working OK. Tapping on found words moves the words into the viewing area instead of scrolling to the beginning or end of the code.

Thanks for testing and letting us know @dave1707

@Simeon Here’s something that’s probably existed forever. According to the reference, readProjectTab(name) should return nothing if it can’t find name, but instead causes an error. Another thing, the project name looks like it’s case insensitive, but the tab name is case sensitive. In the code below, the first 2 readProjectTabs work, but the third causes an. It would be nice if both were case insensitive and returned nil if nothing is found.

function setup()
    a=readProjectTab("CaRgO-bOt:Main")  -- mixed case project name, correct tab name
    print("size ",#a)     — above line works
    a=readProjectTab("cargo-bot:Main")  -- lower case project name, correct tab name
    print("size ",#a)     — above line works
    a=readProjectTab("cargo-bot:main")  -- lower case project and tab name
    print("size ",#a)     — above line causes an error    

@Simeon Something else that’s kind of weird. Sometimes when I close Codea with a project still open in the editor, then at a later time start Codea, there is a different project open in the editor. I thought when this happened in the past, that I might have been in that project, but just now when I opened Codea, I was in a project that I know I haven’t been in for maybe months. I’ll keep an eye out for this, and see if I can come up with a cause.

@John entity.worldRotation prints ’nil`.

I’m trying to work out how AR keeps track of where an entity is relative to the camera. Any hints on this? The world positions of the camera and entity don’t seem to change as I move the iPad around, and I can’t check world rotations as they print nil.

Hi @LoopSpace
This is a bit of an oversight which I’ll need to fix. ARKit provides matrices in a different handedness than what we’re using which I’ll need to compensate for.

@John I think that entity.inverseTransformPoint uses the wrong rotation matrix. Specifically, it uses entity.rotation instead of its inverse. I haven’t experimented with entity.inverseTransformDirection yet.

What I’m trying to do is interact with something that I’ve placed in AR. So I need to transform the touch point into the entity’s local space. Without entity.worldRotation, I wanted to use entity.inverseTransformPoint instead.

@LoopSpace I just checked my code. You’re right, I’m using the wrong matrix. This fix will be in the next beta.

@John Great!

By inverting the forward transformation, I’ve managed to do what I wanted: interact with an AR-projected scene. The core functionality can be seen in the video on this tweet. As I have a few more than 140 (or 280) characters here, let me give a bit more detail.

There are four entities:

  1. A Desert Cliff cube
  2. A Water cube, which is a child of the Desert Cliff cube
  3. A purple cube, which is a child of the Water cube
  4. A yellow sphere, which is not a child of anything

The cubes rotate, move, and scale as time passes, so the transformation from world space to the purple cube is non-trivial.

To position the yellow sphere, we take the vector vec3(1,0,0) in the local space of the water cube and translate it to a position in world space.

To position the purple cube, we take the current touch and project it onto a plane through the origin which is orthogonal to the vector from the camera at the centre of the screen. Then we transform that point into the local space of the water cube so that we can position the purple cube correctly. It stays in the right place - the green circle is a 2d ellipse at the CurrentTouch location - but the fact that it turns and changes shape shows that it is genuinely a child of the water cube.

At the moment, I’m doing this by taking the forward transformation and inverting it. Once @John has fixed the transformation, it’ll be possible using the entity:inverseTransformPoint routine directly.

I also checked it with one of my AR projects and it works just fine. I projected an AR image, moved around it, and then could interact with it via touch exactly as I wanted.

Have I said recently just how awesome Codea is???

Just checking in to say yay, you fixed that scrolling thing, great job!

May I make a feature request? It would be fantastic if you could type in letters in a search bar at the top of the dependencies list, to find specific projects for dependencies, just the same way you can do that in the main Projects screen of Codea.

Oh man oh man oh man oh man

What was that thing that I thought I saw someone else talking about, and that I thought was fixed, about losing tabs? I just lost like four tabs in a project and I’m freaking out.

What I did was:

  • have a project where “Main” was like the third or fourth tab
  • duplicate that project
  • delete the original (I was basically just renaming it)

…and when I opened the duplicate, everything before the “Main” tab was gone


Is there any hope of getting those tabs back?

@UberGoober I gave an example long ago of a way that tabs were being deleted, but I don’t know if that had anything to do with how your tabs were deleted. I don’t know if that led to any fixes. Codea has the Export Projects that works. It copies all of your projects into a zip file and it lets you import them all or just selected projects. A lot of times I’ll make a duplicate of any project I’m making major changes to so if I screw something up, I have the original. Here’s a suggestion for next time, make sure the copied project is OK before you delete the original. If you don’t have any backups, the only way to get the tabs back is to re-key them. A lot of times when you have to recreate a deleted project or tab, you do a better job of coding it.

@John Can you show an example of how to use craft.noise.cache(). Also, you didn’t include craft.noise.multiply() or craft.noise.invert() in the documentation.

EDIT: Also, any noise function that requires an input causes an error if it isn’t supplied. Instead of causing an error, a 0 should be assumed if an input isn’t supplied.

@dave1707 Thanks, I’ll make sure to fix those. Default parameters shouldn’t be a problem either.

@dave1707 The craft.noise.cache() module is helpful when you want to prevent redundant calculations. Here’s an example:

noise = craft.noise

-- Semi-expensive noise function
perlin = noise.perlin()

cachedPerlin = noise.cache()
cachedPerlin:setSource(0, perlin)

multipliedPerlin = noise.multiply()
multipliedPerlin:setSource(0, cachedPerlin)
multipliedPerlin:setSource(1, cachedPerlin)


Normally if you evaluated the multipliedPerlin module (which is just the perlin noise multiplied by itself) you would have to evaluate the perlin noise module twice. By using the cache module you only evaluate perlin once per call. There is another version of this for voxels called chunkCache2D which caches a grid of values for a voxel chunk which speeds up terrain generation quite a bit for some expensive noise modules.